kubectl adding extra env variable to pod

2019-08-16 06:36发布

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!

1条回答
迷人小祖宗
2楼-- · 2019-08-16 07:03

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.

查看更多
登录 后发表回答