kubectl adding extra env variable to pod

6/30/2017

Ok here is the story:

I am using minikube to host my application:

1 pod running redis (redis on ubuntu:14.04)

1 pod running my php application (php7-apache)

I realised that if I setup my redis pod first then my php pod, my php pod will have these extra env variables:

REDIS_SERVICE_PORT=6379
REDIS_PORT_6379_TCP_ADDR=10.0.0.229
REDIS_PORT_6379_TCP_PORT=6379
REDIS_PORT_6379_TCP=tcp://10.0.0.229:6379
REDIS_PORT=tcp://10.0.0.229:6379
REDIS_SERVICE_HOST=10.0.0.229

These variables override the port I setup for my php project.

To counter it, I have to explicitly set the REDIS_PORT in my yaml file for my php deployment.

Any idea why this happened? And clean way to simply avoid this?

Thanks!

-- Chen Sturmweizen
kubectl
kubernetes
minikube
redis

1 Answer

7/1/2017

Ooooook, got the answer.

Credits to @aschepis.

For some mysterious reason, if I name my deployment to be exactly "redis" in the redis pod, the env variables will be injected to other pods who comes later.

As long as I renamed the deployment to another name, things went back to normal...

Thanks again to @aschepis.

-- Chen Sturmweizen
Source: StackOverflow