define more default values for opConfig CRD
This commit is contained in:
		
							parent
							
								
									be208b61f1
								
							
						
					
					
						commit
						bb0de6ff53
					
				|  | @ -106,7 +106,7 @@ configKubernetes: | ||||||
|   # Postgres pods are terminated forcefully after this timeout |   # Postgres pods are terminated forcefully after this timeout | ||||||
|   pod_terminate_grace_period: 5m |   pod_terminate_grace_period: 5m | ||||||
|   # template for database user secrets generated by the operator |   # template for database user secrets generated by the operator | ||||||
|   secret_name_template: '{username}.{cluster}.credentials' |   secret_name_template: "{username}.{cluster}.credentials.{tprkind}.{tprgroup}" | ||||||
|   # group ID with write-access to volumes (required to run Spilo as non-root process) |   # group ID with write-access to volumes (required to run Spilo as non-root process) | ||||||
|   # spilo_fsgroup: "103" |   # spilo_fsgroup: "103" | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -49,16 +49,16 @@ data: | ||||||
|   # inherited_labels: application,environment |   # inherited_labels: application,environment | ||||||
|   # kube_iam_role: "" |   # kube_iam_role: "" | ||||||
|   # log_s3_bucket: "" |   # log_s3_bucket: "" | ||||||
|   # logical_backup_docker_image: "registry.opensource.zalan.do/acid/logical-backup" |   logical_backup_docker_image: "registry.opensource.zalan.do/acid/logical-backup" | ||||||
|   # logical_backup_s3_access_key_id: "" |   # logical_backup_s3_access_key_id: "" | ||||||
|   # logical_backup_s3_bucket: "my-bucket-url" |   logical_backup_s3_bucket: "my-bucket-url" | ||||||
|   # logical_backup_s3_region: "" |   # logical_backup_s3_region: "" | ||||||
|   # logical_backup_s3_endpoint: "" |   # logical_backup_s3_endpoint: "" | ||||||
|   # logical_backup_s3_secret_access_key: "" |   # logical_backup_s3_secret_access_key: "" | ||||||
|   # logical_backup_s3_sse: "AES256" |   logical_backup_s3_sse: "AES256" | ||||||
|   # logical_backup_schedule: "30 00 * * *" |   logical_backup_schedule: "30 00 * * *" | ||||||
|   master_dns_name_format: "{cluster}.{team}.{hostedzone}" |   master_dns_name_format: "{cluster}.{team}.{hostedzone}" | ||||||
|   # master_pod_move_timeout: 10m |   # master_pod_move_timeout: 20m | ||||||
|   # max_instances: "-1" |   # max_instances: "-1" | ||||||
|   # min_instances: "-1" |   # min_instances: "-1" | ||||||
|   # min_cpu_limit: 250m |   # min_cpu_limit: 250m | ||||||
|  |  | ||||||
|  | @ -33,28 +33,28 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur | ||||||
| 	result := &config.Config{} | 	result := &config.Config{} | ||||||
| 
 | 
 | ||||||
| 	// general config
 | 	// general config
 | ||||||
| 	result.EnableCRDValidation = fromCRD.EnableCRDValidation | 	result.EnableCRDValidation = util.CoalesceBool(fromCRD.EnableCRDValidation, util.True()) | ||||||
| 	result.EnableLazySpiloUpgrade = fromCRD.EnableLazySpiloUpgrade | 	result.EnableLazySpiloUpgrade = fromCRD.EnableLazySpiloUpgrade | ||||||
| 	result.EtcdHost = fromCRD.EtcdHost | 	result.EtcdHost = fromCRD.EtcdHost | ||||||
| 	result.KubernetesUseConfigMaps = fromCRD.KubernetesUseConfigMaps | 	result.KubernetesUseConfigMaps = fromCRD.KubernetesUseConfigMaps | ||||||
| 	result.DockerImage = fromCRD.DockerImage | 	result.DockerImage = util.Coalesce(fromCRD.DockerImage, "registry.opensource.zalan.do/acid/spilo-cdp-12:1.6-p115") | ||||||
| 	result.Workers = fromCRD.Workers | 	result.Workers = fromCRD.Workers | ||||||
| 	result.MinInstances = fromCRD.MinInstances | 	result.MinInstances = fromCRD.MinInstances | ||||||
| 	result.MaxInstances = fromCRD.MaxInstances | 	result.MaxInstances = fromCRD.MaxInstances | ||||||
| 	result.ResyncPeriod = time.Duration(fromCRD.ResyncPeriod) | 	result.ResyncPeriod = time.Duration(fromCRD.ResyncPeriod) | ||||||
| 	result.RepairPeriod = time.Duration(fromCRD.RepairPeriod) | 	result.RepairPeriod = time.Duration(fromCRD.RepairPeriod) | ||||||
| 	result.SetMemoryRequestToLimit = fromCRD.SetMemoryRequestToLimit | 	result.SetMemoryRequestToLimit = fromCRD.SetMemoryRequestToLimit | ||||||
| 	result.ShmVolume = fromCRD.ShmVolume | 	result.ShmVolume = util.CoalesceBool(fromCRD.ShmVolume, util.True()) | ||||||
| 	result.SidecarImages = fromCRD.SidecarImages | 	result.SidecarImages = fromCRD.SidecarImages | ||||||
| 	result.SidecarContainers = fromCRD.SidecarContainers | 	result.SidecarContainers = fromCRD.SidecarContainers | ||||||
| 
 | 
 | ||||||
