Skip to content

Commit e24e5f2

Browse files
committed
feat: Add namespaced deployment to helm chart
Add helm chart related changes for the namespaced deployment If one wants to use the namespaced deployment it is possible to deploy the operator setting config.namespaced and config.clusterwide. Add short documentation reference to CNPG documentation
1 parent 9969c81 commit e24e5f2

File tree

6 files changed

+21
-0
lines changed

6 files changed

+21
-0
lines changed

charts/cloudnative-pg/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ CloudNativePG Operator Helm Chart
3131
| affinity | object | `{}` | Affinity for the operator to be installed. |
3232
| commonAnnotations | object | `{}` | Annotations to be added to all other resources. |
3333
| config.clusterWide | bool | `true` | This option determines if the operator is responsible for observing events across the entire Kubernetes cluster or if its focus should be narrowed down to the specific namespace within which it has been deployed. |
34+
| config.namespaced | bool | `false` | When true, limits the operator to not access any `Nodes` or `ClusterImageCatalog` resources. The rbac policy will not include any ClusterRole and it will install the operator in namespaced deployment. See see https://cloudnative-pg.io/documentation/current/operator_conf/#available-options for more details on namespaced deployment. |
3435
| config.create | bool | `true` | Specifies whether the secret should be created. |
3536
| config.data | object | `{}` | The content of the configmap/secret, see https://cloudnative-pg.io/documentation/current/operator_conf/#available-options for all the available options. |
3637
| config.maxConcurrentReconciles | int | `10` | The maximum number of concurrent reconciles. Defaults to 10. |

charts/cloudnative-pg/templates/_helpers.tpl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,3 +310,13 @@ Define the set of rules that must be applied clusterwide
310310
- list
311311
- watch
312312
{{- end }}
313+
314+
{{/*
315+
Validate configuration compatibility and return namespaced value
316+
*/}}
317+
{{- define "cloudnative-pg.validateNamespaced" -}}
318+
{{- if and .Values.config.namespaced .Values.config.clusterWide -}}
319+
{{- fail "config.namespaced and config.clusterWide cannot both be true. When config.namespaced is true, config.clusterWide must be false." -}}
320+
{{- end -}}
321+
{{- .Values.config.namespaced -}}
322+
{{- end -}}

charts/cloudnative-pg/templates/deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ spec:
8787
valueFrom:
8888
fieldRef:
8989
fieldPath: metadata.namespace
90+
- name: NAMESPACED
91+
value: {{ include "cloudnative-pg.validateNamespaced" . }}
9092
- name: MONITORING_QUERIES_CONFIGMAP
9193
value: "{{ .Values.monitoringQueriesConfigMap.name }}"
9294
{{- if not .Values.config.clusterWide }}

charts/cloudnative-pg/templates/rbac.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ metadata:
3232
{{- end }}
3333

3434
{{- if .Values.rbac.create }}
35+
{{- if not .Values.config.namespaced }}
3536
---
3637
apiVersion: rbac.authorization.k8s.io/v1
3738
kind: ClusterRole
@@ -77,6 +78,7 @@ we create a Role with the common rules for the operator,
7778
and a RoleBinding. We already created the ClusterRole above with the
7879
required cluster-wide rules
7980
*/}}
81+
{{- end }}
8082
{{- if eq .Values.config.clusterWide false }}
8183
---
8284
apiVersion: rbac.authorization.k8s.io/v1

charts/cloudnative-pg/values.schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
"clusterWide": {
2121
"type": "boolean"
2222
},
23+
"namespaced": {
24+
"type": "boolean"
25+
},
2326
"create": {
2427
"type": "boolean"
2528
},

charts/cloudnative-pg/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ config:
7878
# events across the entire Kubernetes cluster or if its focus should be
7979
# narrowed down to the specific namespace within which it has been deployed.
8080
clusterWide: true
81+
# -- This option makes the dependency on nodes and clusterImageCatalog optional.
82+
# can only be configured with config.clusterWide set to false.
83+
namespaced: false
8184
# -- The content of the configmap/secret, see
8285
# https://cloudnative-pg.io/documentation/current/operator_conf/#available-options
8386
# for all the available options.

0 commit comments

Comments
 (0)