Skip to content

Commit

Permalink
feat!: extraResources defined as a map (previously an array)
Browse files Browse the repository at this point in the history
To allow enabling/disabling, easy override by path, customisation,...
  • Loading branch information
davidB committed Dec 18, 2024
1 parent e9732e2 commit 009fde8
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 17 deletions.
7 changes: 5 additions & 2 deletions charts/cdviz-collector/templates/extra-resources.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{{- range .Values.extraResources }}
{{- range $_, $extraResource := .Values.extraResources }}
{{- if $extraResource.enabled }}
{{- $def := unset $extraResource "enabled" }}
---
{{- tpl (toYaml .) $ }}
{{- tpl (toYaml $def) $ }}
{{- end}}
{{- end }}
7 changes: 5 additions & 2 deletions charts/cdviz-collector/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,8 @@ config: |
# Additional kubernetes resources to create. Helm template could be used.
# you could use it to create secrets, or custom resources like external secrets,
# configmaps, gateways,...
extraResources: []
# configmaps, gateways, volumes, keda, ...
# - the name/key of the resource is used just to access the definition more easily than an arrays's index
# - the 'enabled' field is used to enable/disable the resource (removed when the resource is templated)
# - user can add any other resource definition as child node of extraResources
extraResources: {}
7 changes: 5 additions & 2 deletions charts/cdviz-db/templates/extra-resources.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{{- range .Values.extraResources }}
{{- range $_, $extraResource := .Values.extraResources }}
{{- if $extraResource.enabled }}
{{- $def := unset $extraResource "enabled" }}
---
{{- tpl (toYaml .) $ }}
{{- tpl (toYaml $def) $ }}
{{- end}}
{{- end }}
36 changes: 33 additions & 3 deletions charts/cdviz-db/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,36 @@ env:

# Additional kubernetes resources to create. Helm template could be used.
# you could use it to create secrets, or custom resources like external secrets,
# database definitions for an operator,...
# apiVersion: postgresql.cnpg.io/v1
extraResources: []
# configmaps, gateways, volumes, keda, ...
# - the name/key of the resource is used just to access the definition more easily than an arrays's index
# - the 'enabled' field is used to enable/disable the resource (removed when the resource is templated)
# - user can add any other resource definition as child node of extraResources
extraResources:
cloudnative-pg-basic:
enabled: false
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: cdviz-db
spec:
instances: 1
storage:
size: 100Mi
monitoring:
enablePodMonitor: true
bootstrap:
initdb:
database: cdviz
owner: cdviz
secret:
name: cdviz-db-owner-secret
cdviz-db-owner-secret:
enabled: false
apiVersion: v1
kind: Secret
metadata:
name: cdviz-db-owner-secret
type: kubernetes.io/basic-auth
data:
username: '{{ "cdviz-su" b64enc }}'
password: '{{ "mysecretpassword" | b64enc }}'
7 changes: 5 additions & 2 deletions charts/cdviz-grafana/templates/extra-resources.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{{- range .Values.extraResources }}
{{- range $_, $extraResource := .Values.extraResources }}
{{- if $extraResource.enabled }}
{{- $def := unset $extraResource "enabled" }}
---
{{- tpl (toYaml .) $ }}
{{- tpl (toYaml $def) $ }}
{{- end}}
{{- end }}
12 changes: 10 additions & 2 deletions charts/cdviz-grafana/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,13 @@ dashboards:

# Additional kubernetes resources to create. Helm template could be used.
# you could use it to create secrets, or custom resources like external secrets,
# configmaps, gateways,...
extraResources: []
# configmaps, gateways, volumes, keda, ...
# - the name/key of the resource is used just to access the definition more easily than an arrays's index
# - the 'enabled' field is used to enable/disable the resource (removed when the resource is templated)
# - user can add any other resource definition as child node of extraResources
extraResources: {}
# sample:
# enabled: false
# apiVersion: v1
# kind: Secret
# ...
4 changes: 3 additions & 1 deletion demos/stack-k8s/values/cdviz-collector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ env:
key: DATABASE_URL

extraResources:
- apiVersion: v1
secrets:
enabled: true
apiVersion: v1
kind: Secret
metadata:
name: cdviz-db-collector
Expand Down
12 changes: 9 additions & 3 deletions demos/stack-k8s/values/cdviz-db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ env:
key: DATABASE_URL

extraResources:
- apiVersion: postgresql.cnpg.io/v1
postgresql:
enabled: true
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: cdviz-db
Expand All @@ -27,15 +29,19 @@ extraResources:
owner: "{{ .Values.secrets.values.CDVIZ_SU_POSTGRES_USER }}"
secret:
name: cdviz-db-owner-secret
- apiVersion: v1
cdviz-db-owner-secret:
enabled: true
apiVersion: v1
kind: Secret
metadata:
name: cdviz-db-owner-secret
type: kubernetes.io/basic-auth
data:
username: "{{ .Values.secrets.values.CDVIZ_SU_POSTGRES_USER | b64enc }}"
password: "{{ .Values.secrets.values.CDVIZ_SU_POSTGRES_PASSWORD | b64enc }}"
- apiVersion: v1
migration-secret:
enabled: true
apiVersion: v1
kind: Secret
metadata:
name: cdviz-db-su
Expand Down

0 comments on commit 009fde8

Please sign in to comment.