Issue
How do I override environment variables in a .env file for Go with Helm?
With C# I do the following:
In appsettings.json
:
{
"Animals":{
"Pig": "Squeek"
},
}
In values.yaml
:
animals:
pig: "Oink"
In configmap.yaml
:
apiVersion: v1
kind: ConfigMap
metadata:
name: animal-configmap
pig: {{ .Values.animals.pig }}
And finally in deployment.yaml
:
spec:
...
template:
...
spec:
...
containers:
...
env:
- name: Animals__Pig
valueFrom:
configMapKeyRef:
name: animal-configmap
key: pig
Not the double __
.
How would one go about updating an environment value for Go?
Here is the Go .env
file example:
PIG=SQUEEK
Solution
If your Go code is retrieving an ordinary environment variable
pig := os.Getenv("PIG")
then the Kubernetes manifest should use that name as the environment variable name:
env:
- name: PIG
valueFrom: {...}
The double-underscore doesn't have any special meaning in Unix environment variables or the Kubernetes manifest, in your initial example it looks like the way the C# framework separates components when it maps environment variables to application properties. If you're using environment variables directly you don't need to do anything special.
Answered By - David Maze Answer Checked By - Marilyn (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.