Kubernetes ClusterIP vs 无头服务场景

Kubernetes ClusterIP versus headless service scenario

我了解 Kubernetes 服务 ClusterIP 和 Headless 服务的概念,但我什么时候应该使用一个而不是另一个?

常见情况是对集群内的服务使用 ClusterIP,除非您有特定原因需要另一种 Service

For headless Services, a cluster IP is not allocated, kube-proxy does not handle these Services, and there is no load balancing or proxying done by the platform for them. How DNS is automatically configured depends on whether the Service has selectors defined

headless 服务的一个具体原因可能是您使用 StatefulSet