I know there are many questions around this but I didn't find any with a real answer.
My helm chart have dependencies from another helm charts and I need to override their values with my .Release.Name
and .Release.Namespace
.
My requeriments.yaml
dependencies:
- name: keycloak
alias: keycloak-config
repository: https://my-repository.com/
version: 1.0.0
- name: kong
alias: kong-config
repository: https://my-repository.com/
version: 1.0.0
On my values.yaml
kong-config:
websso:
service:
fullnameOverride: "my-helm._RELEASE_NAMESPACE_.svc.cluster.local"
ckngOauth2Opts: "--data config.post_logout_redirect_uri=/_RELEASE_NAME_
--data config.logout_path=/_RELEASE_NAME_/logout"
I basically need to use {{ .Release.Name }}
where I have _RELEASE_NAME_
and {{ .Release.Namespace }}
where I have _RELEASE_NAMESPACE_
.
I already tried:
{{ .Release.Name }}
and {{ .Release.Namespace }}
$RELEASE_NAME
and $RELEASE_NAMESPACE
${RELEASE_NAME}
and ${RELEASE_NAMESPACE}
but nothing works.
Note I really need to access those values at values.yaml
. I don't have access to my dependencies code to change and set that values on that.
How can I solve this?
I solved this executing one additional command outside of my helm chart. As I have a Makefile
file for my project build process where I can run some scripts for the multiple stages of my build. And so I added this command to the deploy stage:
sed -i "s/_RELEASE_NAMESPACE_/$(NAMESPACE)/g" $(MODULE_PATH)/chart/values.yaml
This works for a build workflow in some tool. But when I want to install manually my helm chart somewhere, it can't be done and I need to change manually that value with the server value.
While it does not appear that helm, itself, can do that, helmfile can via either its integration with kustomize or with its prepare
hook. I'll show the prepare
hook because it's much shorter
releases:
- name: kong-config
chart: whatever/kong
version: 1.0.0
values:
- ./generated-values.yaml
hooks:
- events: ['prepare']
command: bash
args:
- -c
- |
printf 'websso:\n service:\n fullnameOverride: my-helm.{{`{{ .Release.Namespace }}`}}.svc.cluster.local\n' > generated-values.yaml