Kubernetes: List services and their endpoints
SafeServices with type, cluster IP, external IP, ports and selector, then the pod IPs actually behind each one.
kubectl get svc -n <namespace> -o wide && kubectl get endpointslices -n <namespace>What each part does
kubectl get svclist services (svc is the short name)-n <namespace>in this namespace; -A for all-o wideadd the SELECTOR column: the pod labels the service routes to&&then, if that workedkubectl get endpointslicesthe ready pod IPs:ports behind each service (kubectl get ep on older clusters)
Example
$ kubectl get svc -n shop -o wide
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
api ClusterIP 10.96.120.15 <none> 80/TCP 3d app=apiMy note No endpoints? The selector matches no ready pods: compare SELECTOR with kubectl get po --show-labels, and check readiness probes.
Also known as: kubectl get svc · kubectl get services · list services · service has no endpoints · kubectl get ep