Skip to content

Commit 3bfd63c

Browse files
authored
Make teamId in cluster name optional (zalando#2001)
* making teamId in clustername optional * move teamId check to addCluster function
1 parent b91b69c commit 3bfd63c

File tree

17 files changed

+96
-76
lines changed

17 files changed

+96
-76
lines changed

charts/postgres-operator/crds/operatorconfigurations.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ spec:
8888
enable_spilo_wal_path_compat:
8989
type: boolean
9090
default: false
91+
enable_team_id_clustername_prefix:
92+
type: boolean
93+
default: false
9194
etcd_host:
9295
type: string
9396
default: ""

charts/postgres-operator/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ configGeneral:
3333
enable_shm_volume: true
3434
# enables backwards compatible path between Spilo 12 and Spilo 13+ images
3535
enable_spilo_wal_path_compat: false
36+
# operator will sync only clusters where name starts with teamId prefix
37+
enable_team_id_clustername_prefix: false
3638
# etcd connection string for Patroni. Empty uses K8s-native DCS.
3739
etcd_host: ""
3840
# Spilo docker image

docs/reference/cluster_manifest.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ Those parameters are grouped under the `metadata` top-level key.
5353
These parameters are grouped directly under the `spec` key in the manifest.
5454

5555
* **teamId**
56-
name of the team the cluster belongs to. Changing it after the cluster
57-
creation is not supported. Required field.
56+
name of the team the cluster belongs to. Required field.
5857

5958
* **numberOfInstances**
6059
total number of instances for a given cluster. The operator parameters

docs/reference/operator_parameters.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ Those are top-level keys, containing both leaf keys and groups.
9292
* **enable_spilo_wal_path_compat**
9393
enables backwards compatible path between Spilo 12 and Spilo 13+ images. The default is `false`.
9494

95+
* **enable_team_id_clustername_prefix**
96+
To lower the risk of name clashes between clusters of different teams you
97+
can turn on this flag and the operator will sync only clusters where the
98+
name starts with the `teamId` (from `spec`) plus `-`. Default is `false`.
99+
95100
* **etcd_host**
96101
Etcd connection string for Patroni defined as `host:port`. Not required when
97102
Patroni native Kubernetes support is used. The default is empty (use

docs/user.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,12 @@ Make sure, the `spec` section of the manifest contains at least a `teamId`, the
4545
The minimum volume size to run the `postgresql` resource on Elastic Block
4646
Storage (EBS) is `1Gi`.
4747

48-
Note, that the name of the cluster must start with the `teamId` and `-`. At
49-
Zalando we use team IDs (nicknames) to lower the chance of duplicate cluster
50-
names and colliding entities. The team ID would also be used to query an API to
51-
get all members of a team and create [database roles](#teams-api-roles) for
52-
them. Besides, the maximum cluster name length is 53 characters.
48+
Note, that when `enable_team_id_clustername_prefix` is set to `true` the name
49+
of the cluster must start with the `teamId` and `-`. At Zalando we use team IDs
50+
(nicknames) to lower chances of duplicate cluster names and colliding entities.
51+
The team ID would also be used to query an API to get all members of a team
52+
and create [database roles](#teams-api-roles) for them. Besides, the maximum
53+
cluster name length is 53 characters.
5354

5455
## Watch pods being created
5556

manifests/configmap.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ data:
5757
# enable_shm_volume: "true"
5858
# enable_sidecars: "true"
5959
enable_spilo_wal_path_compat: "true"
60+
enable_team_id_clustername_prefix: "false"
6061
enable_team_member_deprecation: "false"
6162
# enable_team_superuser: "false"
6263
enable_teams_api: "false"

manifests/operatorconfiguration.crd.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ spec:
8686
enable_spilo_wal_path_compat:
8787
type: boolean
8888
default: false
89+
enable_team_id_clustername_prefix:
90+
type: boolean
91+
default: false
8992
etcd_host:
9093
type: string
9194
default: ""

manifests/postgresql-operator-default-configuration.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ configuration:
1111
enable_pgversion_env_var: true
1212
# enable_shm_volume: true
1313
enable_spilo_wal_path_compat: false
14+
enable_team_id_clustername_prefix: false
1415
etcd_host: ""
1516
# ignore_instance_limits_annotation_key: ""
1617
# kubernetes_use_configmaps: false

pkg/apis/acid.zalan.do/v1/crds.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,9 @@ var OperatorConfigCRDResourceValidation = apiextv1.CustomResourceValidation{
11121112
"enable_spilo_wal_path_compat": {
11131113
Type: "boolean",
11141114
},
1115+
"enable_team_id_clustername_prefix": {
1116+
Type: "boolean",
1117+
},
11151118
"etcd_host": {
11161119
Type: "string",
11171120
},

pkg/apis/acid.zalan.do/v1/marshal.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,9 @@ func (p *Postgresql) UnmarshalJSON(data []byte) error {
110110
}
111111
tmp2 := Postgresql(tmp)
112112

113-
if clusterName, err := extractClusterName(tmp2.ObjectMeta.Name, tmp2.Spec.TeamID); err != nil {
114-
tmp2.Error = err.Error()
115-
tmp2.Status = PostgresStatus{PostgresClusterStatus: ClusterStatusInvalid}
116-
} else if err := validateCloneClusterDescription(tmp2.Spec.Clone); err != nil {
117-
113+
if err := validateCloneClusterDescription(tmp2.Spec.Clone); err != nil {
118114
tmp2.Error = err.Error()
119115
tmp2.Status.PostgresClusterStatus = ClusterStatusInvalid
120-
} else {
121-
tmp2.Spec.ClusterName = clusterName
122116
}
123117

124118
*p = tmp2

0 commit comments

Comments
 (0)