Skip to content

Commit dc4beae

Browse files
committed
feat(charts): adding extraDeploy key for additional k8s objects
This adds an `extraDeploy` key to the chart, enabling users to attach additional Kubernetes manifests to the deployment as needed Signed-off-by: Scott Crooks <[email protected]>
1 parent 1b8e765 commit dc4beae

File tree

12 files changed

+106
-2
lines changed

12 files changed

+106
-2
lines changed

charts/flagger/templates/_helpers.tpl

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,23 @@ Create the name of the service account to use
3939
{{- else -}}
4040
{{ default "default" .Values.serviceAccount.name }}
4141
{{- end -}}
42-
{{- end -}}
42+
{{- end -}}
43+
44+
{{/*
45+
Renders a value that contains template perhaps with scope if the scope is present.
46+
Usage:
47+
{{ include "flagger.render" ( dict "value" .Values.path.to.the.Value "context" $ ) }}
48+
{{ include "flagger.render" ( dict "value" .Values.path.to.the.Value "context" $ "scope" $app ) }}
49+
*/}}
50+
{{- define "flagger.render" -}}
51+
{{- $value := typeIs "string" .value | ternary .value (.value | toYaml) }}
52+
{{- if contains "{{" (toJson .value) }}
53+
{{- if .scope }}
54+
{{- tpl (cat "{{- with $.RelativeScope -}}" $value "{{- end }}") (merge (dict "RelativeScope" .scope) .context) }}
55+
{{- else }}
56+
{{- tpl $value .context }}
57+
{{- end }}
58+
{{- else }}
59+
{{- $value }}
60+
{{- end }}
61+
{{- end -}}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{{- range .Values.extraDeploy }}
2+
---
3+
{{ include "flagger.render" (dict "value" . "context" $) }}
4+
{{- end }}

charts/flagger/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,3 +207,6 @@ noCrossNamespaceRefs: false
207207
additionalVolumes: {}
208208
# - name: tmpfs
209209
# emptyDir: {}
210+
211+
# Array of extra objects to deploy with the release
212+
extraDeploy: []

charts/grafana/templates/_helpers.tpl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,22 @@ Create chart name and version as used by the chart label.
3030
{{- define "grafana.chart" -}}
3131
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
3232
{{- end -}}
33+
34+
{{/*
35+
Renders a value that contains template perhaps with scope if the scope is present.
36+
Usage:
37+
{{ include "grafana.render" ( dict "value" .Values.path.to.the.Value "context" $ ) }}
38+
{{ include "grafana.render" ( dict "value" .Values.path.to.the.Value "context" $ "scope" $app ) }}
39+
*/}}
40+
{{- define "grafana.render" -}}
41+
{{- $value := typeIs "string" .value | ternary .value (.value | toYaml) }}
42+
{{- if contains "{{" (toJson .value) }}
43+
{{- if .scope }}
44+
{{- tpl (cat "{{- with $.RelativeScope -}}" $value "{{- end }}") (merge (dict "RelativeScope" .scope) .context) }}
45+
{{- else }}
46+
{{- tpl $value .context }}
47+
{{- end }}
48+
{{- else }}
49+
{{- $value }}
50+
{{- end }}
51+
{{- end -}}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{{- range .Values.extraDeploy }}
2+
---
3+
{{ include "grafana.render" (dict "value" . "context" $) }}
4+
{{- end }}

charts/grafana/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,6 @@ url: http://prometheus:9090
3737

3838
# Weave Cloud instance token
3939
token:
40+
41+
# Array of extra objects to deploy with the release
42+
extraDeploy: []

charts/loadtester/templates/_helpers.tpl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,22 @@ Create chart name and version as used by the chart label.
3030
{{- define "loadtester.chart" -}}
3131
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
3232
{{- end -}}
33+
34+
{{/*
35+
Renders a value that contains template perhaps with scope if the scope is present.
36+
Usage:
37+
{{ include "loadtester.render" ( dict "value" .Values.path.to.the.Value "context" $ ) }}
38+
{{ include "loadtester.render" ( dict "value" .Values.path.to.the.Value "context" $ "scope" $app ) }}
39+
*/}}
40+
{{- define "loadtester.render" -}}
41+
{{- $value := typeIs "string" .value | ternary .value (.value | toYaml) }}
42+
{{- if contains "{{" (toJson .value) }}
43+
{{- if .scope }}
44+
{{- tpl (cat "{{- with $.RelativeScope -}}" $value "{{- end }}") (merge (dict "RelativeScope" .scope) .context) }}
45+
{{- else }}
46+
{{- tpl $value .context }}
47+
{{- end }}
48+
{{- else }}
49+
{{- $value }}
50+
{{- end }}
51+
{{- end -}}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{{- range .Values.extraDeploy }}
2+
---
3+
{{ include "loadtester.render" (dict "value" . "context" $) }}
4+
{{- end }}

charts/loadtester/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,6 @@ securityContext:
9494
podDisruptionBudget:
9595
enabled: false
9696
minAvailable: 1
97+
98+
# Array of extra objects to deploy with the release
99+
extraDeploy: []

charts/podinfo/templates/_helpers.tpl

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,23 @@ Create chart name suffix.
4040
{{- else -}}
4141
{{- "" -}}
4242
{{- end -}}
43-
{{- end -}}
43+
{{- end -}}
44+
45+
{{/*
46+
Renders a value that contains template perhaps with scope if the scope is present.
47+
Usage:
48+
{{ include "podinfo.render" ( dict "value" .Values.path.to.the.Value "context" $ ) }}
49+
{{ include "podinfo.render" ( dict "value" .Values.path.to.the.Value "context" $ "scope" $app ) }}
50+
*/}}
51+
{{- define "podinfo.render" -}}
52+
{{- $value := typeIs "string" .value | ternary .value (.value | toYaml) }}
53+
{{- if contains "{{" (toJson .value) }}
54+
{{- if .scope }}
55+
{{- tpl (cat "{{- with $.RelativeScope -}}" $value "{{- end }}") (merge (dict "RelativeScope" .scope) .context) }}
56+
{{- else }}
57+
{{- tpl $value .context }}
58+
{{- end }}
59+
{{- else }}
60+
{{- $value }}
61+
{{- end }}
62+
{{- end -}}

0 commit comments

Comments
 (0)