Skip to content

Commit fe34019

Browse files
dpeckettDamian Peckett
andauthored
Add configuration flag for disabling operator CRD creation/update (zalando#1733)
* Make CRD registration configurable and drop RBAC permissions when CRD registration is disabled * add generated deep copy functions Co-authored-by: Damian Peckett <[email protected]>
1 parent b4155bc commit fe34019

File tree

13 files changed

+41
-10
lines changed

13 files changed

+41
-10
lines changed

charts/postgres-operator/crds/operatorconfigurations.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ spec:
6464
docker_image:
6565
type: string
6666
default: "registry.opensource.zalan.do/acid/spilo-14:2.1-p3"
67+
enable_crd_registration:
68+
type: boolean
69+
default: true
6770
enable_crd_validation:
6871
type: boolean
6972
default: true

charts/postgres-operator/templates/clusterrole.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@ rules:
4040
resources:
4141
- customresourcedefinitions
4242
verbs:
43-
- create
4443
- get
44+
{{- if toString .Values.configGeneral.enable_crd_registration | eq "true" }}
45+
- create
4546
- patch
4647
- update
48+
{{- end }}
4749
# to send events to the CRs
4850
- apiGroups:
4951
- ""

charts/postgres-operator/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ enableJsonLogging: false
2020

2121
# general configuration parameters
2222
configGeneral:
23+
# the deployment should create/update the CRDs
24+
enable_crd_registration: true
2325
# choose if deployment creates/updates CRDs with OpenAPIV3Validation
2426
enable_crd_validation: true
2527
# update only the statefulsets without immediately doing the rolling update

docs/reference/operator_parameters.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ Variable names are underscore-separated words.
7070

7171
Those are top-level keys, containing both leaf keys and groups.
7272

73+
* **enable_crd_registration**
74+
Instruct the operator to create/update the CRDs. If disabled the operator will rely on the CRDs being managed separately.
75+
The default is `true`.
76+
7377
* **enable_crd_validation**
7478
toggles if the operator will create or update CRDs with
7579
[OpenAPI v3 schema validation](https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/#validation)

manifests/configmap.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ data:
3535
docker_image: registry.opensource.zalan.do/acid/spilo-14:2.1-p3
3636
# downscaler_annotations: "deployment-time,downscaler/*"
3737
# enable_admin_role_for_users: "true"
38+
# enable_crd_registration: "true"
3839
# enable_crd_validation: "true"
3940
# enable_cross_namespace_secret: "false"
4041
# enable_database_access: "true"

manifests/operatorconfiguration.crd.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ spec:
6262
docker_image:
6363
type: string
6464
default: "registry.opensource.zalan.do/acid/spilo-14:2.1-p3"
65+
enable_crd_registration:
66+
type: boolean
67+
default: true
6568
enable_crd_validation:
6669
type: boolean
6770
default: true

manifests/postgresql-operator-default-configuration.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ metadata:
44
name: postgresql-operator-default-configuration
55
configuration:
66
docker_image: registry.opensource.zalan.do/acid/spilo-14:2.1-p3
7+
# enable_crd_registration: true
78
# enable_crd_validation: true
89
# enable_lazy_spilo_upgrade: false
910
enable_pgversion_env_var: true

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,9 @@ var OperatorConfigCRDResourceValidation = apiextv1.CustomResourceValidation{
946946
"docker_image": {
947947
Type: "string",
948948
},
949+
"enable_crd_registration": {
950+
Type: "boolean",
951+
},
949952
"enable_crd_validation": {
950953
Type: "boolean",
951954
},

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ type OperatorLogicalBackupConfiguration struct {
215215

216216
// OperatorConfigurationData defines the operation config
217217
type OperatorConfigurationData struct {
218+
EnableCRDRegistration *bool `json:"enable_crd_registration,omitempty"`
218219
EnableCRDValidation *bool `json:"enable_crd_validation,omitempty"`
219220
EnableLazySpiloUpgrade bool `json:"enable_lazy_spilo_upgrade,omitempty"`
220221
EnablePgVersionEnvVar bool `json:"enable_pgversion_env_var,omitempty"`

pkg/apis/acid.zalan.do/v1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)