I have an env file as below:
K1=s1
K2=s2
K3=s3
# many other key-value pairs I don't know about
I want to create a Kubernetes secret from K1 only
Actually, I am looking for a result that I would get if I had run kubectl create secret generic k1-secret --from-literal="K1=s1"
However
- I want to read it from a file that has many keys
- I don't want (I cannot) use imperative commands. I need to do it using a
k1-secret.yaml
file that I runkubectl create -f k1-secret.yaml
How can I do this?
A little background:
I am trying to pull github secrets and save them in a file in a GitHub action step. Then I want to have some helm chart files. In the helm's values.yaml I want to refer to the name of the secret like this:
generic_secret_keys:
K1: K1
k2: K2
....
Then in the template parts of the helm chart, I am going to have a secrets.yaml file. I am going to loop over the secrets in the values.yaml file and create them one by one. the first K1 is the key from the .env file and the second the secret name to be created. the value comes from the exported secret file.
More background: I am hoping to store the github secrets in an env file in a k=v pairs format