Reputation: 71
I have two helm charts, I need to generate a random password in one of the charts, and I am required to use the same password in the second.
What would be the best practice to achieve this?
Thanks in advance!!
Upvotes: 3
Views: 1295
Reputation: 142532
You have several options to achieve this requirement.
If you are using Helm you can deploy resources to the same Namespace and store the password in a configMap
or in Secret
.
The ConfigMap
/ Secret
will be generated dynamically during the creation or deployment of the chart
Another solution might be to use Helm Dependency. Helm dependency allows you to build up the charts with dependencies between each other so you can pass information between them.
Use kubectl kustomization
to generate the ConfigMap
/ Secret
and share them between the charts. The best approach is to use kustomisation
hierarchy which will allow you to share the content.
For example:
# Generate random number and store it inside `ConfigMap`
echo $RANDOM > .env
# reference: [https://github.com/nirgeier/KubernetesLabs/tree/master/Labs/08-Kustomization/samples/03-generators/ConfigMap/01-FromEnv]
# kustomization.yaml for ConfigMap
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
configMapGenerator:
# Generate config file from the env file which you
# created in teh previous step
- name: configMapFromEnv
env: .env
Upvotes: 1
Reputation: 5645
Generate the password in a known secret name then refer to that secret in the other chart?
Upvotes: 2