Simplify service account name in helm chart (#612)
* Simplify service account name in helm chart (#610)
This commit is contained in:
		
							parent
							
								
									7c19cf50db
								
							
						
					
					
						commit
						1c340c68c6
					
				|  | @ -24,6 +24,13 @@ If release name contains chart name it will be used as a full name. | ||||||
| {{- end -}} | {{- end -}} | ||||||
| {{- end -}} | {{- end -}} | ||||||
| 
 | 
 | ||||||
|  | {{/* | ||||||
|  | Create a service account name. | ||||||
|  | */}} | ||||||
|  | {{- define "postgres-operator.serviceAccountName" -}} | ||||||
|  | {{ default (include "postgres-operator.fullname" .) .Values.serviceAccount.name }} | ||||||
|  | {{- end -}} | ||||||
|  | 
 | ||||||
| {{/* | {{/* | ||||||
| Create chart name and version as used by the chart label. | Create chart name and version as used by the chart label. | ||||||
| */}} | */}} | ||||||
|  |  | ||||||
|  | @ -2,11 +2,7 @@ | ||||||
| apiVersion: rbac.authorization.k8s.io/v1beta1 | apiVersion: rbac.authorization.k8s.io/v1beta1 | ||||||
| kind: ClusterRole | kind: ClusterRole | ||||||
| metadata: | metadata: | ||||||
|   name: {{- if eq .Values.serviceAccount.name "" }} |   name: {{ include "postgres-operator.serviceAccountName" . }} | ||||||
|             {{ template "postgres-operator.fullname" . }} |  | ||||||
|         {{- else }} |  | ||||||
|             {{ .Values.serviceAccount.name }} |  | ||||||
|         {{- end }} |  | ||||||
|   labels: |   labels: | ||||||
|     app.kubernetes.io/name: {{ template "postgres-operator.name" . }} |     app.kubernetes.io/name: {{ template "postgres-operator.name" . }} | ||||||
|     helm.sh/chart: {{ template "postgres-operator.chart" . }} |     helm.sh/chart: {{ template "postgres-operator.chart" . }} | ||||||
|  | @ -145,11 +141,7 @@ rules: | ||||||
|   verbs: |   verbs: | ||||||
|   - bind |   - bind | ||||||
|   resourceNames: |   resourceNames: | ||||||
|   - {{- if eq .Values.serviceAccount.name "" }} |   - {{ include "postgres-operator.serviceAccountName" . }} | ||||||
|       {{ template "postgres-operator.fullname" . }} |  | ||||||
|     {{- else }} |  | ||||||
|       {{ .Values.serviceAccount.name }} |  | ||||||
|     {{- end }} |  | ||||||
| - apiGroups: | - apiGroups: | ||||||
|   - batch |   - batch | ||||||
|   resources: |   resources: | ||||||
|  |  | ||||||
|  | @ -2,11 +2,7 @@ | ||||||
| apiVersion: rbac.authorization.k8s.io/v1 | apiVersion: rbac.authorization.k8s.io/v1 | ||||||
| kind: ClusterRoleBinding | kind: ClusterRoleBinding | ||||||
| metadata: | metadata: | ||||||
|   name: {{- if eq .Values.serviceAccount.name "" }} |   name: {{ include "postgres-operator.serviceAccountName" . }} | ||||||
|             {{ template "postgres-operator.fullname" . }} |  | ||||||
|         {{- else }} |  | ||||||
|             {{ .Values.serviceAccount.name }} |  | ||||||
|         {{- end }} |  | ||||||
|   labels: |   labels: | ||||||
|     app.kubernetes.io/name: {{ template "postgres-operator.name" . }} |     app.kubernetes.io/name: {{ template "postgres-operator.name" . }} | ||||||
|     helm.sh/chart: {{ template "postgres-operator.chart" . }} |     helm.sh/chart: {{ template "postgres-operator.chart" . }} | ||||||
|  | @ -15,19 +11,11 @@ metadata: | ||||||
| roleRef: | roleRef: | ||||||
|   apiGroup: rbac.authorization.k8s.io |   apiGroup: rbac.authorization.k8s.io | ||||||
|   kind: ClusterRole |   kind: ClusterRole | ||||||
|   name: {{- if eq .Values.serviceAccount.name "" }} |   name: {{ include "postgres-operator.serviceAccountName" . }} | ||||||
|             {{ template "postgres-operator.fullname" . }} |  | ||||||
|         {{- else }} |  | ||||||
|             {{ .Values.serviceAccount.name }} |  | ||||||
|         {{- end }} |  | ||||||
| subjects: | subjects: | ||||||
| - kind: ServiceAccount | - kind: ServiceAccount | ||||||
| # note: the cluster role binding needs to be defined | # note: the cluster role binding needs to be defined | ||||||
| # for every namespace the operator service account lives in. | # for every namespace the operator service account lives in. | ||||||
|   name: {{- if eq .Values.serviceAccount.name "" }} |   name: {{ include "postgres-operator.serviceAccountName" . }} | ||||||
|             {{ template "postgres-operator.fullname" . }} |  | ||||||
|         {{- else }} |  | ||||||
|             {{ .Values.serviceAccount.name }} |  | ||||||
|         {{- end }} |  | ||||||
|   namespace: {{ .Release.Namespace }} |   namespace: {{ .Release.Namespace }} | ||||||
| {{ end }} | {{ end }} | ||||||
|  |  | ||||||
|  | @ -9,11 +9,7 @@ metadata: | ||||||
|     app.kubernetes.io/managed-by: {{ .Release.Service }} |     app.kubernetes.io/managed-by: {{ .Release.Service }} | ||||||
|     app.kubernetes.io/instance: {{ .Release.Name }} |     app.kubernetes.io/instance: {{ .Release.Name }} | ||||||
| data: | data: | ||||||
|   pod_service_account_name: {{- if eq .Values.serviceAccount.name "" }} |   pod_service_account_name: {{ include "postgres-operator.serviceAccountName" . }} | ||||||
|                                 {{ template "postgres-operator.fullname" . }} |  | ||||||
|                             {{- else }} |  | ||||||
|                                 {{ .Values.serviceAccount.name }} |  | ||||||
|                             {{- end }} |  | ||||||
| {{ toYaml .Values.configGeneral | indent 2 }} | {{ toYaml .Values.configGeneral | indent 2 }} | ||||||
| {{ toYaml .Values.configUsers | indent 2 }} | {{ toYaml .Values.configUsers | indent 2 }} | ||||||
| {{ toYaml .Values.configKubernetes | indent 2 }} | {{ toYaml .Values.configKubernetes | indent 2 }} | ||||||
|  |  | ||||||
|  | @ -31,11 +31,7 @@ spec: | ||||||
| {{ toYaml .Values.podLabels | indent 8 }} | {{ toYaml .Values.podLabels | indent 8 }} | ||||||
|       {{- end }} |       {{- end }} | ||||||
|     spec: |     spec: | ||||||
|       serviceAccountName: {{- if eq .Values.serviceAccount.name "" }} |       serviceAccountName: {{ include "postgres-operator.serviceAccountName" . }} | ||||||
|                             {{ template "postgres-operator.fullname" . }} |  | ||||||
|                           {{- else }} |  | ||||||
|                             {{ .Values.serviceAccount.name }} |  | ||||||
|                           {{- end }} |  | ||||||
|       containers: |       containers: | ||||||
|       - name: {{ .Chart.Name }} |       - name: {{ .Chart.Name }} | ||||||
|         image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag }}" |         image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag }}" | ||||||
|  |  | ||||||
|  | @ -2,11 +2,7 @@ | ||||||
| apiVersion: v1 | apiVersion: v1 | ||||||
| kind: ServiceAccount | kind: ServiceAccount | ||||||
| metadata: | metadata: | ||||||
|   name: {{- if eq .Values.serviceAccount.name "" }} |   name: {{ include "postgres-operator.serviceAccountName" . }} | ||||||
|             {{ template "postgres-operator.fullname" . }} |  | ||||||
|         {{- else }} |  | ||||||
|             {{ .Values.serviceAccount.name }} |  | ||||||
|         {{- end }} |  | ||||||
|   labels: |   labels: | ||||||
|     app.kubernetes.io/name: {{ template "postgres-operator.name" . }} |     app.kubernetes.io/name: {{ template "postgres-operator.name" . }} | ||||||
|     helm.sh/chart: {{ template "postgres-operator.chart" . }} |     helm.sh/chart: {{ template "postgres-operator.chart" . }} | ||||||
|  |  | ||||||
|  | @ -245,7 +245,7 @@ serviceAccount: | ||||||
|   # If not set and create is true, a name is generated using the fullname template |   # If not set and create is true, a name is generated using the fullname template | ||||||
|   # When relying solely on the OperatorConfiguration CRD, set this value to "operator" |   # When relying solely on the OperatorConfiguration CRD, set this value to "operator" | ||||||
|   # Otherwise, the operator tries to use the "default" service account which is forbidden |   # Otherwise, the operator tries to use the "default" service account which is forbidden | ||||||
|   name: "operator" |   name: operator | ||||||
| 
 | 
 | ||||||
| priorityClassName: "" | priorityClassName: "" | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -226,7 +226,7 @@ serviceAccount: | ||||||
|   # If not set and create is true, a name is generated using the fullname template |   # If not set and create is true, a name is generated using the fullname template | ||||||
|   # When relying solely on the OperatorConfiguration CRD, set this value to "operator" |   # When relying solely on the OperatorConfiguration CRD, set this value to "operator" | ||||||
|   # Otherwise, the operator tries to use the "default" service account which is forbidden |   # Otherwise, the operator tries to use the "default" service account which is forbidden | ||||||
|   name: "" |   name: | ||||||
| 
 | 
 | ||||||
| priorityClassName: "" | priorityClassName: "" | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue