I am trying to pass a value using the --set
in helm3
. However, it looks like the yaml file is not pulling/parsing the value.
My folder structure is like below: (there are a few other charts but I have removed them for simplicity)
k8shelmcharts
├── Chart.yaml
└── charts
├── postgresdb
│ ├── Chart.yaml
│ ├── templates
│ │ ├── postgres.configmap.yml
│ │ ├── postgres.deployment.yml
│ │ ├── postgres.secrets.yml
│ │ └── postgres.service.yml
│ └── values.yaml
and the contents of the postgres.secrest.yml
file is:
apiVersion: v1
kind: Secret
metadata:
name: postgres-secret
type: Opaque
data:
# property-like keys; each key maps to a simple value
password: {{ .Values.password }}
( I have also tried .Values.global.password
)
When I try to install the charts by running the command (from the root of the helm charts ie: k8shelmcharts
folder) helm install testapp . --set password=postgrespasssword --debug --dry-run
I get the error:
Error: unable to build kubernetes objects from release manifest: error validating "": error validating data: unknown object type "nil" in Secret.data.password
helm.go:94: [debug] error validating "": error validating data: unknown object type "nil" in Secret.data.password
If I try to generate the templates using helm template testflaskapp . --set password=postgrespassword --debug --dry-run
, I can see that the password does not seem to get populated in the postgres.secret.yml
file -
# Source: flask-k8s-app/charts/postgresdb/templates/postgres.secret.yml
apiVersion: v1
kind: Secret
metadata:
name: postgres-secret
data:
# property-like keys; each key maps to a simple value
password:
Any help on what I am missing so that I can --set
values and pull them in the yaml files successfully? Thanks!
Option 1:
helm install testapp . --set postgresdb.password=postgrespasssword --debug --dry-run
The variable should be called postgresdb.password
, in the postgres.secrets.yml should stay {{ .Values.password }}
.
Option 2
helm install testapp . --set global.password=postgrespasssword --debug --dry-run
The variable should be called global.password
, postgres.secrets.yml should be changed to {{ .Values.global.password }}
.
The first option is the preferable one I guess, as probably you are using the postgress password only in the postgresdb
subchart.
Reference: Subcharts and Global Values