| 	// user config
 | 	// user config
 | ||||||
| 	result.SuperUsername = fromCRD.PostgresUsersConfiguration.SuperUsername | 	result.SuperUsername = util.Coalesce(fromCRD.PostgresUsersConfiguration.SuperUsername, "postgres") | ||||||
| 	result.ReplicationUsername = fromCRD.PostgresUsersConfiguration.ReplicationUsername | 	result.ReplicationUsername = util.Coalesce(fromCRD.PostgresUsersConfiguration.ReplicationUsername, "standby") | ||||||
| 
 | 
 | ||||||
| 	// kubernetes config
 | 	// kubernetes config
 | ||||||
| 	result.CustomPodAnnotations = fromCRD.Kubernetes.CustomPodAnnotations | 	result.CustomPodAnnotations = fromCRD.Kubernetes.CustomPodAnnotations | ||||||
| 	result.PodServiceAccountName = fromCRD.Kubernetes.PodServiceAccountName | 	result.PodServiceAccountName = util.Coalesce(fromCRD.Kubernetes.PodServiceAccountName, "postgres-pod") | ||||||
| 	result.PodServiceAccountDefinition = fromCRD.Kubernetes.PodServiceAccountDefinition | 	result.PodServiceAccountDefinition = fromCRD.Kubernetes.PodServiceAccountDefinition | ||||||
| 	result.PodServiceAccountRoleBindingDefinition = fromCRD.Kubernetes.PodServiceAccountRoleBindingDefinition | 	result.PodServiceAccountRoleBindingDefinition = fromCRD.Kubernetes.PodServiceAccountRoleBindingDefinition | ||||||
| 	result.PodEnvironmentConfigMap = fromCRD.Kubernetes.PodEnvironmentConfigMap | 	result.PodEnvironmentConfigMap = fromCRD.Kubernetes.PodEnvironmentConfigMap | ||||||
|  | @ -64,30 +64,30 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur | ||||||
| 	result.ClusterDomain = util.Coalesce(fromCRD.Kubernetes.ClusterDomain, "cluster.local") | 	result.ClusterDomain = util.Coalesce(fromCRD.Kubernetes.ClusterDomain, "cluster.local") | ||||||
| 	result.WatchedNamespace = fromCRD.Kubernetes.WatchedNamespace | 	result.WatchedNamespace = fromCRD.Kubernetes.WatchedNamespace | ||||||
| 	result.PDBNameFormat = fromCRD.Kubernetes.PDBNameFormat | 	result.PDBNameFormat = fromCRD.Kubernetes.PDBNameFormat | ||||||
| 	result.EnablePodDisruptionBudget = fromCRD.Kubernetes.EnablePodDisruptionBudget | 	result.EnablePodDisruptionBudget = util.CoalesceBool(fromCRD.Kubernetes.EnablePodDisruptionBudget, util.True()) | ||||||
| 	result.EnableInitContainers = fromCRD.Kubernetes.EnableInitContainers | 	result.EnableInitContainers = util.CoalesceBool(fromCRD.Kubernetes.EnableInitContainers, util.True()) | ||||||
| 	result.EnableSidecars = fromCRD.Kubernetes.EnableSidecars | 	result.EnableSidecars = util.CoalesceBool(fromCRD.Kubernetes.EnableSidecars, util.True()) | ||||||
| 	result.SecretNameTemplate = fromCRD.Kubernetes.SecretNameTemplate | 	result.SecretNameTemplate = fromCRD.Kubernetes.SecretNameTemplate | ||||||
| 	result.OAuthTokenSecretName = fromCRD.Kubernetes.OAuthTokenSecretName | 	result.OAuthTokenSecretName = fromCRD.Kubernetes.OAuthTokenSecretName | ||||||
| 	result.InfrastructureRolesSecretName = fromCRD.Kubernetes.InfrastructureRolesSecretName | 	result.InfrastructureRolesSecretName = fromCRD.Kubernetes.InfrastructureRolesSecretName | ||||||
| 	result.PodRoleLabel = fromCRD.Kubernetes.PodRoleLabel | 	result.PodRoleLabel = util.Coalesce(fromCRD.Kubernetes.PodRoleLabel, "spilo-role") | ||||||
| 	result.ClusterLabels = fromCRD.Kubernetes.ClusterLabels | 	result.ClusterLabels = fromCRD.Kubernetes.ClusterLabels | ||||||
| 	result.InheritedLabels = fromCRD.Kubernetes.InheritedLabels | 	result.InheritedLabels = fromCRD.Kubernetes.InheritedLabels | ||||||
| 	result.ClusterNameLabel = fromCRD.Kubernetes.ClusterNameLabel | 	result.ClusterNameLabel = util.Coalesce(fromCRD.Kubernetes.ClusterNameLabel, "cluster-name") | ||||||
| 	result.NodeReadinessLabel = fromCRD.Kubernetes.NodeReadinessLabel | 	result.NodeReadinessLabel = fromCRD.Kubernetes.NodeReadinessLabel | ||||||
| 	result.PodPriorityClassName = fromCRD.Kubernetes.PodPriorityClassName | 	result.PodPriorityClassName = fromCRD.Kubernetes.PodPriorityClassName | ||||||
| 	result.PodManagementPolicy = fromCRD.Kubernetes.PodManagementPolicy | 	result.PodManagementPolicy = util.Coalesce(fromCRD.Kubernetes.PodManagementPolicy, "ordered_ready") | ||||||
| 	result.MasterPodMoveTimeout = time.Duration(fromCRD.Kubernetes.MasterPodMoveTimeout) | 	result.MasterPodMoveTimeout = time.Duration(fromCRD.Kubernetes.MasterPodMoveTimeout) | ||||||
| 	result.EnablePodAntiAffinity = fromCRD.Kubernetes.EnablePodAntiAffinity | 	result.EnablePodAntiAffinity = fromCRD.Kubernetes.EnablePodAntiAffinity | ||||||
| 	result.PodAntiAffinityTopologyKey = fromCRD.Kubernetes.PodAntiAffinityTopologyKey | 	result.PodAntiAffinityTopologyKey = util.Coalesce(fromCRD.Kubernetes.PodAntiAffinityTopologyKey, "kubernetes.io/hostname") | ||||||
| 
 | 
 | ||||||
