-
Note I am sorry if I am asking something that has already been asked. I was not able to find the information. I am creating a homelab where I want some of the default values to be dynamic. Can environment variables be read in Kustomization patches? I am thinking something like this: # The Kustomization file
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base/gitops-dashboard
patches:
- path: patches/gitops-dashboard-values.yaml
target:
kind: HelmRelease
name: gitops-dashboard # The patch file
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
name: gitops-dashboard
namespace: flux-system
spec:
values:
adminUser:
username: admin
passwordHash: $2a$12$6twAYNqxU3Pz3PqVYTJN9uE5LaMDj3R1.TgLvalUoKeLnzKsFkK3i
ingress:
hosts:
- host: gitops.${DOMAIN} # This where/how I would like to use an environment variable if at all possible.
paths:
- path: /
pathType: ImplementationSpecific If this is not possible in any way, what do you recommend as the best practice to accomplish this? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
You can't feed environment variables into Kustomizations (how would kustomization-controller get them?) but you can use post-build substitutions: https://fluxcd.io/flux/components/kustomize/kustomization/#post-build-variable-substitution. This lets you either create multiple Kustomizations with pre-defined |
Beta Was this translation helpful? Give feedback.
-
can I also add conditions to post build as well ? if env is test then the value of susbstitute is different.. |
Beta Was this translation helpful? Give feedback.
You can't feed environment variables into Kustomizations (how would kustomization-controller get them?) but you can use post-build substitutions: https://fluxcd.io/flux/components/kustomize/kustomization/#post-build-variable-substitution. This lets you either create multiple Kustomizations with pre-defined
.spec.postBuild.substitute
values or use a single Kustomization with.spec.postBuild.substituteFrom
and create ConfigMaps for each environment.