I've created a helm chart with sub-charts.
The global helm chart contains values.yaml
and values-int.yaml
files. as well as all the sub-charts.
this is the structure:
- Global-helm-chart:
- values.yaml
- values-int.yaml
- sub-charts:
- chart-1:
- values.yaml
- value-int.yaml
- templates:
- configmap.yaml
- chart-2:
- values.yaml
- value-int.yaml
- templates:
- configmap.yaml
This is the configmap.yaml
under chart-1
(chart-2 is the same):
{{- $root := .Values -}}
{{ if eq .Values.global.env "int" }}
apiVersion: v1
kind: ConfigMap
metadata:
name: "{{ .Chart.Name }}-configuration"
data:
json: {{ $root.tickets | toJson | quote }}
{{ end }}
this is the values-int.yaml
under chart-1
:
tickets:
dynamicEvents:
topics:
- topic_name: "ai-recommendations-pending-for-review"
events:
- name: "PendingForReview"
parameters:
subject: "$.insightTypeId"
group_uid: "customer_care"
helm template .
from the global chart will print out two configMaps, where their values are taken from values.yaml
and values-int.yml
of the global chart and not as expected which is from chart-1
and chart-2
.
I expect helm template from the global-helm-chart to show the json:
in configMap with the values of values-int.yaml
under chart-1
.
Thanks in advance..
CodePudding user response:
Helm, on its own, doesn't have a notion of per-environment values files the way you're describing it. If you run
helm template . -f values-int.yaml
that reads ./values-int.yaml
in the current directory, but doesn't look for that file in any other place; in particular it does not try to look for the same-named values file in sub charts.
Instead, you need to fold all of the settings together into a single values-int.yaml
file wherever you're running the deployment from (it does not need to be in the chart directory per se). That single file includes settings for all of the sub-charts under top-level keys with the charts' names.
So, with a filesystem layout of:
global-helm-chart/
-- Chart.yaml
-- values.yaml
-- values-int.yaml
|
\-- charts/
-- chart1/
| -- Chart.yaml
| -- values.yaml
| \-- templates/
| \-- configmap.yaml
|
\-- chart2/
-- Chart.yaml
-- values.yaml
\-- templates/
\-- configmap.yaml
The top-level values-int.yaml
would contain:
# Helm values for the integration environment. These override
# settings in values.yaml in this chart and its subcharts.
global:
env: int
chart1:
tickets:
dynamicEvents: { ... }
chart2: { ... }