use old LB DNS format when teamId prefix is disabled (#2011)
* use old LB DNS format when teamId prefix is disabled * support both old and new format in external-dns * switch dns template from team to namespace
This commit is contained in:
parent
21d00e2ed7
commit
89375186b3
|
|
@ -424,10 +424,10 @@ spec:
|
||||||
default: "Cluster"
|
default: "Cluster"
|
||||||
master_dns_name_format:
|
master_dns_name_format:
|
||||||
type: string
|
type: string
|
||||||
default: "{cluster}.{team}.{hostedzone}"
|
default: "{cluster}.{namespace}.{hostedzone}"
|
||||||
replica_dns_name_format:
|
replica_dns_name_format:
|
||||||
type: string
|
type: string
|
||||||
default: "{cluster}-repl.{team}.{hostedzone}"
|
default: "{cluster}-repl.{namespace}.{hostedzone}"
|
||||||
aws_or_gcp:
|
aws_or_gcp:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
|
|
||||||
|
|
@ -269,9 +269,9 @@ configLoadBalancer:
|
||||||
# define external traffic policy for the load balancer
|
# define external traffic policy for the load balancer
|
||||||
external_traffic_policy: "Cluster"
|
external_traffic_policy: "Cluster"
|
||||||
# defines the DNS name string template for the master load balancer cluster
|
# defines the DNS name string template for the master load balancer cluster
|
||||||
master_dns_name_format: "{cluster}.{team}.{hostedzone}"
|
master_dns_name_format: "{cluster}.{namespace}.{hostedzone}"
|
||||||
# defines the DNS name string template for the replica load balancer cluster
|
# defines the DNS name string template for the replica load balancer cluster
|
||||||
replica_dns_name_format: "{cluster}-repl.{team}.{hostedzone}"
|
replica_dns_name_format: "{cluster}-repl.{namespace}.{hostedzone}"
|
||||||
|
|
||||||
# options to aid debugging of the operator itself
|
# options to aid debugging of the operator itself
|
||||||
configDebug:
|
configDebug:
|
||||||
|
|
|
||||||
|
|
@ -617,15 +617,15 @@ In the CRD-based configuration they are grouped under the `load_balancer` key.
|
||||||
|
|
||||||
* **master_dns_name_format** defines the DNS name string template for the
|
* **master_dns_name_format** defines the DNS name string template for the
|
||||||
master load balancer cluster. The default is
|
master load balancer cluster. The default is
|
||||||
`{cluster}.{team}.{hostedzone}`, where `{cluster}` is replaced by the cluster
|
`{cluster}.{namespace}.{hostedzone}`, where `{cluster}` is replaced by the cluster
|
||||||
name, `{team}` is replaced with the team name and `{hostedzone}` is replaced
|
name, `{namespace}` is replaced with the namespace and `{hostedzone}` is replaced
|
||||||
with the hosted zone (the value of the `db_hosted_zone` parameter). No other
|
with the hosted zone (the value of the `db_hosted_zone` parameter). No other
|
||||||
placeholders are allowed.
|
placeholders are allowed.
|
||||||
|
|
||||||
* **replica_dns_name_format** defines the DNS name string template for the
|
* **replica_dns_name_format** defines the DNS name string template for the
|
||||||
replica load balancer cluster. The default is
|
replica load balancer cluster. The default is
|
||||||
`{cluster}-repl.{team}.{hostedzone}`, where `{cluster}` is replaced by the
|
`{cluster}-repl.{namespace}.{hostedzone}`, where `{cluster}` is replaced by the
|
||||||
cluster name, `{team}` is replaced with the team name and `{hostedzone}` is
|
cluster name, `{namespace}` is replaced with the namespace and `{hostedzone}` is
|
||||||
replaced with the hosted zone (the value of the `db_hosted_zone` parameter).
|
replaced with the hosted zone (the value of the `db_hosted_zone` parameter).
|
||||||
No other placeholders are allowed.
|
No other placeholders are allowed.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,7 @@ specified explicitly.
|
||||||
|
|
||||||
The operator automatically generates a password for each manifest role and
|
The operator automatically generates a password for each manifest role and
|
||||||
places it in the secret named
|
places it in the secret named
|
||||||
`{username}.{team}-{clustername}.credentials.postgresql.acid.zalan.do` in the
|
`{username}.{clustername}.credentials.postgresql.acid.zalan.do` in the
|
||||||
same namespace as the cluster. This way, the application running in the
|
same namespace as the cluster. This way, the application running in the
|
||||||
K8s cluster and connecting to Postgres can obtain the password right from the
|
K8s cluster and connecting to Postgres can obtain the password right from the
|
||||||
secret, without ever sharing it outside of the cluster.
|
secret, without ever sharing it outside of the cluster.
|
||||||
|
|
@ -182,7 +182,7 @@ be in the form of `namespace.username`.
|
||||||
|
|
||||||
For such usernames, the secret is created in the given namespace and its name is
|
For such usernames, the secret is created in the given namespace and its name is
|
||||||
of the following form,
|
of the following form,
|
||||||
`{namespace}.{username}.{team}-{clustername}.credentials.postgresql.acid.zalan.do`
|
`{namespace}.{username}.{clustername}.credentials.postgresql.acid.zalan.do`
|
||||||
|
|
||||||
### Infrastructure roles
|
### Infrastructure roles
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ data:
|
||||||
logical_backup_schedule: "30 00 * * *"
|
logical_backup_schedule: "30 00 * * *"
|
||||||
major_version_upgrade_mode: "manual"
|
major_version_upgrade_mode: "manual"
|
||||||
# major_version_upgrade_team_allow_list: ""
|
# major_version_upgrade_team_allow_list: ""
|
||||||
master_dns_name_format: "{cluster}.{team}.{hostedzone}"
|
master_dns_name_format: "{cluster}.{namespace}.{hostedzone}"
|
||||||
# master_pod_move_timeout: 20m
|
# master_pod_move_timeout: 20m
|
||||||
# max_instances: "-1"
|
# max_instances: "-1"
|
||||||
# min_instances: "-1"
|
# min_instances: "-1"
|
||||||
|
|
@ -124,7 +124,7 @@ data:
|
||||||
ready_wait_interval: 3s
|
ready_wait_interval: 3s
|
||||||
ready_wait_timeout: 30s
|
ready_wait_timeout: 30s
|
||||||
repair_period: 5m
|
repair_period: 5m
|
||||||
replica_dns_name_format: "{cluster}-repl.{team}.{hostedzone}"
|
replica_dns_name_format: "{cluster}-repl.{namespace}.{hostedzone}"
|
||||||
replication_username: standby
|
replication_username: standby
|
||||||
resource_check_interval: 3s
|
resource_check_interval: 3s
|
||||||
resource_check_timeout: 10m
|
resource_check_timeout: 10m
|
||||||
|
|
|
||||||
|
|
@ -422,10 +422,10 @@ spec:
|
||||||
default: "Cluster"
|
default: "Cluster"
|
||||||
master_dns_name_format:
|
master_dns_name_format:
|
||||||
type: string
|
type: string
|
||||||
default: "{cluster}.{team}.{hostedzone}"
|
default: "{cluster}.{namespace}.{hostedzone}"
|
||||||
replica_dns_name_format:
|
replica_dns_name_format:
|
||||||
type: string
|
type: string
|
||||||
default: "{cluster}-repl.{team}.{hostedzone}"
|
default: "{cluster}-repl.{namespace}.{hostedzone}"
|
||||||
aws_or_gcp:
|
aws_or_gcp:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
|
|
||||||
|
|
@ -133,8 +133,8 @@ configuration:
|
||||||
enable_replica_load_balancer: false
|
enable_replica_load_balancer: false
|
||||||
enable_replica_pooler_load_balancer: false
|
enable_replica_pooler_load_balancer: false
|
||||||
external_traffic_policy: "Cluster"
|
external_traffic_policy: "Cluster"
|
||||||
master_dns_name_format: "{cluster}.{team}.{hostedzone}"
|
master_dns_name_format: "{cluster}.{namespace}.{hostedzone}"
|
||||||
replica_dns_name_format: "{cluster}-repl.{team}.{hostedzone}"
|
replica_dns_name_format: "{cluster}-repl.{namespace}.{hostedzone}"
|
||||||
aws_or_gcp:
|
aws_or_gcp:
|
||||||
# additional_secret_mount: "some-secret-name"
|
# additional_secret_mount: "some-secret-name"
|
||||||
# additional_secret_mount_path: "/some/dir"
|
# additional_secret_mount_path: "/some/dir"
|
||||||
|
|
|
||||||
|
|
@ -450,6 +450,7 @@ func TestServiceAnnotations(t *testing.T) {
|
||||||
enableMasterLoadBalancerOC bool
|
enableMasterLoadBalancerOC bool
|
||||||
enableReplicaLoadBalancerSpec *bool
|
enableReplicaLoadBalancerSpec *bool
|
||||||
enableReplicaLoadBalancerOC bool
|
enableReplicaLoadBalancerOC bool
|
||||||
|
enableTeamIdClusterPrefix bool
|
||||||
operatorAnnotations map[string]string
|
operatorAnnotations map[string]string
|
||||||
clusterAnnotations map[string]string
|
clusterAnnotations map[string]string
|
||||||
expect map[string]string
|
expect map[string]string
|
||||||
|
|
@ -460,6 +461,7 @@ func TestServiceAnnotations(t *testing.T) {
|
||||||
role: "master",
|
role: "master",
|
||||||
enableMasterLoadBalancerSpec: &disabled,
|
enableMasterLoadBalancerSpec: &disabled,
|
||||||
enableMasterLoadBalancerOC: false,
|
enableMasterLoadBalancerOC: false,
|
||||||
|
enableTeamIdClusterPrefix: false,
|
||||||
operatorAnnotations: make(map[string]string),
|
operatorAnnotations: make(map[string]string),
|
||||||
clusterAnnotations: make(map[string]string),
|
clusterAnnotations: make(map[string]string),
|
||||||
expect: make(map[string]string),
|
expect: make(map[string]string),
|
||||||
|
|
@ -469,10 +471,11 @@ func TestServiceAnnotations(t *testing.T) {
|
||||||
role: "master",
|
role: "master",
|
||||||
enableMasterLoadBalancerSpec: &enabled,
|
enableMasterLoadBalancerSpec: &enabled,
|
||||||
enableMasterLoadBalancerOC: false,
|
enableMasterLoadBalancerOC: false,
|
||||||
|
enableTeamIdClusterPrefix: false,
|
||||||
operatorAnnotations: make(map[string]string),
|
operatorAnnotations: make(map[string]string),
|
||||||
clusterAnnotations: make(map[string]string),
|
clusterAnnotations: make(map[string]string),
|
||||||
expect: map[string]string{
|
expect: map[string]string{
|
||||||
"external-dns.alpha.kubernetes.io/hostname": "test.acid.db.example.com",
|
"external-dns.alpha.kubernetes.io/hostname": "acid-test.test.db.example.com,test.acid.db.example.com",
|
||||||
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "3600",
|
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "3600",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -481,6 +484,7 @@ func TestServiceAnnotations(t *testing.T) {
|
||||||
role: "master",
|
role: "master",
|
||||||
enableMasterLoadBalancerSpec: &disabled,
|
enableMasterLoadBalancerSpec: &disabled,
|
||||||
enableMasterLoadBalancerOC: true,
|
enableMasterLoadBalancerOC: true,
|
||||||
|
enableTeamIdClusterPrefix: false,
|
||||||
operatorAnnotations: make(map[string]string),
|
operatorAnnotations: make(map[string]string),
|
||||||
clusterAnnotations: make(map[string]string),
|
clusterAnnotations: make(map[string]string),
|
||||||
expect: make(map[string]string),
|
expect: make(map[string]string),
|
||||||
|
|
@ -489,10 +493,11 @@ func TestServiceAnnotations(t *testing.T) {
|
||||||
about: "Master with no annotations and EnableMasterLoadBalancer defined only on operator config",
|
about: "Master with no annotations and EnableMasterLoadBalancer defined only on operator config",
|
||||||
role: "master",
|
role: "master",
|
||||||
enableMasterLoadBalancerOC: true,
|
enableMasterLoadBalancerOC: true,
|
||||||
|
enableTeamIdClusterPrefix: false,
|
||||||
operatorAnnotations: make(map[string]string),
|
operatorAnnotations: make(map[string]string),
|
||||||
clusterAnnotations: make(map[string]string),
|
clusterAnnotations: make(map[string]string),
|
||||||
expect: map[string]string{
|
expect: map[string]string{
|
||||||
"external-dns.alpha.kubernetes.io/hostname": "test.acid.db.example.com",
|
"external-dns.alpha.kubernetes.io/hostname": "acid-test.test.db.example.com,test.acid.db.example.com",
|
||||||
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "3600",
|
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "3600",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -500,10 +505,11 @@ func TestServiceAnnotations(t *testing.T) {
|
||||||
about: "Master with cluster annotations and load balancer enabled",
|
about: "Master with cluster annotations and load balancer enabled",
|
||||||
role: "master",
|
role: "master",
|
||||||
enableMasterLoadBalancerOC: true,
|
enableMasterLoadBalancerOC: true,
|
||||||
|
enableTeamIdClusterPrefix: false,
|
||||||
operatorAnnotations: make(map[string]string),
|
operatorAnnotations: make(map[string]string),
|
||||||
clusterAnnotations: map[string]string{"foo": "bar"},
|
clusterAnnotations: map[string]string{"foo": "bar"},
|
||||||
expect: map[string]string{
|
expect: map[string]string{
|
||||||
"external-dns.alpha.kubernetes.io/hostname": "test.acid.db.example.com",
|
"external-dns.alpha.kubernetes.io/hostname": "acid-test.test.db.example.com,test.acid.db.example.com",
|
||||||
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "3600",
|
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "3600",
|
||||||
"foo": "bar",
|
"foo": "bar",
|
||||||
},
|
},
|
||||||
|
|
@ -513,6 +519,7 @@ func TestServiceAnnotations(t *testing.T) {
|
||||||
role: "master",
|
role: "master",
|
||||||
enableMasterLoadBalancerSpec: &disabled,
|
enableMasterLoadBalancerSpec: &disabled,
|
||||||
enableMasterLoadBalancerOC: true,
|
enableMasterLoadBalancerOC: true,
|
||||||
|
enableTeamIdClusterPrefix: false,
|
||||||
operatorAnnotations: make(map[string]string),
|
operatorAnnotations: make(map[string]string),
|
||||||
clusterAnnotations: map[string]string{"foo": "bar"},
|
clusterAnnotations: map[string]string{"foo": "bar"},
|
||||||
expect: map[string]string{"foo": "bar"},
|
expect: map[string]string{"foo": "bar"},
|
||||||
|
|
@ -521,10 +528,11 @@ func TestServiceAnnotations(t *testing.T) {
|
||||||
about: "Master with operator annotations and load balancer enabled",
|
about: "Master with operator annotations and load balancer enabled",
|
||||||
role: "master",
|
role: "master",
|
||||||
enableMasterLoadBalancerOC: true,
|
enableMasterLoadBalancerOC: true,
|
||||||
|
enableTeamIdClusterPrefix: false,
|
||||||
operatorAnnotations: map[string]string{"foo": "bar"},
|
operatorAnnotations: map[string]string{"foo": "bar"},
|
||||||
clusterAnnotations: make(map[string]string),
|
clusterAnnotations: make(map[string]string),
|
||||||
expect: map[string]string{
|
expect: map[string]string{
|
||||||
"external-dns.alpha.kubernetes.io/hostname": "test.acid.db.example.com",
|
"external-dns.alpha.kubernetes.io/hostname": "acid-test.test.db.example.com,test.acid.db.example.com",
|
||||||
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "3600",
|
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "3600",
|
||||||
"foo": "bar",
|
"foo": "bar",
|
||||||
},
|
},
|
||||||
|
|
@ -533,12 +541,13 @@ func TestServiceAnnotations(t *testing.T) {
|
||||||
about: "Master with operator annotations override default annotations",
|
about: "Master with operator annotations override default annotations",
|
||||||
role: "master",
|
role: "master",
|
||||||
enableMasterLoadBalancerOC: true,
|
enableMasterLoadBalancerOC: true,
|
||||||
|
enableTeamIdClusterPrefix: false,
|
||||||
operatorAnnotations: map[string]string{
|
operatorAnnotations: map[string]string{
|
||||||
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "1800",
|
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "1800",
|
||||||
},
|
},
|
||||||
clusterAnnotations: make(map[string]string),
|
clusterAnnotations: make(map[string]string),
|
||||||
expect: map[string]string{
|
expect: map[string]string{
|
||||||
"external-dns.alpha.kubernetes.io/hostname": "test.acid.db.example.com",
|
"external-dns.alpha.kubernetes.io/hostname": "acid-test.test.db.example.com,test.acid.db.example.com",
|
||||||
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "1800",
|
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "1800",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -546,12 +555,13 @@ func TestServiceAnnotations(t *testing.T) {
|
||||||
about: "Master with cluster annotations override default annotations",
|
about: "Master with cluster annotations override default annotations",
|
||||||
role: "master",
|
role: "master",
|
||||||
enableMasterLoadBalancerOC: true,
|
enableMasterLoadBalancerOC: true,
|
||||||
|
enableTeamIdClusterPrefix: false,
|
||||||
operatorAnnotations: make(map[string]string),
|
operatorAnnotations: make(map[string]string),
|
||||||
clusterAnnotations: map[string]string{
|
clusterAnnotations: map[string]string{
|
||||||
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "1800",
|
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "1800",
|
||||||
},
|
},
|
||||||
expect: map[string]string{
|
expect: map[string]string{
|
||||||
"external-dns.alpha.kubernetes.io/hostname": "test.acid.db.example.com",
|
"external-dns.alpha.kubernetes.io/hostname": "acid-test.test.db.example.com,test.acid.db.example.com",
|
||||||
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "1800",
|
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "1800",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -559,25 +569,25 @@ func TestServiceAnnotations(t *testing.T) {
|
||||||
about: "Master with cluster annotations do not override external-dns annotations",
|
about: "Master with cluster annotations do not override external-dns annotations",
|
||||||
role: "master",
|
role: "master",
|
||||||
enableMasterLoadBalancerOC: true,
|
enableMasterLoadBalancerOC: true,
|
||||||
|
enableTeamIdClusterPrefix: false,
|
||||||
operatorAnnotations: make(map[string]string),
|
operatorAnnotations: make(map[string]string),
|
||||||
clusterAnnotations: map[string]string{
|
clusterAnnotations: map[string]string{
|
||||||
"external-dns.alpha.kubernetes.io/hostname": "wrong.external-dns-name.example.com",
|
"external-dns.alpha.kubernetes.io/hostname": "wrong.external-dns-name.example.com",
|
||||||
},
|
},
|
||||||
expect: map[string]string{
|
expect: map[string]string{
|
||||||
"external-dns.alpha.kubernetes.io/hostname": "test.acid.db.example.com",
|
"external-dns.alpha.kubernetes.io/hostname": "acid-test.test.db.example.com,test.acid.db.example.com",
|
||||||
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "3600",
|
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "3600",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
about: "Master with operator annotations do not override external-dns annotations",
|
about: "Master with cluster name teamId prefix enabled",
|
||||||
role: "master",
|
role: "master",
|
||||||
enableMasterLoadBalancerOC: true,
|
enableMasterLoadBalancerOC: true,
|
||||||
|
enableTeamIdClusterPrefix: true,
|
||||||
clusterAnnotations: make(map[string]string),
|
clusterAnnotations: make(map[string]string),
|
||||||
operatorAnnotations: map[string]string{
|
operatorAnnotations: make(map[string]string),
|
||||||
"external-dns.alpha.kubernetes.io/hostname": "wrong.external-dns-name.example.com",
|
|
||||||
},
|
|
||||||
expect: map[string]string{
|
expect: map[string]string{
|
||||||
"external-dns.alpha.kubernetes.io/hostname": "test.acid.db.example.com",
|
"external-dns.alpha.kubernetes.io/hostname": "test.test.db.example.com",
|
||||||
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "3600",
|
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "3600",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -587,6 +597,7 @@ func TestServiceAnnotations(t *testing.T) {
|
||||||
role: "replica",
|
role: "replica",
|
||||||
enableReplicaLoadBalancerSpec: &disabled,
|
enableReplicaLoadBalancerSpec: &disabled,
|
||||||
enableReplicaLoadBalancerOC: false,
|
enableReplicaLoadBalancerOC: false,
|
||||||
|
enableTeamIdClusterPrefix: false,
|
||||||
operatorAnnotations: make(map[string]string),
|
operatorAnnotations: make(map[string]string),
|
||||||
clusterAnnotations: make(map[string]string),
|
clusterAnnotations: make(map[string]string),
|
||||||
expect: make(map[string]string),
|
expect: make(map[string]string),
|
||||||
|
|
@ -596,10 +607,11 @@ func TestServiceAnnotations(t *testing.T) {
|
||||||
role: "replica",
|
role: "replica",
|
||||||
enableReplicaLoadBalancerSpec: &enabled,
|
enableReplicaLoadBalancerSpec: &enabled,
|
||||||
enableReplicaLoadBalancerOC: false,
|
enableReplicaLoadBalancerOC: false,
|
||||||
|
enableTeamIdClusterPrefix: false,
|
||||||
operatorAnnotations: make(map[string]string),
|
operatorAnnotations: make(map[string]string),
|
||||||
clusterAnnotations: make(map[string]string),
|
clusterAnnotations: make(map[string]string),
|
||||||
expect: map[string]string{
|
expect: map[string]string{
|
||||||
"external-dns.alpha.kubernetes.io/hostname": "test-repl.acid.db.example.com",
|
"external-dns.alpha.kubernetes.io/hostname": "acid-test-repl.test.db.example.com,test-repl.acid.db.example.com",
|
||||||
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "3600",
|
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "3600",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -608,6 +620,7 @@ func TestServiceAnnotations(t *testing.T) {
|
||||||
role: "replica",
|
role: "replica",
|
||||||
enableReplicaLoadBalancerSpec: &disabled,
|
enableReplicaLoadBalancerSpec: &disabled,
|
||||||
enableReplicaLoadBalancerOC: true,
|
enableReplicaLoadBalancerOC: true,
|
||||||
|
enableTeamIdClusterPrefix: false,
|
||||||
operatorAnnotations: make(map[string]string),
|
operatorAnnotations: make(map[string]string),
|
||||||
clusterAnnotations: make(map[string]string),
|
clusterAnnotations: make(map[string]string),
|
||||||
expect: make(map[string]string),
|
expect: make(map[string]string),
|
||||||
|
|
@ -616,10 +629,11 @@ func TestServiceAnnotations(t *testing.T) {
|
||||||
about: "Replica with no annotations and EnableReplicaLoadBalancer defined only on operator config",
|
about: "Replica with no annotations and EnableReplicaLoadBalancer defined only on operator config",
|
||||||
role: "replica",
|
role: "replica",
|
||||||
enableReplicaLoadBalancerOC: true,
|
enableReplicaLoadBalancerOC: true,
|
||||||
|
enableTeamIdClusterPrefix: false,
|
||||||
operatorAnnotations: make(map[string]string),
|
operatorAnnotations: make(map[string]string),
|
||||||
clusterAnnotations: make(map[string]string),
|
clusterAnnotations: make(map[string]string),
|
||||||
expect: map[string]string{
|
expect: map[string]string{
|
||||||
"external-dns.alpha.kubernetes.io/hostname": "test-repl.acid.db.example.com",
|
"external-dns.alpha.kubernetes.io/hostname": "acid-test-repl.test.db.example.com,test-repl.acid.db.example.com",
|
||||||
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "3600",
|
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "3600",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -627,10 +641,11 @@ func TestServiceAnnotations(t *testing.T) {
|
||||||
about: "Replica with cluster annotations and load balancer enabled",
|
about: "Replica with cluster annotations and load balancer enabled",
|
||||||
role: "replica",
|
role: "replica",
|
||||||
enableReplicaLoadBalancerOC: true,
|
enableReplicaLoadBalancerOC: true,
|
||||||
|
enableTeamIdClusterPrefix: false,
|
||||||
operatorAnnotations: make(map[string]string),
|
operatorAnnotations: make(map[string]string),
|
||||||
clusterAnnotations: map[string]string{"foo": "bar"},
|
clusterAnnotations: map[string]string{"foo": "bar"},
|
||||||
expect: map[string]string{
|
expect: map[string]string{
|
||||||
"external-dns.alpha.kubernetes.io/hostname": "test-repl.acid.db.example.com",
|
"external-dns.alpha.kubernetes.io/hostname": "acid-test-repl.test.db.example.com,test-repl.acid.db.example.com",
|
||||||
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "3600",
|
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "3600",
|
||||||
"foo": "bar",
|
"foo": "bar",
|
||||||
},
|
},
|
||||||
|
|
@ -640,6 +655,7 @@ func TestServiceAnnotations(t *testing.T) {
|
||||||
role: "replica",
|
role: "replica",
|
||||||
enableReplicaLoadBalancerSpec: &disabled,
|
enableReplicaLoadBalancerSpec: &disabled,
|
||||||
enableReplicaLoadBalancerOC: true,
|
enableReplicaLoadBalancerOC: true,
|
||||||
|
enableTeamIdClusterPrefix: false,
|
||||||
operatorAnnotations: make(map[string]string),
|
operatorAnnotations: make(map[string]string),
|
||||||
clusterAnnotations: map[string]string{"foo": "bar"},
|
clusterAnnotations: map[string]string{"foo": "bar"},
|
||||||
expect: map[string]string{"foo": "bar"},
|
expect: map[string]string{"foo": "bar"},
|
||||||
|
|
@ -648,10 +664,11 @@ func TestServiceAnnotations(t *testing.T) {
|
||||||
about: "Replica with operator annotations and load balancer enabled",
|
about: "Replica with operator annotations and load balancer enabled",
|
||||||
role: "replica",
|
role: "replica",
|
||||||
enableReplicaLoadBalancerOC: true,
|
enableReplicaLoadBalancerOC: true,
|
||||||
|
enableTeamIdClusterPrefix: false,
|
||||||
operatorAnnotations: map[string]string{"foo": "bar"},
|
operatorAnnotations: map[string]string{"foo": "bar"},
|
||||||
clusterAnnotations: make(map[string]string),
|
clusterAnnotations: make(map[string]string),
|
||||||
expect: map[string]string{
|
expect: map[string]string{
|
||||||
"external-dns.alpha.kubernetes.io/hostname": "test-repl.acid.db.example.com",
|
"external-dns.alpha.kubernetes.io/hostname": "acid-test-repl.test.db.example.com,test-repl.acid.db.example.com",
|
||||||
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "3600",
|
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "3600",
|
||||||
"foo": "bar",
|
"foo": "bar",
|
||||||
},
|
},
|
||||||
|
|
@ -660,12 +677,13 @@ func TestServiceAnnotations(t *testing.T) {
|
||||||
about: "Replica with operator annotations override default annotations",
|
about: "Replica with operator annotations override default annotations",
|
||||||
role: "replica",
|
role: "replica",
|
||||||
enableReplicaLoadBalancerOC: true,
|
enableReplicaLoadBalancerOC: true,
|
||||||
|
enableTeamIdClusterPrefix: false,
|
||||||
operatorAnnotations: map[string]string{
|
operatorAnnotations: map[string]string{
|
||||||
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "1800",
|
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "1800",
|
||||||
},
|
},
|
||||||
clusterAnnotations: make(map[string]string),
|
clusterAnnotations: make(map[string]string),
|
||||||
expect: map[string]string{
|
expect: map[string]string{
|
||||||
"external-dns.alpha.kubernetes.io/hostname": "test-repl.acid.db.example.com",
|
"external-dns.alpha.kubernetes.io/hostname": "acid-test-repl.test.db.example.com,test-repl.acid.db.example.com",
|
||||||
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "1800",
|
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "1800",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -673,12 +691,13 @@ func TestServiceAnnotations(t *testing.T) {
|
||||||
about: "Replica with cluster annotations override default annotations",
|
about: "Replica with cluster annotations override default annotations",
|
||||||
role: "replica",
|
role: "replica",
|
||||||
enableReplicaLoadBalancerOC: true,
|
enableReplicaLoadBalancerOC: true,
|
||||||
|
enableTeamIdClusterPrefix: false,
|
||||||
operatorAnnotations: make(map[string]string),
|
operatorAnnotations: make(map[string]string),
|
||||||
clusterAnnotations: map[string]string{
|
clusterAnnotations: map[string]string{
|
||||||
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "1800",
|
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "1800",
|
||||||
},
|
},
|
||||||
expect: map[string]string{
|
expect: map[string]string{
|
||||||
"external-dns.alpha.kubernetes.io/hostname": "test-repl.acid.db.example.com",
|
"external-dns.alpha.kubernetes.io/hostname": "acid-test-repl.test.db.example.com,test-repl.acid.db.example.com",
|
||||||
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "1800",
|
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "1800",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -686,25 +705,25 @@ func TestServiceAnnotations(t *testing.T) {
|
||||||
about: "Replica with cluster annotations do not override external-dns annotations",
|
about: "Replica with cluster annotations do not override external-dns annotations",
|
||||||
role: "replica",
|
role: "replica",
|
||||||
enableReplicaLoadBalancerOC: true,
|
enableReplicaLoadBalancerOC: true,
|
||||||
|
enableTeamIdClusterPrefix: false,
|
||||||
operatorAnnotations: make(map[string]string),
|
operatorAnnotations: make(map[string]string),
|
||||||
clusterAnnotations: map[string]string{
|
clusterAnnotations: map[string]string{
|
||||||
"external-dns.alpha.kubernetes.io/hostname": "wrong.external-dns-name.example.com",
|
"external-dns.alpha.kubernetes.io/hostname": "wrong.external-dns-name.example.com",
|
||||||
},
|
},
|
||||||
expect: map[string]string{
|
expect: map[string]string{
|
||||||
"external-dns.alpha.kubernetes.io/hostname": "test-repl.acid.db.example.com",
|
"external-dns.alpha.kubernetes.io/hostname": "acid-test-repl.test.db.example.com,test-repl.acid.db.example.com",
|
||||||
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "3600",
|
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "3600",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
about: "Replica with operator annotations do not override external-dns annotations",
|
about: "Replica with cluster name teamId prefix enabled",
|
||||||
role: "replica",
|
role: "replica",
|
||||||
enableReplicaLoadBalancerOC: true,
|
enableReplicaLoadBalancerOC: true,
|
||||||
|
enableTeamIdClusterPrefix: true,
|
||||||
clusterAnnotations: make(map[string]string),
|
clusterAnnotations: make(map[string]string),
|
||||||
operatorAnnotations: map[string]string{
|
operatorAnnotations: make(map[string]string),
|
||||||
"external-dns.alpha.kubernetes.io/hostname": "wrong.external-dns-name.example.com",
|
|
||||||
},
|
|
||||||
expect: map[string]string{
|
expect: map[string]string{
|
||||||
"external-dns.alpha.kubernetes.io/hostname": "test-repl.acid.db.example.com",
|
"external-dns.alpha.kubernetes.io/hostname": "test-repl.test.db.example.com",
|
||||||
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "3600",
|
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout": "3600",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -713,6 +732,7 @@ func TestServiceAnnotations(t *testing.T) {
|
||||||
about: "cluster annotations append to operator annotations",
|
about: "cluster annotations append to operator annotations",
|
||||||
role: "replica",
|
role: "replica",
|
||||||
enableReplicaLoadBalancerOC: false,
|
enableReplicaLoadBalancerOC: false,
|
||||||
|
enableTeamIdClusterPrefix: false,
|
||||||
operatorAnnotations: map[string]string{"foo": "bar"},
|
operatorAnnotations: map[string]string{"foo": "bar"},
|
||||||
clusterAnnotations: map[string]string{"post": "gres"},
|
clusterAnnotations: map[string]string{"post": "gres"},
|
||||||
expect: map[string]string{"foo": "bar", "post": "gres"},
|
expect: map[string]string{"foo": "bar", "post": "gres"},
|
||||||
|
|
@ -721,6 +741,7 @@ func TestServiceAnnotations(t *testing.T) {
|
||||||
about: "cluster annotations override operator annotations",
|
about: "cluster annotations override operator annotations",
|
||||||
role: "replica",
|
role: "replica",
|
||||||
enableReplicaLoadBalancerOC: false,
|
enableReplicaLoadBalancerOC: false,
|
||||||
|
enableTeamIdClusterPrefix: false,
|
||||||
operatorAnnotations: map[string]string{"foo": "bar", "post": "gres"},
|
operatorAnnotations: map[string]string{"foo": "bar", "post": "gres"},
|
||||||
clusterAnnotations: map[string]string{"post": "greSQL"},
|
clusterAnnotations: map[string]string{"post": "greSQL"},
|
||||||
expect: map[string]string{"foo": "bar", "post": "greSQL"},
|
expect: map[string]string{"foo": "bar", "post": "greSQL"},
|
||||||
|
|
@ -729,14 +750,20 @@ func TestServiceAnnotations(t *testing.T) {
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.about, func(t *testing.T) {
|
t.Run(tt.about, func(t *testing.T) {
|
||||||
|
cl.OpConfig.EnableTeamIdClusternamePrefix = tt.enableTeamIdClusterPrefix
|
||||||
|
if tt.enableTeamIdClusterPrefix {
|
||||||
|
cl.Postgresql.Spec.ClusterName = "test"
|
||||||
|
} else {
|
||||||
|
cl.Postgresql.Spec.ClusterName = "acid-test"
|
||||||
|
}
|
||||||
|
|
||||||
cl.OpConfig.CustomServiceAnnotations = tt.operatorAnnotations
|
cl.OpConfig.CustomServiceAnnotations = tt.operatorAnnotations
|
||||||
cl.OpConfig.EnableMasterLoadBalancer = tt.enableMasterLoadBalancerOC
|
cl.OpConfig.EnableMasterLoadBalancer = tt.enableMasterLoadBalancerOC
|
||||||
cl.OpConfig.EnableReplicaLoadBalancer = tt.enableReplicaLoadBalancerOC
|
cl.OpConfig.EnableReplicaLoadBalancer = tt.enableReplicaLoadBalancerOC
|
||||||
cl.OpConfig.MasterDNSNameFormat = "{cluster}.{team}.{hostedzone}"
|
cl.OpConfig.MasterDNSNameFormat = "{cluster}.{namespace}.{hostedzone}"
|
||||||
cl.OpConfig.ReplicaDNSNameFormat = "{cluster}-repl.{team}.{hostedzone}"
|
cl.OpConfig.ReplicaDNSNameFormat = "{cluster}-repl.{namespace}.{hostedzone}"
|
||||||
cl.OpConfig.DbHostedZone = "db.example.com"
|
cl.OpConfig.DbHostedZone = "db.example.com"
|
||||||
|
|
||||||
cl.Postgresql.Spec.ClusterName = "test"
|
|
||||||
cl.Postgresql.Spec.TeamID = "acid"
|
cl.Postgresql.Spec.TeamID = "acid"
|
||||||
cl.Postgresql.Spec.ServiceAnnotations = tt.clusterAnnotations
|
cl.Postgresql.Spec.ServiceAnnotations = tt.clusterAnnotations
|
||||||
cl.Postgresql.Spec.EnableMasterLoadBalancer = tt.enableMasterLoadBalancerSpec
|
cl.Postgresql.Spec.EnableMasterLoadBalancer = tt.enableMasterLoadBalancerSpec
|
||||||
|
|
|
||||||
|
|
@ -1814,12 +1814,7 @@ func (c *Cluster) generateServiceAnnotations(role PostgresRole, spec *acidv1.Pos
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.shouldCreateLoadBalancerForService(role, spec) {
|
if c.shouldCreateLoadBalancerForService(role, spec) {
|
||||||
var dnsName string
|
dnsName := c.dnsName(role)
|
||||||
if role == Master {
|
|
||||||
dnsName = c.masterDNSName()
|
|
||||||
} else {
|
|
||||||
dnsName = c.replicaDNSName()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Just set ELB Timeout annotation with default value, if it does not
|
// Just set ELB Timeout annotation with default value, if it does not
|
||||||
// have a cutom value
|
// have a cutom value
|
||||||
|
|
|
||||||
|
|
@ -505,20 +505,50 @@ func (c *Cluster) roleLabelsSet(shouldAddExtraLabels bool, role PostgresRole) la
|
||||||
return lbls
|
return lbls
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Cluster) dnsName(role PostgresRole) string {
|
||||||
|
var dnsString string
|
||||||
|
if role == Master {
|
||||||
|
dnsString = c.masterDNSName()
|
||||||
|
} else {
|
||||||
|
dnsString = c.replicaDNSName()
|
||||||
|
}
|
||||||
|
|
||||||
|
// when cluster name starts with teamId prefix create an extra DNS entry
|
||||||
|
// to support the old format when prefix contraint was enabled (but is disabled now)
|
||||||
|
if !c.OpConfig.EnableTeamIdClusternamePrefix {
|
||||||
|
clusterNameWithoutTeamPrefix, _ := acidv1.ExtractClusterName(c.Name, c.Spec.TeamID)
|
||||||
|
if clusterNameWithoutTeamPrefix != "" {
|
||||||
|
if role == Replica {
|
||||||
|
clusterNameWithoutTeamPrefix = fmt.Sprintf("%s-repl", clusterNameWithoutTeamPrefix)
|
||||||
|
}
|
||||||
|
dnsString = fmt.Sprintf("%s,%s", dnsString, c.oldDNSFormat(clusterNameWithoutTeamPrefix))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return dnsString
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Cluster) masterDNSName() string {
|
func (c *Cluster) masterDNSName() string {
|
||||||
return strings.ToLower(c.OpConfig.MasterDNSNameFormat.Format(
|
return strings.ToLower(c.OpConfig.MasterDNSNameFormat.Format(
|
||||||
"cluster", c.Spec.ClusterName,
|
"cluster", c.Spec.ClusterName,
|
||||||
"team", c.teamName(),
|
"namespace", c.Namespace,
|
||||||
"hostedzone", c.OpConfig.DbHostedZone))
|
"hostedzone", c.OpConfig.DbHostedZone))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cluster) replicaDNSName() string {
|
func (c *Cluster) replicaDNSName() string {
|
||||||
return strings.ToLower(c.OpConfig.ReplicaDNSNameFormat.Format(
|
return strings.ToLower(c.OpConfig.ReplicaDNSNameFormat.Format(
|
||||||
"cluster", c.Spec.ClusterName,
|
"cluster", c.Spec.ClusterName,
|
||||||
"team", c.teamName(),
|
"namespace", c.Namespace,
|
||||||
"hostedzone", c.OpConfig.DbHostedZone))
|
"hostedzone", c.OpConfig.DbHostedZone))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Cluster) oldDNSFormat(clusterName string) string {
|
||||||
|
return fmt.Sprintf("%s.%s.%s",
|
||||||
|
clusterName,
|
||||||
|
c.teamName(),
|
||||||
|
c.OpConfig.DbHostedZone)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Cluster) credentialSecretName(username string) string {
|
func (c *Cluster) credentialSecretName(username string) string {
|
||||||
return c.credentialSecretNameForCluster(username, c.Name)
|
return c.credentialSecretNameForCluster(username, c.Name)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -159,17 +159,24 @@ func (c *Controller) acquireInitialListOfClusters() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Controller) addCluster(lg *logrus.Entry, clusterName spec.NamespacedName, pgSpec *acidv1.Postgresql) (*cluster.Cluster, error) {
|
func (c *Controller) addCluster(lg *logrus.Entry, clusterName spec.NamespacedName, pgSpec *acidv1.Postgresql) (*cluster.Cluster, error) {
|
||||||
|
var (
|
||||||
|
extractedClusterName string
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
|
||||||
if c.opConfig.EnableTeamIdClusternamePrefix {
|
if c.opConfig.EnableTeamIdClusternamePrefix {
|
||||||
if _, err := acidv1.ExtractClusterName(clusterName.Name, pgSpec.Spec.TeamID); err != nil {
|
if extractedClusterName, err = acidv1.ExtractClusterName(clusterName.Name, pgSpec.Spec.TeamID); err != nil {
|
||||||
c.KubeClient.SetPostgresCRDStatus(clusterName, acidv1.ClusterStatusInvalid)
|
c.KubeClient.SetPostgresCRDStatus(clusterName, acidv1.ClusterStatusInvalid)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
extractedClusterName = clusterName.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
cl := cluster.New(c.makeClusterConfig(), c.KubeClient, *pgSpec, lg, c.eventRecorder)
|
cl := cluster.New(c.makeClusterConfig(), c.KubeClient, *pgSpec, lg, c.eventRecorder)
|
||||||
cl.Run(c.stopCh)
|
cl.Run(c.stopCh)
|
||||||
teamName := strings.ToLower(cl.Spec.TeamID)
|
teamName := strings.ToLower(cl.Spec.TeamID)
|
||||||
|
cl.ClusterName = extractedClusterName
|
||||||
|
|
||||||
defer c.clustersMu.Unlock()
|
defer c.clustersMu.Unlock()
|
||||||
c.clustersMu.Lock()
|
c.clustersMu.Lock()
|
||||||
|
|
|
||||||
|
|
@ -206,8 +206,8 @@ type Config struct {
|
||||||
StorageResizeMode string `name:"storage_resize_mode" default:"pvc"`
|
StorageResizeMode string `name:"storage_resize_mode" default:"pvc"`
|
||||||
EnableLoadBalancer *bool `name:"enable_load_balancer"` // deprecated and kept for backward compatibility
|
EnableLoadBalancer *bool `name:"enable_load_balancer"` // deprecated and kept for backward compatibility
|
||||||
ExternalTrafficPolicy string `name:"external_traffic_policy" default:"Cluster"`
|
ExternalTrafficPolicy string `name:"external_traffic_policy" default:"Cluster"`
|
||||||
MasterDNSNameFormat StringTemplate `name:"master_dns_name_format" default:"{cluster}.{team}.{hostedzone}"`
|
MasterDNSNameFormat StringTemplate `name:"master_dns_name_format" default:"{cluster}.{namespace}.{hostedzone}"`
|
||||||
ReplicaDNSNameFormat StringTemplate `name:"replica_dns_name_format" default:"{cluster}-repl.{team}.{hostedzone}"`
|
ReplicaDNSNameFormat StringTemplate `name:"replica_dns_name_format" default:"{cluster}-repl.{namespace}.{hostedzone}"`
|
||||||
PDBNameFormat StringTemplate `name:"pdb_name_format" default:"postgres-{cluster}-pdb"`
|
PDBNameFormat StringTemplate `name:"pdb_name_format" default:"postgres-{cluster}-pdb"`
|
||||||
EnablePodDisruptionBudget *bool `name:"enable_pod_disruption_budget" default:"true"`
|
EnablePodDisruptionBudget *bool `name:"enable_pod_disruption_budget" default:"true"`
|
||||||
EnableInitContainers *bool `name:"enable_init_containers" default:"true"`
|
EnableInitContainers *bool `name:"enable_init_containers" default:"true"`
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue