3

on GKE I created some pods and a headless service. The headless service has a selector and I am expecting the endpoint to get the IP of the Pod that matches the selector.

However the endpoint remains empty

$ kubectl get pods -lservice=front-end
NAME                         READY     STATUS    RESTARTS   AGE
front-end-1567472915-tei91   1/1       Running   0          12m
$ kubectl get svc -lapp=sockshop
NAME        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
front-end   None         <none>                  11m
$ kubectl get endpoints -lapp=sockshop
NAME        ENDPOINTS   AGE
front-end   <none>      11m
$ more svc.yaml 
apiVersion: v1
kind: Service
metadata:
  labels:
    app: sockshop
  name: front-end
spec:
  clusterIP: None
  ports: null
  selector:
    service: front-end

I would expect an endpoint to get the IP of the Pod so that the DNS registration works.

1
  • I think you need to modify your svc.yaml to include a selector that applies directly to the pods. E.g., if your pods have labels app: sockshop, you should use that as a selector.
    – Yu-Ju Hong
    Commented Sep 13, 2016 at 22:05

1 Answer 1

3

if ports is set to null the endpoint will not get populated.

You need to add a port (even a dummy one) for the endpoint to get populated with the PodIPs of the Pods that match the selector.

ports: - port: 1234 protocol: TCP targetPort: 1234

3
  • 1
    That sounds like a bug. I think headless services should not need ports. I will file it
    – Tim Hockin
    Commented Sep 15, 2016 at 14:50
  • I've also been wondering why and came up to the same conclusion that a dummy port must be declared. Commented Sep 16, 2016 at 10:09
  • there is a PR pending that fixes it github.com/kubernetes/kubernetes/pull/32875 Commented Sep 16, 2016 at 20:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.