Resolve service name in environment variable in Kubernetes

8/5/2018

I'm really not sure what is going on and what is problem, when I pass service name in environment variable in YAML file, that service name is still string, it's not being resolved in real ip address.

Does it should work by automatically inside kubernetes, or I need to do some more config in order that service is resolved.

Example like this, new deployment:

env:
   -name: MYSQL-SERVICE
    value: my-service-name-which-should-be-resolved (also deployed on kubernetes as service)

thanks a lot for any advice!

-- Dino
kubernetes

1 Answer

8/16/2018

@MatthewLDaniel and @RyanDawson are right. In this case, environment variable could not be converted into IP address, and you should use Service name.

More details you can find in DNS for Services and Pods and Services.

-- Akar
Source: StackOverflow