From 29dec5b53cbe9ca48787b800d0303c0a29b60e90 Mon Sep 17 00:00:00 2001 From: Vincent Marguerie <24724195+vincentmrg@users.noreply.github.com> Date: Mon, 22 Apr 2024 14:56:15 +0200 Subject: [PATCH] Extra objects templating (#284) * Template priorityexpander values * Add extraObjects values * Upgrade helm chart to 3.0.0 --- helm/kubestitute/Chart.yaml | 2 +- helm/kubestitute/README.md | 3 ++- helm/kubestitute/templates/_helpers.tpl | 11 +++++++++++ helm/kubestitute/templates/extraObjects.yaml | 4 ++++ helm/kubestitute/templates/priorityexpander.yaml | 2 +- helm/kubestitute/values.yaml | 3 +++ 6 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 helm/kubestitute/templates/extraObjects.yaml diff --git a/helm/kubestitute/Chart.yaml b/helm/kubestitute/Chart.yaml index df697d0..cdf450e 100644 --- a/helm/kubestitute/Chart.yaml +++ b/helm/kubestitute/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v2 name: kubestitute type: application -version: 2.3.0 +version: 3.0.0 appVersion: "2.2.0" description: Kubestitute is an event based instances lifecycle manager for Kubernetes. home: https://github.com/quortex/kubestitute diff --git a/helm/kubestitute/README.md b/helm/kubestitute/README.md index dc7712e..fed2f49 100644 --- a/helm/kubestitute/README.md +++ b/helm/kubestitute/README.md @@ -1,6 +1,6 @@ # kubestitute -   +   Kubestitute is an event based instances lifecycle manager for Kubernetes. @@ -117,6 +117,7 @@ helm install kubestitute kubestitute/kubestitute -n kubestitute-system | serviceMonitor.interval | string | `""` | Override prometheus operator scrapping interval. | | serviceMonitor.scrapeTimeout | string | `""` | Override prometheus operator scrapping timeout. | | serviceMonitor.relabelings | list | `[]` | Relabellings to apply to samples before scraping. | +| extraObjects | list | `[]` | Extra objects to deploy (value evaluated as a template). | ## Maintainers diff --git a/helm/kubestitute/templates/_helpers.tpl b/helm/kubestitute/templates/_helpers.tpl index 4c51ce7..28bb297 100644 --- a/helm/kubestitute/templates/_helpers.tpl +++ b/helm/kubestitute/templates/_helpers.tpl @@ -51,3 +51,14 @@ app.kubernetes.io/name: {{ include "kubestitute.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} control-plane: controller-manager {{- end -}} + +{{/* +Renders a complete tree, even values that contains template. +*/}} +{{- define "kubestitute.render" -}} + {{- if typeIs "string" .value }} + {{- tpl .value .context }} + {{ else }} + {{- tpl (.value | toYaml) .context }} + {{- end }} +{{- end -}} diff --git a/helm/kubestitute/templates/extraObjects.yaml b/helm/kubestitute/templates/extraObjects.yaml new file mode 100644 index 0000000..28fe690 --- /dev/null +++ b/helm/kubestitute/templates/extraObjects.yaml @@ -0,0 +1,4 @@ +{{- range .Values.extraObjects }} +--- +{{ include "kubestitute.render" (dict "value" . "context" $) }} +{{- end }} diff --git a/helm/kubestitute/templates/priorityexpander.yaml b/helm/kubestitute/templates/priorityexpander.yaml index 2449d2e..e51ce43 100644 --- a/helm/kubestitute/templates/priorityexpander.yaml +++ b/helm/kubestitute/templates/priorityexpander.yaml @@ -6,6 +6,6 @@ metadata: name: {{ .name }} namespace: {{ .namespace }} spec: - template: {{ toYaml .template | indent 4 }} + template: {{ toYaml (tpl .template $) | indent 4 }} {{- end }} {{- end }} diff --git a/helm/kubestitute/values.yaml b/helm/kubestitute/values.yaml index 094e0fc..13e928a 100644 --- a/helm/kubestitute/values.yaml +++ b/helm/kubestitute/values.yaml @@ -148,3 +148,6 @@ serviceMonitor: scrapeTimeout: "" # -- Relabellings to apply to samples before scraping. relabelings: [] + +# -- Extra objects to deploy (value evaluated as a template). +extraObjects: []