| 	// Postgres Pod resources
 | 	// Postgres Pod resources
 | ||||||
| 	result.DefaultCPURequest = fromCRD.PostgresPodResources.DefaultCPURequest | 	result.DefaultCPURequest = util.Coalesce(fromCRD.PostgresPodResources.DefaultCPURequest, "100m") | ||||||
| 	result.DefaultMemoryRequest = fromCRD.PostgresPodResources.DefaultMemoryRequest | 	result.DefaultMemoryRequest = util.Coalesce(fromCRD.PostgresPodResources.DefaultMemoryRequest, "100Mi") | ||||||
| 	result.DefaultCPULimit = fromCRD.PostgresPodResources.DefaultCPULimit | 	result.DefaultCPULimit = util.Coalesce(fromCRD.PostgresPodResources.DefaultCPULimit, "1") | ||||||
| 	result.DefaultMemoryLimit = fromCRD.PostgresPodResources.DefaultMemoryLimit | 	result.DefaultMemoryLimit = util.Coalesce(fromCRD.PostgresPodResources.DefaultMemoryLimit, "500Mi") | ||||||
| 	result.MinCPULimit = fromCRD.PostgresPodResources.MinCPULimit | 	result.MinCPULimit = util.Coalesce(fromCRD.PostgresPodResources.MinCPULimit, "250m") | ||||||
| 	result.MinMemoryLimit = fromCRD.PostgresPodResources.MinMemoryLimit | 	result.MinMemoryLimit = util.Coalesce(fromCRD.PostgresPodResources.MinMemoryLimit, "250Mi") | ||||||
| 
 | 
 | ||||||
| 	// timeout config
 | 	// timeout config
 | ||||||
