Skip to content

Commit 099af84

Browse files
feat(cluster): add option to specify shared service account
Signed-off-by: maciej-tatarski <mta@corti.ai>
1 parent 4a9040f commit 099af84

7 files changed

Lines changed: 16 additions & 5 deletions

File tree

charts/cluster/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ description: Deploys and manages a CloudNativePG cluster and its associated reso
2222
kubeVersion: ">=1.29.0-0"
2323
icon: https://raw.githubusercontent.com/cloudnative-pg/artwork/main/cloudnativepg-logo.svg
2424
type: application
25-
version: 0.6.0
25+
version: 0.6.1
2626
sources:
2727
- https://github.com/cloudnative-pg/charts
2828
keywords:

charts/cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ Kubernetes: `>=1.29.0-0`
196196
| cluster.roles | list | `[]` | This feature enables declarative management of existing roles, as well as the creation of new roles if they are not already present in the database. See: https://cloudnative-pg.io/documentation/current/declarative_role_management/ |
197197
| cluster.securityContext | object | `{}` | Configure Container Security Context. See: https://cloudnative-pg.io/documentation/preview/security/ |
198198
| cluster.serviceAccountTemplate | object | `{}` | Configure the metadata of the generated service account |
199+
| cluster.serviceAccountName | string | `""` | Name of the service account to use for the cluster. If not set, a new service account will be created using the template. |
199200
| cluster.services | object | `{}` | Customization of service definitions. Please refer to https://cloudnative-pg.io/documentation/current/service_management/ |
200201
| cluster.storage.size | string | `"8Gi"` | |
201202
| cluster.storage.storageClass | string | `""` | |

charts/cluster/templates/cluster.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,16 @@ spec:
110110
{{ end }}
111111
{{- end }}
112112

113+
{{- if not .Values.cluster.serviceAccountName }}
113114
{{- with .Values.cluster.serviceAccountTemplate }}
114115
serviceAccountTemplate:
115116
{{- toYaml . | nindent 4 }}
116117
{{- end }}
118+
{{- end }}
119+
120+
{{- if .Values.cluster.serviceAccountName }}
121+
serviceAccountName: {{ .Values.cluster.serviceAccountName }}
122+
{{- end }}
117123

118124
{{- with .Values.cluster.podSecurityContext }}
119125
podSecurityContext:

charts/cluster/test/postgresql-cluster-configuration/01-non_default_configuration_cluster-assert.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,7 @@ spec:
127127
test-annotation: "true"
128128
spec:
129129
type: LoadBalancer
130-
serviceAccountTemplate:
131-
metadata:
132-
annotations:
133-
my-annotation: my-service-account
130+
serviceAccountName: my-custom-service-account
134131
podSecurityContext:
135132
runAsUser: 26
136133
runAsGroup: 26

charts/cluster/test/postgresql-cluster-configuration/01-non_default_configuration_cluster.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ cluster:
127127
metadata:
128128
annotations:
129129
my-annotation: my-service-account
130+
serviceAccountName: my-custom-service-account
130131
podSecurityContext:
131132
runAsUser: 26
132133
runAsGroup: 26

charts/cluster/values.schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,9 @@
334334
"serviceAccountTemplate": {
335335
"type": "object"
336336
},
337+
"serviceAccountName": {
338+
"type": "string"
339+
},
337340
"services": {
338341
"type": "object"
339342
},

charts/cluster/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,9 @@ cluster:
398398
# -- Configure the metadata of the generated service account
399399
serviceAccountTemplate: {}
400400

401+
# -- Configure the name serviceAccount to use for the cluster. If specified, it takes precedence over serviceAccountTemplate.name
402+
serviceAccountName: ""
403+
401404
# -- Configure the Pod Security Context.
402405
# See: https://cloudnative-pg.io/documentation/preview/security/
403406
podSecurityContext: {}

0 commit comments

Comments
 (0)