Kuberntes DNS

查找服务端点

# kubectl get  endpoints
NAME                   ENDPOINTS                                   AGE
docker-registry        172.17.0.10:5000                            19d
kubernetes             10.0.2.41:8443                              19d
router                 10.0.2.41:1936,10.0.2.41:80,10.0.2.41:443   19d
sparkthrift-headless   172.17.0.12:1888                            7d

When you are unable to access your pods through the service, you should start by
checking and keeping in mind the following few things:

  • First, make sure you’re connecting to the service’s cluster IP from within the cluster, not from the outside.
  • Do not ping the service IP to figure out if the service is accessible (remember, the service’s cluster IP is a virtual IP and pinging it will never work).
  • If you’ve defined a readiness probe, make sure it is reporting that the pod is ready, otherwise the pod won’t be part of the service.
  • To confirm that a pod is part of the service, examine the Endpoints object with kubectl get endpoints.
  • If you’re trying to access the service through its FQDN or a part of it (for example, myservice.mynamespace.svc.cluster.local or just myservice.mynamespace) and it doesn’t work, see if you can access it using its cluster IP instead of the FQDN.
  • Check if you’re connecting to the port exposed by the service and not the target port.
  • Try connecting to the pod IP directly, to confirm your pod is actually accepting connections on the correct port.
  • If you can’t even access your app through the pod’s IP, make sure your app is not only binding to localhost.

你可能感兴趣的:(DNS,kubernetes)