docs: add description about common.metadata
This commit is contained in:
42
README.md
42
README.md
@ -22,6 +22,7 @@ It provides utilities that reflect best practices of Kubernetes chart developmen
|
|||||||
* [`common.serviceMonitor.secret`](#commonservicemonitorsecret)
|
* [`common.serviceMonitor.secret`](#commonservicemonitorsecret)
|
||||||
- [Partial Objects](#partial-objects)
|
- [Partial Objects](#partial-objects)
|
||||||
* [`common.container`](#commoncontainer)
|
* [`common.container`](#commoncontainer)
|
||||||
|
* [`common.metadata`](#commonmetadata)
|
||||||
* [`common.pod.template`](#commonpodtemplate)
|
* [`common.pod.template`](#commonpodtemplate)
|
||||||
|
|
||||||
|
|
||||||
@ -882,6 +883,47 @@ spec:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### `common.metadata`
|
||||||
|
|
||||||
|
The `common.metadata` helper generates value for the `metadata:` section of a Kubernetes resource.
|
||||||
|
|
||||||
|
This takes a list of two values:
|
||||||
|
|
||||||
|
- `$top`, the top context
|
||||||
|
- [optional] the template name of the overrides
|
||||||
|
|
||||||
|
It generates standard labels and a name field.
|
||||||
|
|
||||||
|
Example template:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
metadata:
|
||||||
|
{{- include "common.metadata" (list .) | nindent 2 }}
|
||||||
|
|
||||||
|
## The following is the same as above:
|
||||||
|
# metadata:
|
||||||
|
# {{- include "common.metadata" (list . "mychart.metadata") | nindent 2 }}
|
||||||
|
# {{- define "mychart.metadata" -}}
|
||||||
|
# {{- end -}}
|
||||||
|
```
|
||||||
|
|
||||||
|
Example output:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
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
|
||||||
|
```
|
||||||
|
|
||||||
|
Most of the common templates that define a resource type (e.g. `common.configMap` or `common.cronJob`) use this to generate the metadata, which means they inherit the same `labels` and `name` fields.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### `common.pod.template`
|
### `common.pod.template`
|
||||||
|
|
||||||
The `common.pod.template` template accepts a list of three values:
|
The `common.pod.template` template accepts a list of three values:
|
||||||
|
Reference in New Issue
Block a user