Skip to content

Commit

Permalink
Add overwrite option for instance label value (#725)
Browse files Browse the repository at this point in the history
Signed-off-by: Frederik Grieshaber <[email protected]>
Signed-off-by: Freddy Grieshaber <[email protected]>
Signed-off-by: Yann Soubeyrand <[email protected]>
Co-authored-by: Yann Soubeyrand <[email protected]>
Co-authored-by: Michel Loiseleur <[email protected]>
  • Loading branch information
3 people authored Nov 17, 2022
1 parent 4a974f4 commit 09320ab
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 4 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ order to be able to upgrade.
You may also upgrade by deploying another Traefik to a different namespace and
removing after your first Traefik.

Alternatively, since version 20.3.0 of this chart, you may set `instanceLabelOverride` to the previous value of that label.
This will override the new `Release.Name-Release.Namespace` pattern to avoid any (longer) downtime.

## Contributing

If you want to contribute to this chart, please read the [Contributing Guide](./CONTRIBUTING.md).
26 changes: 24 additions & 2 deletions traefik/Changelog.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
# Change Log

## 20.2.1 ![AppVersion: v2.9.4](https://img.shields.io/static/v1?label=AppVersion&message=v2.9.4&color=success&logo=) ![Helm: v3](https://img.shields.io/static/v1?label=Helm&message=v3&color=informational&logo=helm)
## 20.3.0 ![AppVersion: v2.9.4](https://img.shields.io/static/v1?label=AppVersion&message=v2.9.4&color=success&logo=) ![Helm: v3](https://img.shields.io/static/v1?label=Helm&message=v3&color=informational&logo=helm)

**Release date:** 2022-11-16

* 🙈 do not namespace ingress class
* Add option to override instance label value

### Default value changes

```diff
diff --git a/traefik/values.yaml b/traefik/values.yaml
index c7f84a7..ca15f6a 100644
--- a/traefik/values.yaml
+++ b/traefik/values.yaml
@@ -731,3 +731,6 @@ extraObjects: []
# This will override the default Release Namespace for Helm.
# It will not affect optional CRDs such as `ServiceMonitor` and `PrometheusRules`
# namespaceOverride: traefik
+#
+## This will override the default app.kubernetes.io/instance label for all Objects.
+# instanceLabelOverride: traefik
```

## 20.2.1 ![AppVersion: v2.9.4](https://img.shields.io/static/v1?label=AppVersion&message=v2.9.4&color=success&logo=) ![Helm: v3](https://img.shields.io/static/v1?label=Helm&message=v3&color=informational&logo=helm)

**Release date:** 2022-11-17

* 🙈 do not namespace ingress class (#723)
* ✨ copy LICENSE and README.md on release


Expand Down
2 changes: 1 addition & 1 deletion traefik/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: traefik
description: A Traefik based Kubernetes ingress controller
type: application
version: 20.2.1
version: 20.3.0
appVersion: v2.9.4
keywords:
- traefik
Expand Down
9 changes: 8 additions & 1 deletion traefik/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,18 @@ If release name contains chart name it will be used as a full name.
{{- end -}}
{{- end -}}

{{/*
Allow customization of the instance label value.
*/}}
{{- define "traefik.instance-name" -}}
{{- default (printf "%s-%s" .Release.Name .Release.Namespace) .Values.instanceLabelOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/* Shared labels used for selector*/}}
{{/* This is an immutable field: this should not change between upgrade */}}
{{- define "traefik.labelselector" -}}
app.kubernetes.io/name: {{ template "traefik.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}-{{ .Release.Namespace }}
app.kubernetes.io/instance: {{ template "traefik.instance-name" . }}
{{- end }}

{{/* Shared labels used in metada */}}
Expand Down
18 changes: 18 additions & 0 deletions traefik/tests/container-config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,21 @@ tests:
asserts:
- failedTemplate:
errorMessage: "topologySpreadConstraints are supported only on kubernetes >= v1.19"
- it: should set instance label to release.name-release.namespace if no override is set
asserts:
- isSubset:
path: spec.selector
content:
matchLabels:
app.kubernetes.io/name: traefik
app.kubernetes.io/instance: RELEASE-NAME-NAMESPACE
- it: should set instance label to instanceLabelOverride if set
set:
instanceLabelOverride: traefik
asserts:
- isSubset:
path: spec.selector
content:
matchLabels:
app.kubernetes.io/name: traefik
app.kubernetes.io/instance: traefik
3 changes: 3 additions & 0 deletions traefik/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -731,3 +731,6 @@ extraObjects: []
# This will override the default Release Namespace for Helm.
# It will not affect optional CRDs such as `ServiceMonitor` and `PrometheusRules`
# namespaceOverride: traefik
#
## This will override the default app.kubernetes.io/instance label for all Objects.
# instanceLabelOverride: traefik

0 comments on commit 09320ab

Please sign in to comment.