docs: add description about common.serviceAccount

This commit is contained in:
Chi-En Wu
2020-04-23 12:17:28 +08:00
parent 70530640c5
commit a5d0102367

View File

@ -14,6 +14,7 @@ It provides utilities that reflect best practices of Kubernetes chart developmen
* [`common.ingress`](#commoningress) * [`common.ingress`](#commoningress)
* [`common.secret`](#commonsecret) * [`common.secret`](#commonsecret)
* [`common.service`](#commonservice) * [`common.service`](#commonservice)
* [`common.serviceAccount`](#commonserviceaccount)
- [Partial Objects](#partial-objects) - [Partial Objects](#partial-objects)
* [`common.container`](#commoncontainer) * [`common.container`](#commoncontainer)
* [`common.pod.template`](#commonpodtemplate) * [`common.pod.template`](#commonpodtemplate)
@ -371,6 +372,56 @@ spec:
### `common.serviceAccount`
The `common.serviceAccount` template accepts a list of three values:
- `$top`, the top context
- `$serviceAccount`, a dictionary of values used in the service account template
- [optional] the template name of the overrides
It creates a basic `ServiceAccount` resource with the following defaults:
- The name is set with `common.serviceAccountName`
- Lays out the annotations using `$serviceAccount.annotations`
An example values file that can be used to configure the `ServiceAccount` resource is:
```yaml
serviceAccount:
create: true
annotations: {}
name:
```
Example use:
```yaml
{{- include "common.serviceAccount" (list . .Values.serviceAccount) -}}
## The following is the same as above:
# {{- include "common.serviceAccount" (list . .Values.serviceAccount "mychart.serviceAccount") -}}
# {{- define "mychart.serviceAccount" -}}
# {{- end -}}
```
Output:
```yaml
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
app.kubernetes.io/instance: release-name
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: mychart
app.kubernetes.io/version: 1.16.0
helm.sh/chart: mychart-0.1.0
name: release-name-mychart
```
## Partial Objects ## Partial Objects
When writing Kubernetes resources, you may find the following helpers useful to construct parts of the spec. When writing Kubernetes resources, you may find the following helpers useful to construct parts of the spec.
@ -529,7 +580,7 @@ It creates a basic `PodTemplate` spec to be used within a `Deployment` or `CronJ
app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/instance: {{ .Release.Name }}
``` ```
as this is also used as the selector. as this is also used as the selector.
- Service account name is set with `{{ include "common.serviceAccountName" $top }}` - Service account name is set with `common.serviceAccountName`
It also uses the following configuration from the `$pod`: It also uses the following configuration from the `$pod`: