简体   繁体   中英

Kubernetes can not get its own cluster IP

I have 3 kubernetes services which are:

service 1:

name: abc

service 2:

name: def

service 3:

name: hgk

In application running on service 1, I successfully use environment variables to get cluster IP of other services.

System.getenv(DEF_SERVICE_HOST); --> success
System.getenv(HGK_SERVICE_HOST); --> success

However, when I call the service 1 's environemnet, it return null

System.get(ABC_SERVICE_HOST); ---> null 

Looks like it can not get its own cluster IP.

Do you guys have any ideas? Thank you very much!

The only service environment variables that are populated in a pod are the services that existed before the pod created. Environment variables are not injected into running pods once they've already been started.

I'm guessing that you created the abc replication controller / pods before you created the abc service. If you kill the existing pods and let them be recreated, they should have the ABC_SERVICE_HOST environment variable set.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM