Discovering Services
Explore how Kubernetes Services enable Pod discovery through environment variables and DNS. Understand how service names resolve to IPs, facilitating connection and load balancing in your cluster.
Discovering Services using DNS and environment variables
Services can be discovered through two principal modes:
- Environment variables
- DNS
Every Pod gets environment variables for each of the active Services. They are provided in the same format as what Docker links expect, as well as with the simpler Kubernetes-specific syntax.
Let's get environment variables for go-demo-2-db :
The output is limited to the environment variables related to the go-demo-2-db Service. It is as follows:
The first five variables use the Docker format. If you have already worked with Docker networking, you must be familiar with the way Swarm (standalone) and Docker Compose operate. The later ...