You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Guidelines: set matchLabels as being mandatory (helm#7692)
* Guidelines: set matchLabels as being mandatory.
Signed-off-by: Cédric de Saint Martin <[email protected]>
* fixup! Guidelines: set matchLabels as being mandatory.
Signed-off-by: Cédric de Saint Martin <[email protected]>
* fixup! fixup! Guidelines: set matchLabels as being mandatory.
Signed-off-by: Cédric de Saint Martin <[email protected]>
* Update guidelines: mention DaemonSets as well.
Signed-off-by: Cédric de Saint Martin <[email protected]>
* Review guidelines: be more precise + specify upgrade
Signed-off-by: Cédric de Saint Martin <[email protected]>
* Review guidelines: fix typos, add persistence paragraph and do not repeat component part.
Signed-off-by: Cédric de Saint Martin <[email protected]>
* Review guidelines: add PVC paragraph.
Signed-off-by: Cédric de Saint Martin <[email protected]>
* Fix spelling/typos
Signed-off-by: Reinhard Nägele <[email protected]>
* Fix incorrect typo fix
Signed-off-by: Reinhard Nägele <[email protected]>
Copy file name to clipboardExpand all lines: REVIEW_GUIDELINES.md
+56-3
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,8 @@ Stable charts should not depend on charts in incubator.
33
33
34
34
## Names and Labels
35
35
36
-
Resources and labels should follow some conventions. The standard resource metadata should be this:
36
+
### Metadata
37
+
Resources and labels should follow some conventions. The standard resource metadata (`metadata.labels` and `spec.template.metadata.labels`) should be this:
37
38
38
39
```yaml
39
40
name: {{ template "myapp.fullname" . }}
@@ -44,8 +45,41 @@ labels:
44
45
heritage: {{ .Release.Service }}
45
46
```
46
47
48
+
If a chart has multiple components, a `component` label should be added (e. g. `component: server`). The resource name should get the component as suffix (e. g. `name: {{ template "myapp.fullname" . }}-server`).
49
+
47
50
Note that templates have to be namespaced. With Helm 2.7+, `helm create` does this out-of-the-box. The `app` label should use the `name` template, not `fullname` as is still the case with older charts.
`spec.selector.matchLabels` must be specified should follow some conventions. The standard selector should be this:
55
+
56
+
```yaml
57
+
selector:
58
+
matchLabels:
59
+
app: {{ template "myapp.name" . }}
60
+
release: {{ .Release.Name }}
61
+
```
62
+
63
+
If a chart has multiple components, a `component` label should be added to the selector (see above).
64
+
65
+
`spec.selector.matchLabels`defined in `Deployments`/`StatefulSets`/`DaemonSets` `>=v1/beta2` **must not** contain `chart` label or any label containing a version of the chart, because the selector is immutable.
66
+
The chart label string contains the version, so if it is specified, whenever the the Chart.yaml version changes, Helm's attempt to change this immutable field would cause the upgrade to fail.
67
+
68
+
#### Fixing Selectors
69
+
70
+
##### For Deployments, StatefulSets, DaemonSets apps/v1beta1 or extensions/v1beta1
71
+
72
+
- If it does not specify `spec.selector.matchLabels`, set it
73
+
- Remove `chart` label in `spec.selector.matchLabels` if it exists
74
+
- Bump patch version of the Chart
75
+
76
+
##### For Deployments, StatefulSets, DaemonSets >=apps/v1beta2
77
+
78
+
- Remove `chart` label in `spec.selector.matchLabels` if it exists
79
+
- Bump major version of the Chart as it is a breaking change
80
+
81
+
### Service Selectors
82
+
49
83
Label selectors for services must have both `app` and `release` labels.
50
84
51
85
```yaml
@@ -54,7 +88,26 @@ selector:
54
88
release: {{ .Release.Name }}
55
89
```
56
90
57
-
If a chart has multiple components, a `component` label should be added (e. g. `component: server`). The resource name should get the component as suffix (e. g. `name: {{ template "myapp.fullname" . }}-server`). The `component` label must be added to label selectors as well.
91
+
If a chart has multiple components, a `component` label should be added to the selector (see above).
92
+
93
+
### Persistence Labels
94
+
95
+
### StatefulSet
96
+
97
+
In case of a `Statefulset`, `spec.volumeClaimTemplates.metadata.labels` must have both `app` and `release` labels, and **must not** contain `chart` label or any label containing a version of the chart, because `spec.volumeClaimTemplates` is immutable.
98
+
99
+
```yaml
100
+
labels:
101
+
app: {{ template "myapp.name" . }}
102
+
release: {{ .Release.Name }}
103
+
```
104
+
105
+
If a chart has multiple components, a `component` label should be added to the selector (see above).
106
+
107
+
### PersistentVolumeClaim
108
+
109
+
In case of a `PersistentVolumeClaim`, unless special needs, `matchLabels` should not be specified
110
+
because it would prevent automatic `PersistentVolume` provisioning.
58
111
59
112
## Formatting
60
113
@@ -269,7 +322,7 @@ spec:
269
322
270
323
We officially support compatibility with the current and the previous minor version of Kubernetes. Generated resources should use the latest possible API versions compatible with these versions. For extended backwards compatibility conditional logic based on capabilities may be used (see [built-in objects](https://github.com/helm/helm/blob/master/docs/chart_template_guide/builtin_objects.md)).
271
324
272
-
## Kubernetes Native Workloads.
325
+
## Kubernetes Native Workloads
273
326
274
327
While reviewing Charts that contain workloads such as [Deployments](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/), [StatefulSets](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/), [DaemonSets](https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/) and [Jobs](https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/) the below points should be considered. These are to be seen as best practices rather than strict enforcement.
0 commit comments