mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-22 10:09:07 +02:00
feat: common labels for all releases in a helmfile (#1415)
This adds `comonLabels` option to helmfile by: - Adding `CommonLabels` to HelmState - Changing `markExcludedReleases` and `ListReleases` functions to merge common labels into release labels Resolves #1266
This commit is contained in:
@@ -103,6 +103,9 @@ helmDefaults:
|
||||
# when using helm 3.2+, automatically create release namespaces if they do not exist (default true)
|
||||
createNamespace: true
|
||||
|
||||
# these labels will be applied to all releases in a Helmfile. Useful in templating if you have a helmfile per environment or customer and don't want to copy the same label to each release
|
||||
commonLabels:
|
||||
hello: world
|
||||
|
||||
# The desired states of Helm releases.
|
||||
#
|
||||
@@ -522,6 +525,41 @@ The `selector` parameter can be specified multiple times. Each parameter is reso
|
||||
|
||||
In addition to user supplied labels, the name, the namespace, and the chart are available to be used as selectors. The chart will just be the chart name excluding the repository (Example `stable/filebeat` would be selected using `--selector chart=filebeat`).
|
||||
|
||||
`commonLabels` can be used when you want to apply the same label to all releases and use [templating](##Templates) based on that.
|
||||
For instance, you install a number of charts on every customer but need to provide different values file per customer.
|
||||
|
||||
templates/common.yaml:
|
||||
|
||||
```
|
||||
templates:
|
||||
nginx: &nginx
|
||||
name: nginx
|
||||
chart: stable/nginx-ingress
|
||||
values:
|
||||
- ../values/common/{{ .Release.Name }}.yaml
|
||||
- ../values/{{ .Release.Labels.customer }}/{{ .Release.Name }}.yaml
|
||||
|
||||
cert-manager: &cert-manager
|
||||
name: cert-manager
|
||||
chart: jetstack/cert-manager
|
||||
values:
|
||||
- ../values/common/{{ .Release.Name }}.yaml
|
||||
- ../values/{{ .Release.Labels.customer }}/{{ .Release.Name }}.yaml
|
||||
```
|
||||
|
||||
helmfile.yaml:
|
||||
|
||||
```
|
||||
{{ readFile "templates/common.yaml" }}
|
||||
|
||||
commonLabels:
|
||||
customer: company
|
||||
|
||||
releases:
|
||||
- <<: *nginx
|
||||
- <<: *cert-manager
|
||||
```
|
||||
|
||||
## Templates
|
||||
|
||||
You can use go's text/template expressions in `helmfile.yaml` and `values.yaml.gotmpl` (templated helm values files). `values.yaml` references will be used verbatim. In other words:
|
||||
|
||||
Reference in New Issue
Block a user