Skip to content

[kube-prometheus-stack] allow extraManifests as map/list #5475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/kube-prometheus-stack/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ name: kube-prometheus-stack
sources:
- https://github.com/prometheus-community/helm-charts
- https://github.com/prometheus-operator/kube-prometheus
version: 70.3.0
version: 70.4.0
appVersion: v0.81.0
kubeVersion: ">=1.19.0-0"
home: https://github.com/prometheus-operator/kube-prometheus
Expand Down
26 changes: 26 additions & 0 deletions charts/kube-prometheus-stack/ci/03-non-defaults-values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# this file tests some non default values to increase the test coverage

commonLabels:
foo: one
bar: two

defaultRules:
additionalRuleLabels:
key: value
Expand Down Expand Up @@ -93,3 +97,25 @@ nodeExporter:
prometheus-node-exporter:
kubeRBACProxy:
enabled: true

extraObjects:
- apiVersion: v1
kind: ConfigMap
metadata:
name: test-cm
data:
plaintext: foobar
templated: '{{ print "foobar" | upper }}'
- |
apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: test-secret
labels:
{{- range $key, $value := .Values.commonLabels }}
{{ $key }}: {{ $value }}
{{- end }}
data:
plaintext: Zm9vYmFy
templated: '{{ print "foobar" | upper | b64enc }}'
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,22 @@ thanosRuler:
- path:
type: PathPrefix
value: /foo/

extraObjects:
configmap:
apiVersion: v1
kind: ConfigMap
metadata:
name: test-cm
data:
plaintext: foobar
templated: '{{ print "foobar" | upper }}'
secret: |
apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: test-secret
data:
plaintext: Zm9vYmFy
templated: '{{ print "foobar" | upper | b64enc }}'
17 changes: 14 additions & 3 deletions charts/kube-prometheus-stack/templates/extra-objects.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
{{ range .Values.extraManifests }}
{{- /* Normalize extraObjects to a list, easier to loop over */ -}}
{{- $extraObjects := .Values.extraManifests | default (list) -}}

{{- if kindIs "map" $extraObjects -}}
{{- $extraObjects = values $extraObjects -}}
{{- end -}}

{{- range $extraObjects }}
---
{{ tpl (toYaml .) $ }}
{{ end }}
{{- if kindIs "map" . }}
{{- tpl (toYaml .) $ | nindent 0 }}
{{- else if kindIs "string" . }}
{{- tpl . $ | nindent 0 }}
{{- end }}
{{- end }}
21 changes: 19 additions & 2 deletions charts/kube-prometheus-stack/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5300,12 +5300,29 @@ thanosRuler:
##
cleanPrometheusOperatorObjectNames: false

## Extra manifests to deploy as an array
extraManifests: []
## Extra manifests to deploy. Can be of type dict or list.
## If dict, keys are ignored and only values are used.
## Items contained within extraObjects can be defined as dict or string and are passed through tpl.
extraManifests: null
# - apiVersion: v1
# kind: ConfigMap
# metadata:
# labels:
# name: prometheus-extra
# data:
# extra-data: "value"
#
# can also be defined as a string, useful for templating field names
# - |
# apiVersion: v1
# kind: Secret
# type: Opaque
# metadata:
# name: super-secret
# labels:
# {{- range $key, $value := .Values.commonLabels }}
# {{ $key }}: {{ $value }}
# {{- end }}
# data:
# plaintext: Zm9vYmFy
# templated: '{{ print "foobar" | upper | b64enc }}'