From ad2432bb9f6b9603e4404ababf7b0f369fbd03e2 Mon Sep 17 00:00:00 2001 From: Harry Lascelles Date: Tue, 17 Sep 2024 10:55:04 +0100 Subject: [PATCH] [stable/kube-downscaler] Kube-Downscaler does not respect release namespace when templating (#601) * Kube-Downscaler does not respect release namespace when templating The `kube-downscaler` helm chart doesn't honor the namespace passed in to helm. This is because the chart is missing the typical metadata configuration on its kubernetes resources. ie, this problem is the same as this one for another chart: https://github.com/deliveryhero/helm-charts/issues/216 To reproduce this problem: ```bash helm fetch deliveryhero/kube-downscaler --version 0.7.4 --untar=true helm template my-release kube-downscaler --namespace kube-systen > kube-downscaler.yaml ``` The `deployment.yaml` and other files will have no namespace. ie, it is not configured here: https://github.com/deliveryhero/helm-charts/blob/0b420820e3f88d5e7f9f10ddd1c9a029adb9a422/stable/kube-downscaler/templates/deployment.yaml#L3 Fix is as below: ```yaml apiVersion: apps/v1 kind: Deployment metadata: name: "{{ $fullname }}-{{ .name }}" namespace: {{ .Release.Namespace }} ``` * Bump version for change * Regenerate docs * Regenerate docs --- README.md | 2 +- stable/kube-downscaler/Chart.yaml | 2 +- stable/kube-downscaler/README.md | 2 +- stable/kube-downscaler/templates/cronjob.yaml | 1 + stable/kube-downscaler/templates/deployment.yaml | 1 + stable/kube-downscaler/templates/serviceaccount.yaml | 1 + 6 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 356fc482..bf125ad4 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ Follow these steps: 1. Fork this repo 2. Make desired changes to the chart 3. Bump the chart version -4. Regenerate the chart `README.md`: `docker run --rm -v "${PWD}:/helm-docs" jnorwood/helm-docs:v1.11.3 --template-files ./ci/README.md.gotmpl` +4. Regenerate the chart `README.md`. Run from the repo root: `docker run --rm -v "${PWD}:/helm-docs" jnorwood/helm-docs:v1.11.3 --template-files ./ci/README.md.gotmpl` 5. Commit and push changes 6. Open 1 pull request per chart you want to change 7. Set pull request title to `[stable/]: ` diff --git a/stable/kube-downscaler/Chart.yaml b/stable/kube-downscaler/Chart.yaml index 5b90469f..260ecc36 100644 --- a/stable/kube-downscaler/Chart.yaml +++ b/stable/kube-downscaler/Chart.yaml @@ -1,6 +1,6 @@ name: kube-downscaler apiVersion: v1 -version: "0.7.4" +version: "0.7.5" appVersion: 23.2.0-6-gc9b88e8 description: Scale down Kubernetes deployments after work hours keywords: diff --git a/stable/kube-downscaler/README.md b/stable/kube-downscaler/README.md index 0525e60b..6b9842db 100644 --- a/stable/kube-downscaler/README.md +++ b/stable/kube-downscaler/README.md @@ -1,6 +1,6 @@ # kube-downscaler -![Version: 0.7.4](https://img.shields.io/badge/Version-0.7.4-informational?style=flat-square) ![AppVersion: 23.2.0-6-gc9b88e8](https://img.shields.io/badge/AppVersion-23.2.0--6--gc9b88e8-informational?style=flat-square) +![Version: 0.7.5](https://img.shields.io/badge/Version-0.7.5-informational?style=flat-square) ![AppVersion: 23.2.0-6-gc9b88e8](https://img.shields.io/badge/AppVersion-23.2.0--6--gc9b88e8-informational?style=flat-square) Scale down Kubernetes deployments after work hours diff --git a/stable/kube-downscaler/templates/cronjob.yaml b/stable/kube-downscaler/templates/cronjob.yaml index 2bf798b5..d9fe4a89 100644 --- a/stable/kube-downscaler/templates/cronjob.yaml +++ b/stable/kube-downscaler/templates/cronjob.yaml @@ -3,6 +3,7 @@ apiVersion: {{ template "batch.apiVersion" . }} kind: CronJob metadata: name: {{ template "kube-downscaler.fullname" . }}-de-annotate + namespace: {{ .Release.Namespace }} labels: {{ include "kube-downscaler.labels" . | indent 4 }} {{- if .Values.extraLabels }} diff --git a/stable/kube-downscaler/templates/deployment.yaml b/stable/kube-downscaler/templates/deployment.yaml index e4e8eea0..488e3a0a 100644 --- a/stable/kube-downscaler/templates/deployment.yaml +++ b/stable/kube-downscaler/templates/deployment.yaml @@ -2,6 +2,7 @@ apiVersion: apps/v1 kind: Deployment metadata: name: {{ template "kube-downscaler.fullname" . }} + namespace: {{ .Release.Namespace }} labels: {{ include "kube-downscaler.labels" . | indent 4 }} {{- if .Values.extraLabels }} diff --git a/stable/kube-downscaler/templates/serviceaccount.yaml b/stable/kube-downscaler/templates/serviceaccount.yaml index 5dcacd0f..b9a14a4f 100644 --- a/stable/kube-downscaler/templates/serviceaccount.yaml +++ b/stable/kube-downscaler/templates/serviceaccount.yaml @@ -6,4 +6,5 @@ metadata: labels: {{ include "kube-downscaler.labels" . | indent 4 }} name: {{ template "kube-downscaler.fullname" . }} + namespace: {{ .Release.Namespace }} {{- end -}}