kubernetes_use_configmap (#887)
* kubernetes_use_configmap * Update manifests/postgresql-operator-default-configuration.yaml Co-Authored-By: Felix Kunde <felix-kunde@gmx.de> * Update manifests/configmap.yaml Co-Authored-By: Felix Kunde <felix-kunde@gmx.de> * Update charts/postgres-operator/values.yaml Co-Authored-By: Felix Kunde <felix-kunde@gmx.de> * go.fmt Co-authored-by: Felix Kunde <felix-kunde@gmx.de>
This commit is contained in:
		
							parent
							
								
									b43b22dfcc
								
							
						
					
					
						commit
						1249626a60
					
				|  | @ -66,6 +66,8 @@ spec: | ||||||
|               type: boolean |               type: boolean | ||||||
|             etcd_host: |             etcd_host: | ||||||
|               type: string |               type: string | ||||||
|  |             kubernetes_use_configmaps: | ||||||
|  |               type: boolean | ||||||
|             max_instances: |             max_instances: | ||||||
|               type: integer |               type: integer | ||||||
|               minimum: -1  # -1 = disabled |               minimum: -1  # -1 = disabled | ||||||
|  |  | ||||||
|  | @ -23,6 +23,8 @@ configGeneral: | ||||||
|   enable_shm_volume: true |   enable_shm_volume: true | ||||||
|   # etcd connection string for Patroni. Empty uses K8s-native DCS. |   # etcd connection string for Patroni. Empty uses K8s-native DCS. | ||||||
|   etcd_host: "" |   etcd_host: "" | ||||||
|  |   # Select if setup uses endpoints (default), or configmaps to manage leader (DCS=k8s) | ||||||
|  |   # kubernetes_use_configmaps: false | ||||||
|   # Spilo docker image |   # Spilo docker image | ||||||
|   docker_image: registry.opensource.zalan.do/acid/spilo-12:1.6-p2 |   docker_image: registry.opensource.zalan.do/acid/spilo-12:1.6-p2 | ||||||
|   # max number of instances in Postgres cluster. -1 = no limit |   # max number of instances in Postgres cluster. -1 = no limit | ||||||
|  |  | ||||||
|  | @ -23,6 +23,8 @@ configGeneral: | ||||||
|   enable_shm_volume: "true" |   enable_shm_volume: "true" | ||||||
|   # etcd connection string for Patroni. Empty uses K8s-native DCS. |   # etcd connection string for Patroni. Empty uses K8s-native DCS. | ||||||
|   etcd_host: "" |   etcd_host: "" | ||||||
|  |   # Select if setup uses endpoints (default), or configmaps to manage leader (DCS=k8s) | ||||||
|  |   # kubernetes_use_configmaps: "false" | ||||||
|   # Spilo docker image |   # Spilo docker image | ||||||
|   docker_image: registry.opensource.zalan.do/acid/spilo-12:1.6-p2 |   docker_image: registry.opensource.zalan.do/acid/spilo-12:1.6-p2 | ||||||
|   # max number of instances in Postgres cluster. -1 = no limit |   # max number of instances in Postgres cluster. -1 = no limit | ||||||
|  |  | ||||||
|  | @ -80,6 +80,12 @@ Those are top-level keys, containing both leaf keys and groups. | ||||||
|   Patroni native Kubernetes support is used. The default is empty (use |   Patroni native Kubernetes support is used. The default is empty (use | ||||||
|   Kubernetes-native DCS). |   Kubernetes-native DCS). | ||||||
| 
 | 
 | ||||||
|  | * **kubernetes_use_configmaps** | ||||||
|  |   Select if setup uses endpoints (default), or configmaps to manage leader when | ||||||
|  |   DCS is kubernetes (not etcd or similar). In OpenShift it is not possible to | ||||||
|  |   use endpoints option, and configmaps is required. By default,  | ||||||
|  |   `kubernetes_use_configmaps: false`, meaning endpoints will be used. | ||||||
|  | 
 | ||||||
| * **docker_image** | * **docker_image** | ||||||
|   Spilo Docker image for Postgres instances. For production, don't rely on the |   Spilo Docker image for Postgres instances. For production, don't rely on the | ||||||
|   default image, as it might be not the most up-to-date one. Instead, build |   default image, as it might be not the most up-to-date one. Instead, build | ||||||
|  |  | ||||||
|  | @ -43,6 +43,7 @@ data: | ||||||
|   # enable_team_superuser: "false" |   # enable_team_superuser: "false" | ||||||
|   enable_teams_api: "false" |   enable_teams_api: "false" | ||||||
|   # etcd_host: "" |   # etcd_host: "" | ||||||
|  |   # kubernetes_use_configmaps: "false" | ||||||
|   # infrastructure_roles_secret_name: postgresql-infrastructure-roles |   # infrastructure_roles_secret_name: postgresql-infrastructure-roles | ||||||
|   # inherited_labels: application,environment |   # inherited_labels: application,environment | ||||||
|   # kube_iam_role: "" |   # kube_iam_role: "" | ||||||
|  |  | ||||||
|  | @ -42,6 +42,8 @@ spec: | ||||||
|               type: boolean |               type: boolean | ||||||
|             etcd_host: |             etcd_host: | ||||||
|               type: string |               type: string | ||||||
|  |             kubernetes_use_configmaps: | ||||||
|  |               type: boolean | ||||||
|             max_instances: |             max_instances: | ||||||
|               type: integer |               type: integer | ||||||
|               minimum: -1  # -1 = disabled |               minimum: -1  # -1 = disabled | ||||||
|  |  | ||||||
|  | @ -5,6 +5,7 @@ metadata: | ||||||
| configuration: | configuration: | ||||||
|   # enable_crd_validation: true |   # enable_crd_validation: true | ||||||
|   etcd_host: "" |   etcd_host: "" | ||||||
|  |   # kubernetes_use_configmaps: false | ||||||
|   docker_image: registry.opensource.zalan.do/acid/spilo-12:1.6-p2 |   docker_image: registry.opensource.zalan.do/acid/spilo-12:1.6-p2 | ||||||
|   # enable_shm_volume: true |   # enable_shm_volume: true | ||||||
|   max_instances: -1 |   max_instances: -1 | ||||||
|  |  | ||||||
|  | @ -727,6 +727,9 @@ var OperatorConfigCRDResourceValidation = apiextv1beta1.CustomResourceValidation | ||||||
| 					"etcd_host": { | 					"etcd_host": { | ||||||
| 						Type: "string", | 						Type: "string", | ||||||
| 					}, | 					}, | ||||||
|  | 					"kubernetes_use_configmaps": { | ||||||
|  | 						Type: "boolean", | ||||||
|  | 					}, | ||||||
| 					"max_instances": { | 					"max_instances": { | ||||||
| 						Type:        "integer", | 						Type:        "integer", | ||||||
| 						Description: "-1 = disabled", | 						Description: "-1 = disabled", | ||||||
|  |  | ||||||
|  | @ -183,6 +183,7 @@ type OperatorLogicalBackupConfiguration struct { | ||||||
| type OperatorConfigurationData struct { | type OperatorConfigurationData struct { | ||||||
| 	EnableCRDValidation        *bool                              `json:"enable_crd_validation,omitempty"` | 	EnableCRDValidation        *bool                              `json:"enable_crd_validation,omitempty"` | ||||||
| 	EtcdHost                   string                             `json:"etcd_host,omitempty"` | 	EtcdHost                   string                             `json:"etcd_host,omitempty"` | ||||||
|  | 	KubernetesUseConfigMaps    bool                               `json:"kubernetes_use_configmaps,omitempty"` | ||||||
| 	DockerImage                string                             `json:"docker_image,omitempty"` | 	DockerImage                string                             `json:"docker_image,omitempty"` | ||||||
| 	Workers                    uint32                             `json:"workers,omitempty"` | 	Workers                    uint32                             `json:"workers,omitempty"` | ||||||
| 	MinInstances               int32                              `json:"min_instances,omitempty"` | 	MinInstances               int32                              `json:"min_instances,omitempty"` | ||||||
|  |  | ||||||
|  | @ -672,6 +672,10 @@ func (c *Cluster) generateSpiloPodEnvVars(uid types.UID, spiloConfiguration stri | ||||||
| 		envVars = append(envVars, v1.EnvVar{Name: "ETCD_HOST", Value: c.OpConfig.EtcdHost}) | 		envVars = append(envVars, v1.EnvVar{Name: "ETCD_HOST", Value: c.OpConfig.EtcdHost}) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	if c.patroniKubernetesUseConfigMaps() { | ||||||
|  | 		envVars = append(envVars, v1.EnvVar{Name: "KUBERNETES_USE_CONFIGMAPS", Value: "true"}) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	if cloneDescription.ClusterName != "" { | 	if cloneDescription.ClusterName != "" { | ||||||
| 		envVars = append(envVars, c.generateCloneEnvironment(cloneDescription)...) | 		envVars = append(envVars, c.generateCloneEnvironment(cloneDescription)...) | ||||||
| 	} | 	} | ||||||
|  | @ -1406,7 +1410,7 @@ func (c *Cluster) generateService(role PostgresRole, spec *acidv1.PostgresSpec) | ||||||
| 		Type:  v1.ServiceTypeClusterIP, | 		Type:  v1.ServiceTypeClusterIP, | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if role == Replica { | 	if role == Replica || c.patroniKubernetesUseConfigMaps() { | ||||||
| 		serviceSpec.Selector = c.roleLabelsSet(false, role) | 		serviceSpec.Selector = c.roleLabelsSet(false, role) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -510,6 +510,15 @@ func (c *Cluster) patroniUsesKubernetes() bool { | ||||||
| 	return c.OpConfig.EtcdHost == "" | 	return c.OpConfig.EtcdHost == "" | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | func (c *Cluster) patroniKubernetesUseConfigMaps() bool { | ||||||
|  | 	if !c.patroniUsesKubernetes() { | ||||||
|  | 		return false | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	// otherwise, follow the operator configuration
 | ||||||
|  | 	return c.OpConfig.KubernetesUseConfigMaps | ||||||
|  | } | ||||||
|  | 
 | ||||||
| func (c *Cluster) needConnectionPoolerWorker(spec *acidv1.PostgresSpec) bool { | func (c *Cluster) needConnectionPoolerWorker(spec *acidv1.PostgresSpec) bool { | ||||||
| 	if spec.EnableConnectionPooler == nil { | 	if spec.EnableConnectionPooler == nil { | ||||||
| 		return spec.ConnectionPooler != nil | 		return spec.ConnectionPooler != nil | ||||||
|  |  | ||||||
|  | @ -35,6 +35,7 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur | ||||||
| 	// general config
 | 	// general config
 | ||||||
| 	result.EnableCRDValidation = fromCRD.EnableCRDValidation | 	result.EnableCRDValidation = fromCRD.EnableCRDValidation | ||||||
| 	result.EtcdHost = fromCRD.EtcdHost | 	result.EtcdHost = fromCRD.EtcdHost | ||||||
|  | 	result.KubernetesUseConfigMaps = fromCRD.KubernetesUseConfigMaps | ||||||
| 	result.DockerImage = fromCRD.DockerImage | 	result.DockerImage = fromCRD.DockerImage | ||||||
| 	result.Workers = fromCRD.Workers | 	result.Workers = fromCRD.Workers | ||||||
| 	result.MinInstances = fromCRD.MinInstances | 	result.MinInstances = fromCRD.MinInstances | ||||||
|  |  | ||||||
|  | @ -107,11 +107,12 @@ type Config struct { | ||||||
| 	LogicalBackup | 	LogicalBackup | ||||||
| 	ConnectionPooler | 	ConnectionPooler | ||||||
| 
 | 
 | ||||||
| 	WatchedNamespace      string            `name:"watched_namespace"`    // special values: "*" means 'watch all namespaces', the empty string "" means 'watch a namespace where operator is deployed to'
 | 	WatchedNamespace        string            `name:"watched_namespace"` // special values: "*" means 'watch all namespaces', the empty string "" means 'watch a namespace where operator is deployed to'
 | ||||||
| 	EtcdHost              string            `name:"etcd_host" default:""` // special values: the empty string "" means Patroni will use K8s as a DCS
 | 	KubernetesUseConfigMaps bool              `name:"kubernetes_use_configmaps" default:"false"` | ||||||
| 	DockerImage           string            `name:"docker_image" default:"registry.opensource.zalan.do/acid/spilo-12:1.6-p2"` | 	EtcdHost                string            `name:"etcd_host" default:""` // special values: the empty string "" means Patroni will use K8s as a DCS
 | ||||||
| 	Sidecars              map[string]string `name:"sidecar_docker_images"` | 	DockerImage             string            `name:"docker_image" default:"registry.opensource.zalan.do/acid/spilo-12:1.6-p2"` | ||||||
| 	PodServiceAccountName string            `name:"pod_service_account_name" default:"postgres-pod"` | 	Sidecars                map[string]string `name:"sidecar_docker_images"` | ||||||
|  | 	PodServiceAccountName   string            `name:"pod_service_account_name" default:"postgres-pod"` | ||||||
| 	// value of this string must be valid JSON or YAML; see initPodServiceAccount
 | 	// value of this string must be valid JSON or YAML; see initPodServiceAccount
 | ||||||
| 	PodServiceAccountDefinition            string            `name:"pod_service_account_definition" default:""` | 	PodServiceAccountDefinition            string            `name:"pod_service_account_definition" default:""` | ||||||
| 	PodServiceAccountRoleBindingDefinition string            `name:"pod_service_account_role_binding_definition" default:""` | 	PodServiceAccountRoleBindingDefinition string            `name:"pod_service_account_role_binding_definition" default:""` | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue