diff --git a/charts/descheduler/README.md b/charts/descheduler/README.md index 05862be91..678cc7df8 100644 --- a/charts/descheduler/README.md +++ b/charts/descheduler/README.md @@ -52,6 +52,7 @@ The following table lists the configurable parameters of the _descheduler_ chart | `imagePullSecrets` | Docker repository secrets | `[]` | | `nameOverride` | String to partially override `descheduler.fullname` template (will prepend the release name) | `""` | | `fullnameOverride` | String to fully override `descheduler.fullname` template | `""` | +| `namespaceOverride` | Override the deployment namespace; defaults to .Release.Namespace | `""` | | `cronJobApiVersion` | CronJob API Group Version | `"batch/v1"` | | `schedule` | The cron schedule to run the _descheduler_ job on | `"*/2 * * * *"` | | `startingDeadlineSeconds` | If set, configure `startingDeadlineSeconds` for the _descheduler_ job | `nil` | diff --git a/charts/descheduler/templates/_helpers.tpl b/charts/descheduler/templates/_helpers.tpl index fb540d0f0..3cfa655ac 100644 --- a/charts/descheduler/templates/_helpers.tpl +++ b/charts/descheduler/templates/_helpers.tpl @@ -24,6 +24,14 @@ If release name contains chart name it will be used as a full name. {{- end -}} {{- end -}} +{{/* +Expand the namespace of the release. +Allows overriding it for multi-namespace deployments in combined charts. +*/}} +{{- define "descheduler.namespace" -}} +{{- default .Release.Namespace .Values.namespaceOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + {{/* Create chart name and version as used by the chart label. */}} diff --git a/charts/descheduler/templates/clusterrolebinding.yaml b/charts/descheduler/templates/clusterrolebinding.yaml index 6cbc62004..b6ccfade3 100644 --- a/charts/descheduler/templates/clusterrolebinding.yaml +++ b/charts/descheduler/templates/clusterrolebinding.yaml @@ -12,5 +12,5 @@ roleRef: subjects: - kind: ServiceAccount name: {{ template "descheduler.serviceAccountName" . }} - namespace: {{ .Release.Namespace }} + namespace: {{ include "descheduler.namespace" . }} {{- end -}} diff --git a/charts/descheduler/templates/configmap.yaml b/charts/descheduler/templates/configmap.yaml index ecd69cb3c..a74aef610 100644 --- a/charts/descheduler/templates/configmap.yaml +++ b/charts/descheduler/templates/configmap.yaml @@ -3,7 +3,7 @@ apiVersion: v1 kind: ConfigMap metadata: name: {{ template "descheduler.fullname" . }} - namespace: {{ .Release.Namespace }} + namespace: {{ include "descheduler.namespace" . }} labels: {{- include "descheduler.labels" . | nindent 4 }} data: diff --git a/charts/descheduler/templates/cronjob.yaml b/charts/descheduler/templates/cronjob.yaml index 9d18adf09..cbfeca75b 100644 --- a/charts/descheduler/templates/cronjob.yaml +++ b/charts/descheduler/templates/cronjob.yaml @@ -3,7 +3,7 @@ apiVersion: {{ .Values.cronJobApiVersion | default "batch/v1" }} kind: CronJob metadata: name: {{ template "descheduler.fullname" . }} - namespace: {{ .Release.Namespace }} + namespace: {{ include "descheduler.namespace" . }} labels: {{- include "descheduler.labels" . | nindent 4 }} spec: diff --git a/charts/descheduler/templates/deployment.yaml b/charts/descheduler/templates/deployment.yaml index 53d18cb66..7820a2733 100644 --- a/charts/descheduler/templates/deployment.yaml +++ b/charts/descheduler/templates/deployment.yaml @@ -3,7 +3,7 @@ apiVersion: apps/v1 kind: Deployment metadata: name: {{ template "descheduler.fullname" . }} - namespace: {{ .Release.Namespace }} + namespace: {{ include "descheduler.namespace" . }} labels: {{- include "descheduler.labels" . | nindent 4 }} spec: diff --git a/charts/descheduler/templates/service.yaml b/charts/descheduler/templates/service.yaml index 3faa5ce29..7c9a765f3 100644 --- a/charts/descheduler/templates/service.yaml +++ b/charts/descheduler/templates/service.yaml @@ -6,7 +6,7 @@ metadata: labels: {{- include "descheduler.labels" . | nindent 4 }} name: {{ template "descheduler.fullname" . }} - namespace: {{ .Release.Namespace }} + namespace: {{ include "descheduler.namespace" . }} spec: clusterIP: None {{- if .Values.service.ipFamilyPolicy }} diff --git a/charts/descheduler/templates/serviceaccount.yaml b/charts/descheduler/templates/serviceaccount.yaml index 325fb8104..7c56471d9 100644 --- a/charts/descheduler/templates/serviceaccount.yaml +++ b/charts/descheduler/templates/serviceaccount.yaml @@ -3,7 +3,7 @@ apiVersion: v1 kind: ServiceAccount metadata: name: {{ template "descheduler.serviceAccountName" . }} - namespace: {{ .Release.Namespace }} + namespace: {{ include "descheduler.namespace" . }} labels: {{- include "descheduler.labels" . | nindent 4 }} {{- if .Values.serviceAccount.annotations }} diff --git a/charts/descheduler/templates/servicemonitor.yaml b/charts/descheduler/templates/servicemonitor.yaml index 25d980468..4824069a8 100644 --- a/charts/descheduler/templates/servicemonitor.yaml +++ b/charts/descheduler/templates/servicemonitor.yaml @@ -14,7 +14,7 @@ spec: jobLabel: jobLabel namespaceSelector: matchNames: - - {{ .Release.Namespace }} + - {{ include "descheduler.namespace" . }} selector: matchLabels: {{- include "descheduler.selectorLabels" . | nindent 6 }} diff --git a/charts/descheduler/values.yaml b/charts/descheduler/values.yaml index 7013ce52f..b6b529614 100644 --- a/charts/descheduler/values.yaml +++ b/charts/descheduler/values.yaml @@ -39,6 +39,9 @@ podSecurityContext: {} nameOverride: "" fullnameOverride: "" +# -- Override the deployment namespace; defaults to .Release.Namespace +namespaceOverride: "" + # labels that'll be applied to all resources commonLabels: {}