k8s with docker using env variable

12/12/2019

I’ve a docker file which runs inside side car container on K8S. Inside this docker file, I’ve got several binaries (Golang code) that execute on runtime.

In the dockerfile I’ve defined env variable that I want to access within the binary.

I mean I want to get the value of the env from the binary (Golang code), I tried it and it did not work.

Any idea why?

I’m familiar with configmap but here I need to check the env from the docker which run on my k8s deployment.

To read the env I use (this code complied to go binary)

func main() {

    fmt.Println(“K8SENV:", os.Getenv("K8SENV"))
...

inside the docker

ENV K8SENV=test123
-- Jon lib
docker
go
kubernetes

0 Answers