| 	result.ResourceCheckInterval = time.Duration(fromCRD.Timeouts.ResourceCheckInterval) | 	result.ResourceCheckInterval = time.Duration(fromCRD.Timeouts.ResourceCheckInterval) | ||||||
|  | @ -114,8 +114,8 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur | ||||||
| 	result.AdditionalSecretMountPath = fromCRD.AWSGCP.AdditionalSecretMountPath | 	result.AdditionalSecretMountPath = fromCRD.AWSGCP.AdditionalSecretMountPath | ||||||
| 
 | 
 | ||||||
| 	// logical backup config
 | 	// logical backup config
 | ||||||
| 	result.LogicalBackupSchedule = fromCRD.LogicalBackup.Schedule | 	result.LogicalBackupSchedule = util.Coalesce(fromCRD.LogicalBackup.Schedule, "30 00 * * *") | ||||||
| 	result.LogicalBackupDockerImage = fromCRD.LogicalBackup.DockerImage | 	result.LogicalBackupDockerImage = util.Coalesce(fromCRD.LogicalBackup.DockerImage, "registry.opensource.zalan.do/acid/logical-backup") | ||||||
| 	result.LogicalBackupS3Bucket = fromCRD.LogicalBackup.S3Bucket | 	result.LogicalBackupS3Bucket = fromCRD.LogicalBackup.S3Bucket | ||||||
| 	result.LogicalBackupS3Region = fromCRD.LogicalBackup.S3Region | 	result.LogicalBackupS3Region = fromCRD.LogicalBackup.S3Region | ||||||
| 	result.LogicalBackupS3Endpoint = fromCRD.LogicalBackup.S3Endpoint | 	result.LogicalBackupS3Endpoint = fromCRD.LogicalBackup.S3Endpoint | ||||||
|  |  | ||||||
|  | @ -82,7 +82,7 @@ type LogicalBackup struct { | ||||||
| 	LogicalBackupS3Endpoint        string `name:"logical_backup_s3_endpoint" default:""` | 	LogicalBackupS3Endpoint        string `name:"logical_backup_s3_endpoint" default:""` | ||||||
| 	LogicalBackupS3AccessKeyID     string `name:"logical_backup_s3_access_key_id" default:""` | 	LogicalBackupS3AccessKeyID     string `name:"logical_backup_s3_access_key_id" default:""` | ||||||
| 	LogicalBackupS3SecretAccessKey string `name:"logical_backup_s3_secret_access_key" default:""` | 	LogicalBackupS3SecretAccessKey string `name:"logical_backup_s3_secret_access_key" default:""` | ||||||
| 	LogicalBackupS3SSE             string `name:"logical_backup_s3_sse" default:"AES256"` | 	LogicalBackupS3SSE             string `name:"logical_backup_s3_sse" default:""` | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // Operator options for connection pooler
 | // Operator options for connection pooler
 | ||||||
|  |  | ||||||
|  | @ -147,7 +147,7 @@ func Coalesce(val, defaultVal string) string { | ||||||
| 	return val | 	return val | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // Yeah, golang
 | // CoalesceInt32 works like coalesce but for *int32
 | ||||||
| func CoalesceInt32(val, defaultVal *int32) *int32 { | func CoalesceInt32(val, defaultVal *int32) *int32 { | ||||||
| 	if val == nil { | 	if val == nil { | ||||||
| 		return defaultVal | 		return defaultVal | ||||||
|  | @ -155,6 +155,14 @@ func CoalesceInt32(val, defaultVal *int32) *int32 { | ||||||
| 	return val | 	return val | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // CoalesceBool works like coalesce but for *bool
 | ||||||
|  | func CoalesceBool(val, defaultVal *bool) *bool { | ||||||
|  | 	if val == nil { | ||||||
|  | 		return defaultVal | ||||||
|  | 	} | ||||||
|  | 	return val | ||||||
|  | } | ||||||
|  | 
 | ||||||
| // Test if any of the values is nil
 | // Test if any of the values is nil
 | ||||||
| func testNil(values ...*int32) bool { | func testNil(values ...*int32) bool { | ||||||
| 	for _, v := range values { | 	for _, v := range values { | ||||||
|  | @ -166,8 +174,8 @@ func testNil(values ...*int32) bool { | ||||||
| 	return false | 	return false | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // Return maximum of two integers provided via pointers. If one value is not
 | // MaxInt32 : Return maximum of two integers provided via pointers. If one value
 | ||||||
| // defined, return the other one. If both are not defined, result is also
 | // is not defined, return the other one. If both are not defined, result is also
 | ||||||
| // undefined, caller needs to check for that.
 | // undefined, caller needs to check for that.
 | ||||||
| func MaxInt32(a, b *int32) *int32 { | func MaxInt32(a, b *int32) *int32 { | ||||||
| 	if testNil(a, b) { | 	if testNil(a, b) { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue