mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-09-30 17:01:16 +02:00
Merge branch 'master' into check-cluster-UID
This commit is contained in:
@@ -410,7 +410,7 @@ type OperatorConfigurationData struct {
|
||||
// +kubebuilder:default=""
|
||||
EtcdHost string `json:"etcd_host,omitempty"`
|
||||
// +kubebuilder:default=true
|
||||
KubernetesUseConfigMaps bool `json:"kubernetes_use_configmaps,omitempty"`
|
||||
KubernetesUseConfigMaps *bool `json:"kubernetes_use_configmaps,omitempty"`
|
||||
// +kubebuilder:default="ghcr.io/zalando/spilo-18:4.1-p1"
|
||||
DockerImage string `json:"docker_image,omitempty"`
|
||||
// +kubebuilder:validation:Minimum=1
|
||||
|
||||
@@ -443,6 +443,11 @@ func (in *OperatorConfigurationData) DeepCopyInto(out *OperatorConfigurationData
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.KubernetesUseConfigMaps != nil {
|
||||
in, out := &in.KubernetesUseConfigMaps, &out.KubernetesUseConfigMaps
|
||||
*out = new(bool)
|
||||
**out = **in
|
||||
}
|
||||
if in.ResyncPeriod != nil {
|
||||
in, out := &in.ResyncPeriod, &out.ResyncPeriod
|
||||
*out = new(metav1.Duration)
|
||||
|
||||
@@ -95,6 +95,7 @@ func TestCreate(t *testing.T) {
|
||||
|
||||
client := k8sutil.KubernetesClient{
|
||||
DeploymentsGetter: clientSet.AppsV1(),
|
||||
ConfigMapsGetter: clientSet.CoreV1(),
|
||||
CronJobsGetter: clientSet.BatchV1(),
|
||||
EndpointsGetter: clientSet.CoreV1(),
|
||||
PersistentVolumeClaimsGetter: clientSet.CoreV1(),
|
||||
|
||||
+25
-24
@@ -582,60 +582,60 @@ func TestGenerateSpiloPodEnvVars(t *testing.T) {
|
||||
}
|
||||
expectedValuesS3Bucket := []ExpectedValue{
|
||||
{
|
||||
envIndex: 15,
|
||||
envIndex: 16,
|
||||
envVarConstant: "WAL_S3_BUCKET",
|
||||
envVarValue: "global-s3-bucket",
|
||||
},
|
||||
{
|
||||
envIndex: 16,
|
||||
envIndex: 17,
|
||||
envVarConstant: "WAL_BUCKET_SCOPE_SUFFIX",
|
||||
envVarValue: fmt.Sprintf("/%s", dummyUUID),
|
||||
},
|
||||
{
|
||||
envIndex: 17,
|
||||
envIndex: 18,
|
||||
envVarConstant: "WAL_BUCKET_SCOPE_PREFIX",
|
||||
envVarValue: "",
|
||||
},
|
||||
}
|
||||
expectedValuesGCPCreds := []ExpectedValue{
|
||||
{
|
||||
envIndex: 15,
|
||||
envIndex: 16,
|
||||
envVarConstant: "WAL_GS_BUCKET",
|
||||
envVarValue: "global-gs-bucket",
|
||||
},
|
||||
{
|
||||
envIndex: 16,
|
||||
envIndex: 17,
|
||||
envVarConstant: "WAL_BUCKET_SCOPE_SUFFIX",
|
||||
envVarValue: fmt.Sprintf("/%s", dummyUUID),
|
||||
},
|
||||
{
|
||||
envIndex: 17,
|
||||
envIndex: 18,
|
||||
envVarConstant: "WAL_BUCKET_SCOPE_PREFIX",
|
||||
envVarValue: "",
|
||||
},
|
||||
{
|
||||
envIndex: 18,
|
||||
envIndex: 19,
|
||||
envVarConstant: "GOOGLE_APPLICATION_CREDENTIALS",
|
||||
envVarValue: "some-path-to-credentials",
|
||||
},
|
||||
}
|
||||
expectedS3BucketConfigMap := []ExpectedValue{
|
||||
{
|
||||
envIndex: 17,
|
||||
envIndex: 18,
|
||||
envVarConstant: "wal_s3_bucket",
|
||||
envVarValue: "global-s3-bucket-configmap",
|
||||
},
|
||||
}
|
||||
expectedCustomS3BucketSpec := []ExpectedValue{
|
||||
{
|
||||
envIndex: 15,
|
||||
envIndex: 16,
|
||||
envVarConstant: "WAL_S3_BUCKET",
|
||||
envVarValue: "custom-s3-bucket",
|
||||
},
|
||||
}
|
||||
expectedCustomVariableSecret := []ExpectedValue{
|
||||
{
|
||||
envIndex: 16,
|
||||
envIndex: 17,
|
||||
envVarConstant: "custom_variable",
|
||||
envVarValueRef: &v1.EnvVarSource{
|
||||
SecretKeyRef: &v1.SecretKeySelector{
|
||||
@@ -649,72 +649,72 @@ func TestGenerateSpiloPodEnvVars(t *testing.T) {
|
||||
}
|
||||
expectedCustomVariableConfigMap := []ExpectedValue{
|
||||
{
|
||||
envIndex: 16,
|
||||
envIndex: 17,
|
||||
envVarConstant: "custom_variable",
|
||||
envVarValue: "configmap-test",
|
||||
},
|
||||
}
|
||||
expectedCustomVariableSpec := []ExpectedValue{
|
||||
{
|
||||
envIndex: 15,
|
||||
envIndex: 16,
|
||||
envVarConstant: "CUSTOM_VARIABLE",
|
||||
envVarValue: "spec-env-test",
|
||||
},
|
||||
}
|
||||
expectedCloneEnvSpec := []ExpectedValue{
|
||||
{
|
||||
envIndex: 16,
|
||||
envIndex: 17,
|
||||
envVarConstant: "CLONE_WALE_S3_PREFIX",
|
||||
envVarValue: "s3://another-bucket",
|
||||
},
|
||||
{
|
||||
envIndex: 19,
|
||||
envIndex: 20,
|
||||
envVarConstant: "CLONE_WAL_BUCKET_SCOPE_PREFIX",
|
||||
envVarValue: "",
|
||||
},
|
||||
{
|
||||
envIndex: 20,
|
||||
envIndex: 21,
|
||||
envVarConstant: "CLONE_AWS_ENDPOINT",
|
||||
envVarValue: "s3.eu-central-1.amazonaws.com",
|
||||
},
|
||||
}
|
||||
expectedCloneEnvSpecEnv := []ExpectedValue{
|
||||
{
|
||||
envIndex: 15,
|
||||
envIndex: 16,
|
||||
envVarConstant: "CLONE_WAL_BUCKET_SCOPE_PREFIX",
|
||||
envVarValue: "test-cluster",
|
||||
},
|
||||
{
|
||||
envIndex: 17,
|
||||
envIndex: 18,
|
||||
envVarConstant: "CLONE_WALE_S3_PREFIX",
|
||||
envVarValue: "s3://another-bucket",
|
||||
},
|
||||
{
|
||||
envIndex: 21,
|
||||
envIndex: 22,
|
||||
envVarConstant: "CLONE_AWS_ENDPOINT",
|
||||
envVarValue: "s3.eu-central-1.amazonaws.com",
|
||||
},
|
||||
}
|
||||
expectedCloneEnvConfigMap := []ExpectedValue{
|
||||
{
|
||||
envIndex: 16,
|
||||
envIndex: 17,
|
||||
envVarConstant: "CLONE_WAL_S3_BUCKET",
|
||||
envVarValue: "global-s3-bucket",
|
||||
},
|
||||
{
|
||||
envIndex: 17,
|
||||
envIndex: 18,
|
||||
envVarConstant: "CLONE_WAL_BUCKET_SCOPE_SUFFIX",
|
||||
envVarValue: fmt.Sprintf("/%s", dummyUUID),
|
||||
},
|
||||
{
|
||||
envIndex: 21,
|
||||
envIndex: 22,
|
||||
envVarConstant: "clone_aws_endpoint",
|
||||
envVarValue: "s3.eu-west-1.amazonaws.com",
|
||||
},
|
||||
}
|
||||
expectedCloneEnvSecret := []ExpectedValue{
|
||||
{
|
||||
envIndex: 21,
|
||||
envIndex: 22,
|
||||
envVarConstant: "clone_aws_access_key_id",
|
||||
envVarValueRef: &v1.EnvVarSource{
|
||||
SecretKeyRef: &v1.SecretKeySelector{
|
||||
@@ -728,12 +728,12 @@ func TestGenerateSpiloPodEnvVars(t *testing.T) {
|
||||
}
|
||||
expectedStandbyEnvSecret := []ExpectedValue{
|
||||
{
|
||||
envIndex: 15,
|
||||
envIndex: 16,
|
||||
envVarConstant: "STANDBY_WALE_GS_PREFIX",
|
||||
envVarValue: "gs://some/path/",
|
||||
},
|
||||
{
|
||||
envIndex: 20,
|
||||
envIndex: 21,
|
||||
envVarConstant: "standby_google_application_credentials",
|
||||
envVarValueRef: &v1.EnvVarSource{
|
||||
SecretKeyRef: &v1.SecretKeySelector{
|
||||
@@ -2976,6 +2976,7 @@ func getServices(serviceType v1.ServiceType, sourceRanges []string, extTrafficPo
|
||||
ExternalTrafficPolicy: v1.ServiceExternalTrafficPolicyType(extTrafficPolicy),
|
||||
LoadBalancerSourceRanges: sourceRanges,
|
||||
Ports: []v1.ServicePort{{Name: "postgresql", Port: 5432, TargetPort: intstr.IntOrString{IntVal: 5432}, NodePort: nodePort}},
|
||||
Selector: map[string]string{"spilo-role": "master", "application": "spilo", "cluster-name": clusterName},
|
||||
Type: serviceType,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -67,6 +67,10 @@ func (c *Cluster) Sync(newSpec *acidv1.Postgresql) error {
|
||||
}
|
||||
}()
|
||||
|
||||
if !c.patroniKubernetesUseConfigMaps() {
|
||||
c.logger.Warning("K8s endpoints are deprecated. Please, enable kubernetes_use_configmaps. Requires scale-in to a single primary, see v1 -> v2 migration docs!")
|
||||
}
|
||||
|
||||
if err = c.syncFinalizer(); err != nil {
|
||||
c.logger.Debugf("could not sync finalizers: %v", err)
|
||||
}
|
||||
|
||||
+4
-1
@@ -627,9 +627,12 @@ func (c *Cluster) patroniKubernetesUseConfigMaps() bool {
|
||||
if !c.patroniUsesKubernetes() {
|
||||
return false
|
||||
}
|
||||
if c.OpConfig.KubernetesUseConfigMaps == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
// otherwise, follow the operator configuration
|
||||
return c.OpConfig.KubernetesUseConfigMaps
|
||||
return *c.OpConfig.KubernetesUseConfigMaps
|
||||
}
|
||||
|
||||
// Earlier arguments take priority
|
||||
|
||||
@@ -299,7 +299,7 @@ func newInheritedAnnotationsCluster(client k8sutil.KubernetesClient) (*Cluster,
|
||||
OpConfig: config.Config{
|
||||
PatroniAPICheckInterval: &metav1.Duration{Duration: 1 * time.Second},
|
||||
PatroniAPICheckTimeout: &metav1.Duration{Duration: 5 * time.Second},
|
||||
KubernetesUseConfigMaps: true,
|
||||
KubernetesUseConfigMaps: util.True(),
|
||||
ConnectionPooler: config.ConnectionPooler{
|
||||
ConnectionPoolerDefaultCPURequest: "100m",
|
||||
ConnectionPoolerDefaultCPULimit: "100m",
|
||||
@@ -388,7 +388,7 @@ func createPatroniResources(cluster *Cluster) error {
|
||||
Labels: cluster.labelsSet(false),
|
||||
}
|
||||
|
||||
if cluster.OpConfig.KubernetesUseConfigMaps {
|
||||
if cluster.OpConfig.KubernetesUseConfigMaps != nil && *cluster.OpConfig.KubernetesUseConfigMaps {
|
||||
configMap := v1.ConfigMap{
|
||||
ObjectMeta: metadata,
|
||||
}
|
||||
@@ -598,7 +598,7 @@ func TestInheritedAnnotations(t *testing.T) {
|
||||
// 3. Change from ConfigMaps to Endpoints
|
||||
err = cluster.deletePatroniResources()
|
||||
assert.NoError(t, err)
|
||||
cluster.OpConfig.KubernetesUseConfigMaps = false
|
||||
cluster.OpConfig.KubernetesUseConfigMaps = util.False()
|
||||
err = createPatroniResources(cluster)
|
||||
assert.NoError(t, err)
|
||||
err = cluster.Sync(newSpec.DeepCopy())
|
||||
|
||||
@@ -35,7 +35,7 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur
|
||||
result.EnableSpiloWalPathCompat = fromCRD.EnableSpiloWalPathCompat
|
||||
result.EnableTeamIdClusternamePrefix = fromCRD.EnableTeamIdClusternamePrefix
|
||||
result.EtcdHost = fromCRD.EtcdHost
|
||||
result.KubernetesUseConfigMaps = fromCRD.KubernetesUseConfigMaps
|
||||
result.KubernetesUseConfigMaps = util.CoalesceBool(fromCRD.KubernetesUseConfigMaps, util.True())
|
||||
result.DockerImage = util.Coalesce(fromCRD.DockerImage, "ghcr.io/zalando/spilo-18:4.1-p1")
|
||||
result.Workers = util.CoalesceUInt32(fromCRD.Workers, 8)
|
||||
result.MinInstances = fromCRD.MinInstances
|
||||
|
||||
@@ -177,7 +177,7 @@ type Config struct {
|
||||
ConnectionPooler
|
||||
|
||||
WatchedNamespace string `name:"watched_namespace"` // special values: "*" means 'watch all namespaces', the empty string "" means 'watch a namespace where operator is deployed to'
|
||||
KubernetesUseConfigMaps bool `name:"kubernetes_use_configmaps" default:"false"`
|
||||
KubernetesUseConfigMaps *bool `name:"kubernetes_use_configmaps" default:"true"`
|
||||
EtcdHost string `name:"etcd_host" default:""` // special values: the empty string "" means Patroni will use K8s as a DCS
|
||||
EnableMaintenanceWindows *bool `name:"enable_maintenance_windows" default:"true"`
|
||||
MaintenanceWindows []string `name:"maintenance_windows"`
|
||||
|
||||
Reference in New Issue
Block a user