kubectl adding extra env variable to pod

荒凉一梦 提交于 2019-12-13 07:40:49

问题


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:


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.



来源:https://stackoverflow.com/questions/44849024/kubectl-adding-extra-env-variable-to-pod

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!