fix: common.serviceAccountName
should accepts $serviceAccount
This commit is contained in:
17
README.md
17
README.md
@ -117,11 +117,12 @@ metadata:
|
||||
|
||||
### `common.cronJob`
|
||||
|
||||
The `common.cronJob` template accepts a list of four values:
|
||||
The `common.cronJob` template accepts a list of five values:
|
||||
|
||||
- `$top`, the top context
|
||||
- `$cronJob`, a dictionary of values used in the cronjob template
|
||||
- `$pod`, a dictionary of values used in the pod template
|
||||
- `$serviceAccount`, a dictionary of values used in the service account template
|
||||
- [optional] the template name of the overrides
|
||||
|
||||
It defines a basic `CronJob` with the following defaults:
|
||||
@ -143,10 +144,10 @@ Underneath the hood, it invokes [`common.pod.template`](#commonpodtemplate) temp
|
||||
Example use:
|
||||
|
||||
```yaml
|
||||
{{- include "common.cronJob" (list . .Values.cronJob .Values) -}}
|
||||
{{- include "common.cronJob" (list . .Values.cronJob .Values .Values.serviceAccount) -}}
|
||||
|
||||
## The following is the same as above:
|
||||
# {{- include "common.cronJob" (list . .Values.cronJob .Values "mychart.cronJob") -}}
|
||||
# {{- include "common.cronJob" (list . .Values.cronJob .Values .Values.serviceAccount "mychart.cronJob") -}}
|
||||
# {{- define "mychart.cronJob" -}}
|
||||
# {{- end -}}
|
||||
```
|
||||
@ -156,11 +157,12 @@ Example use:
|
||||
|
||||
### `common.deployment`
|
||||
|
||||
The `common.deployment` template accepts a list of four values:
|
||||
The `common.deployment` template accepts a list of five values:
|
||||
|
||||
- `$top`, the top context
|
||||
- `$deployment`, a dictionary of values used in the deployment template
|
||||
- `$autoscaling`, a dictionary of values used in the hpa template
|
||||
- `$serviceAccount`, a dictionary of values used in the service account template
|
||||
- [optional] the template name of the overrides
|
||||
|
||||
It defines a basic `Deployment` with the following settings:
|
||||
@ -180,10 +182,10 @@ Underneath the hood, it invokes [`common.pod.template`](#commonpodtemplate) temp
|
||||
Example use:
|
||||
|
||||
```yaml
|
||||
{{- include "common.deployment" (list . .Values .Values.autoscaling) -}}
|
||||
{{- include "common.deployment" (list . .Values .Values.autoscaling .Values.serviceAccount) -}}
|
||||
|
||||
## The following is the same as above:
|
||||
# {{- include "common.deployment" (list . .Values .Values.autoscaling "mychart.deployment") -}}
|
||||
# {{- include "common.deployment" (list . .Values .Values.autoscaling .Values.serviceAccount "mychart.deployment") -}}
|
||||
# {{- define "mychart.deployment" -}}
|
||||
# {{- end -}}
|
||||
```
|
||||
@ -1012,10 +1014,11 @@ Output of this function is truncated at 63 characters, which is the maximum leng
|
||||
|
||||
### `common.pod.template`
|
||||
|
||||
The `common.pod.template` template accepts a list of three values:
|
||||
The `common.pod.template` template accepts a list of four values:
|
||||
|
||||
- `$top`, the top context
|
||||
- `$pod`, a dictionary of values used in the container template
|
||||
- `$serviceAccount`, a dictionary of values used in the service account template
|
||||
- [optional] the template name of the overrides
|
||||
|
||||
It creates a basic `PodTemplate` spec to be used within a `Deployment` or `CronJob`. It holds the following defaults:
|
||||
|
@ -9,6 +9,7 @@ spec:
|
||||
{{- $top := first . -}}
|
||||
{{- $cronJob := index . 1 -}}
|
||||
{{- $pod := index . 2 -}}
|
||||
{{- $serviceAccount := index . 3 -}}
|
||||
apiVersion: batch/v1beta1
|
||||
kind: CronJob
|
||||
metadata:
|
||||
@ -30,7 +31,7 @@ spec:
|
||||
{{- include "common.selectorLabels" $top | nindent 8 }}
|
||||
spec:
|
||||
template:
|
||||
{{- include "common.pod.template" (list $top $pod "common.cronJob.pod") | nindent 8 }}
|
||||
{{- include "common.pod.template" (list $top $pod $serviceAccount "common.cronJob.pod") | nindent 8 }}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "common.cronJob" -}}
|
||||
|
@ -4,6 +4,7 @@
|
||||
{{- $top := first . -}}
|
||||
{{- $deployment := index . 1 -}}
|
||||
{{- $autoscaling := index . 2 -}}
|
||||
{{- $serviceAccount := index . 3 -}}
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@ -16,7 +17,7 @@ spec:
|
||||
matchLabels:
|
||||
{{- include "common.selectorLabels" $top | nindent 6 }}
|
||||
template:
|
||||
{{- include "common.pod.template" . | nindent 4 }}
|
||||
{{- include "common.pod.template" (list $top $deployment $serviceAccount) | nindent 4 }}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "common.deployment" -}}
|
||||
|
@ -36,9 +36,10 @@ Create chart name and version as used by the chart label.
|
||||
Create the name of the service account to use.
|
||||
*/}}
|
||||
{{- define "common.serviceAccountName" -}}
|
||||
{{- $serviceAccount := .Values.serviceAccount | default (dict) -}}
|
||||
{{- $top := first . -}}
|
||||
{{- $serviceAccount := index . 1 -}}
|
||||
{{- if $serviceAccount.create -}}
|
||||
{{ default (include "common.fullname" .) $serviceAccount.name }}
|
||||
{{ default (include "common.fullname" $top) $serviceAccount.name }}
|
||||
{{- else -}}
|
||||
{{ default "default" $serviceAccount.name }}
|
||||
{{- end -}}
|
||||
|
@ -3,6 +3,7 @@
|
||||
{{- define "common.pod.template.tpl" -}}
|
||||
{{- $top := first . -}}
|
||||
{{- $pod := index . 1 -}}
|
||||
{{- $serviceAccount := index . 2 -}}
|
||||
metadata:
|
||||
labels:
|
||||
{{- include "common.selectorLabels" $top | nindent 4 }}
|
||||
@ -11,11 +12,11 @@ spec:
|
||||
imagePullSecrets:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
serviceAccountName: {{ include "common.serviceAccountName" $top }}
|
||||
serviceAccountName: {{ include "common.serviceAccountName" (list $top $serviceAccount) }}
|
||||
securityContext:
|
||||
{{- toYaml $pod.podSecurityContext | nindent 4 }}
|
||||
containers:
|
||||
- {{- include "common.container" . | nindent 6 }}
|
||||
- {{- include "common.container" (list $top $pod) | nindent 6 }}
|
||||
{{- with $pod.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
|
@ -3,7 +3,7 @@
|
||||
{{- define "common.serviceAccount.metadata" -}}
|
||||
{{- $top := first . -}}
|
||||
{{- $serviceAccount := index . 1 -}}
|
||||
name: {{ include "common.serviceAccountName" $top }}
|
||||
name: {{ include "common.serviceAccountName" . }}
|
||||
{{- with $serviceAccount.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 2 }}
|
||||
|
Reference in New Issue
Block a user