I have store my env vars in aws secret manger.In CD pipeline I will read this env from secret manager and store into env.yaml once it is available in env.yaml,i want to render it to kubernetes job.yaml file. How to render env var from env.yaml to my k8s job.yaml ??
Asked
Active
Viewed 107 times
1 Answers
0
Not sure how your env.yaml
structure is however i would suggest adding the secret as the kubenetes secret.
You can mount the secret to any job running into the K8s.
If you want to parse it from one YAML to add it into the another YAML file you can use the tool Yq to parse the values.
Example:
---
maindata:
data1:
name: jack
data2:
name: reacher
run command
yq eval '.maindata.*.name' env.yaml
will output
- jack
- teacher
You can save output or write it to variable and use it.

Harsh Manvar
- 27,020
- 6
- 48
- 102
-
My env.yaml structure is same as kubernetes env key. If I use secret then still I had to render it from secret manager. can you share yq command snippet with job.yaml example. – Akshay Gopani Jul 30 '22 at 17:10
-
you already mentioned you are storing secret to env.yaml just apply it to k8s and use secret in job spec simply with name only. – Harsh Manvar Jul 30 '22 at 17:13
-
Sorry miscommunication from my side. My env vars are stored in AWS secret manager. When I run cd pipeline i will read this env from secret manager and store into env.yaml – Akshay Gopani Jul 31 '22 at 05:09
-
got that. now if you are storing it inside the env.yaml you can either parse it or apply file to k8s so it will create the secret inside k8s cluster. You can inject the secret to Job. – Harsh Manvar Jul 31 '22 at 06:08