Skip to content

Commit 3ce0b1e

Browse files
authored
deprecate crd validation toggle and sync with manifests (zalando#1781)
* deprecate crd validation toggle and sync with manifests * fix description in pg crd manifests * change CRD creation strategy * affinity matchExpression has values * lower repair period in e2e tests
1 parent 658923d commit 3ce0b1e

File tree

17 files changed

+261
-152
lines changed

17 files changed

+261
-152
lines changed

charts/postgres-operator/crds/operatorconfigurations.yaml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ spec:
6161
configuration:
6262
type: object
6363
properties:
64+
crd_categories:
65+
type: array
66+
nullable: true
67+
items:
68+
type: string
6469
docker_image:
6570
type: string
6671
default: "registry.opensource.zalan.do/acid/spilo-14:2.1-p3"
@@ -69,6 +74,7 @@ spec:
6974
default: true
7075
enable_crd_validation:
7176
type: boolean
77+
description: deprecated
7278
default: true
7379
enable_lazy_spilo_upgrade:
7480
type: boolean
@@ -90,11 +96,13 @@ spec:
9096
default: false
9197
max_instances:
9298
type: integer
93-
minimum: -1 # -1 = disabled
99+
description: "-1 = disabled"
100+
minimum: -1
94101
default: -1
95102
min_instances:
96103
type: integer
97-
minimum: -1 # -1 = disabled
104+
description: "-1 = disabled"
105+
minimum: -1
98106
default: -1
99107
resync_period:
100108
type: string
@@ -184,12 +192,12 @@ spec:
184192
type: array
185193
items:
186194
type: string
187-
enable_init_containers:
188-
type: boolean
189-
default: true
190195
enable_cross_namespace_secret:
191196
type: boolean
192197
default: false
198+
enable_init_containers:
199+
type: boolean
200+
default: true
193201
enable_pod_antiaffinity:
194202
type: boolean
195203
default: false
@@ -410,12 +418,12 @@ spec:
410418
type: string
411419
log_s3_bucket:
412420
type: string
421+
wal_az_storage_account:
422+
type: string
413423
wal_gs_bucket:
414424
type: string
415425
wal_s3_bucket:
416426
type: string
417-
wal_az_storage_account:
418-
type: string
419427
logical_backup:
420428
type: object
421429
properties:

charts/postgres-operator/crds/postgresqls.yaml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ spec:
147147
- "transaction"
148148
numberOfInstances:
149149
type: integer
150-
minimum: 2
150+
minimum: 1
151151
resources:
152152
type: object
153153
required:
@@ -201,8 +201,9 @@ spec:
201201
type: boolean
202202
enableShmVolume:
203203
type: boolean
204-
init_containers: # deprecated
204+
init_containers:
205205
type: array
206+
description: deprecated
206207
nullable: true
207208
items:
208209
type: object
@@ -229,8 +230,8 @@ spec:
229230
items:
230231
type: object
231232
required:
232-
- weight
233233
- preference
234+
- weight
234235
properties:
235236
preference:
236237
type: object
@@ -348,8 +349,9 @@ spec:
348349
type: object
349350
additionalProperties:
350351
type: string
351-
pod_priority_class_name: # deprecated
352+
pod_priority_class_name:
352353
type: string
354+
description: deprecated
353355
podPriorityClassName:
354356
type: string
355357
postgresql:
@@ -393,8 +395,9 @@ spec:
393395
type: boolean
394396
secretNamespace:
395397
type: string
396-
replicaLoadBalancer: # deprecated
398+
replicaLoadBalancer:
397399
type: boolean
400+
description: deprecated
398401
resources:
399402
type: object
400403
required:
@@ -512,14 +515,14 @@ spec:
512515
- PreferNoSchedule
513516
tolerationSeconds:
514517
type: integer
515-
useLoadBalancer: # deprecated
518+
useLoadBalancer:
516519
type: boolean
520+
description: deprecated
517521
users:
518522
type: object
519523
additionalProperties:
520524
type: array
521525
nullable: true
522-
description: "Role flags specified here must not contradict each other"
523526
items:
524527
type: string
525528
enum:

charts/postgres-operator/values.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ enableJsonLogging: false
2222
configGeneral:
2323
# the deployment should create/update the CRDs
2424
enable_crd_registration: true
25-
# choose if deployment creates/updates CRDs with OpenAPIV3Validation
26-
enable_crd_validation: true
25+
# specify categories under which crds should be listed
26+
crd_categories:
27+
- "all"
2728
# update only the statefulsets without immediately doing the rolling update
2829
enable_lazy_spilo_upgrade: false
2930
# set the PGVERSION env var instead of providing the version via postgresql.bin_dir in SPILO_CONFIGURATION

docs/administrator.md

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,25 @@
33
Learn how to configure and manage the Postgres Operator in your Kubernetes (K8s)
44
environment.
55

6+
## CRD registration and validation
7+
8+
On startup, the operator will try to register the necessary
9+
[CustomResourceDefinitions](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/#customresourcedefinitions)
10+
`Postgresql` and `OperatorConfiguration`. The latter will only get created if
11+
the `POSTGRES_OPERATOR_CONFIGURATION_OBJECT` [environment variable](https://github.com/zalando/postgres-operator/blob/master/manifests/postgres-operator.yaml#L36)
12+
is set in the deployment yaml and is not empty. If the CRDs already exists they
13+
will only be patched. If you do not wish the operator to create or update the
14+
CRDs set `enable_crd_registration` config option to `false`.
15+
16+
CRDs are defined with a `openAPIV3Schema` structural schema against which new
17+
manifests of [`postgresql`](https://github.com/zalando/postgres-operator/blob/master/manifests/postgresql.crd.yaml) or [`OperatorConfiguration`](https://github.com/zalando/postgres-operator/blob/master/manifests/operatorconfiguration.crd.yaml)
18+
resources will be validated. On creation you can bypass the validation with
19+
`kubectl create --validate=false`.
20+
21+
By default, the operator will register the CRDs in the `all` category so
22+
that resources are listed on `kubectl get all` commands. The `crd_categories`
23+
config option allows for customization of categories.
24+
625
## Upgrading the operator
726

827
The Postgres Operator is upgraded by changing the docker image within the
@@ -63,30 +82,6 @@ upgrade procedure, refer to the [corresponding PR in Spilo](https://github.com/z
6382
When `major_version_upgrade_mode` is set to `manual` the operator will run
6483
the upgrade script for you after the manifest is updated and pods are rotated.
6584

66-
## CRD Validation
67-
68-
[CustomResourceDefinitions](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/#customresourcedefinitions)
69-
will be registered with schema validation by default when the operator is
70-
deployed. The `OperatorConfiguration` CRD will only get created if the
71-
`POSTGRES_OPERATOR_CONFIGURATION_OBJECT` [environment variable](https://github.com/zalando/postgres-operator/blob/master/manifests/postgres-operator.yaml#L36)
72-
in the deployment yaml is set and not empty.
73-
74-
When submitting manifests of [`postgresql`](https://github.com/zalando/postgres-operator/blob/master/manifests/postgresql.crd.yaml) or
75-
[`OperatorConfiguration`](https://github.com/zalando/postgres-operator/blob/master/manifests/operatorconfiguration.crd.yaml) custom
76-
resources with kubectl, validation can be bypassed with `--validate=false`. The
77-
operator can also be configured to not register CRDs with validation on `ADD` or
78-
`UPDATE` events. Running instances are not affected when enabling the validation
79-
afterwards unless the manifests is not changed then. Note, that the provided CRD
80-
manifests contain the validation for users to understand what schema is
81-
enforced.
82-
83-
Once the validation is enabled it can only be disabled manually by editing or
84-
patching the CRD manifest:
85-
86-
```bash
87-
kubectl patch crd postgresqls.acid.zalan.do -p '{"spec":{"validation": null}}'
88-
```
89-
9085
## Non-default cluster domain
9186

9287
If your cluster uses a DNS domain other than the default `cluster.local`, this

docs/reference/operator_parameters.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,12 @@ Those are top-level keys, containing both leaf keys and groups.
7575
The default is `true`.
7676

7777
* **enable_crd_validation**
78-
toggles if the operator will create or update CRDs with
78+
*deprecated*: toggles if the operator will create or update CRDs with
7979
[OpenAPI v3 schema validation](https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/#validation)
80-
The default is `true`.
80+
The default is `true`. `false` will be ignored, since `apiextensions.io/v1` requires a structural schema definition.
81+
82+
* **crd_categories**
83+
The operator will register CRDs in the `all` category by default so that they will be returned by a `kubectl get all` call. You are free to change categories or leave them empty.
8184

8285
* **enable_lazy_spilo_upgrade**
8386
Instruct operator to update only the statefulsets with new images (Spilo and InitContainers) without immediately doing the rolling update. The assumption is pods will be re-started later with new images, for example due to the node rotation.

e2e/tests/test_e2e.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@ def test_additional_teams_and_members(self):
204204
"enable_postgres_team_crd": "true",
205205
"enable_team_member_deprecation": "true",
206206
"role_deletion_suffix": "_delete_me",
207-
"resync_period": "15s"
207+
"resync_period": "15s",
208+
"repair_period": "10s",
208209
},
209210
}
210211
k8s.update_config(enable_postgres_team_crd)
@@ -288,6 +289,7 @@ def test_additional_teams_and_members(self):
288289
revert_resync = {
289290
"data": {
290291
"resync_period": "4m",
292+
"repair_period": "1m",
291293
},
292294
}
293295
k8s.update_config(revert_resync)
@@ -1403,6 +1405,7 @@ def test_rolling_update_label_timeout(self):
14031405
"data": {
14041406
"pod_label_wait_timeout": "2s",
14051407
"resync_period": "30s",
1408+
"repair_period": "10s",
14061409
}
14071410
}
14081411

@@ -1444,6 +1447,7 @@ def test_rolling_update_label_timeout(self):
14441447
"data": {
14451448
"pod_label_wait_timeout": "10m",
14461449
"resync_period": "4m",
1450+
"repair_period": "2m",
14471451
}
14481452
}
14491453
k8s.update_config(patch_resync_config, "revert resync interval and pod_label_wait_timeout")

manifests/configmap.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ data:
2222
# connection_pooler_number_of_instances: 2
2323
# connection_pooler_schema: "pooler"
2424
# connection_pooler_user: "pooler"
25+
crd_categories: "all"
2526
# custom_service_annotations: "keyx:valuez,keya:valuea"
2627
# custom_pod_annotations: "keya:valuea,keyb:valueb"
2728
db_hosted_zone: db.example.com
@@ -36,7 +37,6 @@ data:
3637
# downscaler_annotations: "deployment-time,downscaler/*"
3738
# enable_admin_role_for_users: "true"
3839
# enable_crd_registration: "true"
39-
# enable_crd_validation: "true"
4040
# enable_cross_namespace_secret: "false"
4141
# enable_database_access: "true"
4242
enable_ebs_gp3_migration: "false"

manifests/operatorconfiguration.crd.yaml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ spec:
5959
configuration:
6060
type: object
6161
properties:
62+
crd_categories:
63+
type: array
64+
nullable: true
65+
items:
66+
type: string
6267
docker_image:
6368
type: string
6469
default: "registry.opensource.zalan.do/acid/spilo-14:2.1-p3"
@@ -67,6 +72,7 @@ spec:
6772
default: true
6873
enable_crd_validation:
6974
type: boolean
75+
description: deprecated
7076
default: true
7177
enable_lazy_spilo_upgrade:
7278
type: boolean
@@ -88,11 +94,13 @@ spec:
8894
default: false
8995
max_instances:
9096
type: integer
91-
minimum: -1 # -1 = disabled
97+
description: "-1 = disabled"
98+
minimum: -1
9299
default: -1
93100
min_instances:
94101
type: integer
95-
minimum: -1 # -1 = disabled
102+
description: "-1 = disabled"
103+
minimum: -1
96104
default: -1
97105
resync_period:
98106
type: string
@@ -182,6 +190,9 @@ spec:
182190
type: array
183191
items:
184192
type: string
193+
enable_cross_namespace_secret:
194+
type: boolean
195+
default: false
185196
enable_init_containers:
186197
type: boolean
187198
default: true

manifests/postgresql-operator-default-configuration.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ metadata:
55
configuration:
66
docker_image: registry.opensource.zalan.do/acid/spilo-14:2.1-p3
77
# enable_crd_registration: true
8-
# enable_crd_validation: true
8+
# crd_categories:
9+
# - all
910
# enable_lazy_spilo_upgrade: false
1011
enable_pgversion_env_var: true
1112
# enable_shm_volume: true

manifests/postgresql.crd.yaml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ spec:
145145
- "transaction"
146146
numberOfInstances:
147147
type: integer
148-
minimum: 2
148+
minimum: 1
149149
resources:
150150
type: object
151151
required:
@@ -199,8 +199,9 @@ spec:
199199
type: boolean
200200
enableShmVolume:
201201
type: boolean
202-
init_containers: # deprecated
202+
init_containers:
203203
type: array
204+
description: deprecated
204205
nullable: true
205206
items:
206207
type: object
@@ -227,8 +228,8 @@ spec:
227228
items:
228229
type: object
229230
required:
230-
- weight
231231
- preference
232+
- weight
232233
properties:
233234
preference:
234235
type: object
@@ -346,8 +347,9 @@ spec:
346347
type: object
347348
additionalProperties:
348349
type: string
349-
pod_priority_class_name: # deprecated
350+
pod_priority_class_name:
350351
type: string
352+
description: deprecated
351353
podPriorityClassName:
352354
type: string
353355
postgresql:
@@ -391,8 +393,9 @@ spec:
391393
type: boolean
392394
secretNamespace:
393395
type: string
394-
replicaLoadBalancer: # deprecated
396+
replicaLoadBalancer:
395397
type: boolean
398+
description: deprecated
396399
resources:
397400
type: object
398401
required:
@@ -510,14 +513,14 @@ spec:
510513
- PreferNoSchedule
511514
tolerationSeconds:
512515
type: integer
513-
useLoadBalancer: # deprecated
516+
useLoadBalancer:
514517
type: boolean
518+
description: deprecated
515519
users:
516520
type: object
517521
additionalProperties:
518522
type: array
519523
nullable: true
520-
description: "Role flags specified here must not contradict each other"
521524
items:
522525
type: string
523526
enum:

0 commit comments

Comments
 (0)