Communication inside the cluster

Containers in the same Pod communicate through localhost, and Pods reach services by name, by name and namespace, or by a fully qualified name.

Containers and Pods in a cluster communicate in the following ways:

  • Containers in the same Pod communicate through localhost, because they share the same network namespace.
  • Pods in the same namespace reach a service by using the service name.
  • Pods in different namespaces reach a service by using <service-name>.<namespace>, or the fully qualified name <service-name>.<namespace>.svc.cluster.local.

Kubernetes also gives each Pod a DNS name that is based on its IP address, in the format 10-244-1-12.default.pod.cluster.local. For more information about DNS for services and Pods, see DNS for Services and Pods in the Kubernetes documentation.