origin: DNS: Problem resolving services between pods.

Hi,

when following tutorial to create statefulset with headless service nginx: https://kubernetes.io/docs/tutorials/stateful-application/basic-stateful-set/ with slightly edited web.yaml as shown:

---
apiVersion: v1
kind: Service
metadata:
  name: nginx
  labels:
    app: nginx
spec:
  ports:
  - port: 8080
    name: web
  clusterIP: None
  selector:
    app: nginx
---
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
  name: web
spec:
  serviceName: "nginx"
  replicas: 3
  template:
    metadata:
      labels:
        app: nginx
    spec:
      terminationGracePeriodSeconds: 10
      containers:
      - name: nginx
        image: gcr.io/google_containers/nginx-slim:0.8
        ports:
        - containerPort: 8080
          name: web

I bumped into problem with resolving other pods.

Version
# oc version
oc v1.4.1
kubernetes v1.4.0+776c994
features: Basic-Auth GSSAPI Kerberos SPNEGO

Server https://192.168.122.254:8443
openshift v1.5.0-alpha.3+cf7e336
kubernetes v1.5.2+43a9be4
Steps To Reproduce
  1. oc cluster up --host-data-dir /var/lib/origin-data --use-existing-config --public-hostname=$(hostname) --version=v1.5.0-alpha.3
  2. oc new project web
  3. oc create -f web.yaml
Current Result
# oc get pods
NAME      READY     STATUS    RESTARTS   AGE
web-0     1/1       Running   0          1m
web-1     1/1       Running   0          1m
web-2     1/1       Running   0          1m
# oc rsh  web-0 bash
bash-4.3$ echo $HOSTNAME
web-0
bash-4.3$ curl web-0
curl: (7) Failed to connect to web-0 port 80: Connection refused
bash-4.3$ curl web-1
curl: (6) Could not resolve host: web-1
bash-4.3$ cat /etc/resolv.conf 
search web.svc.cluster.local svc.cluster.local cluster.local
nameserver 192.168.122.254
options ndots:5
Expected Result

Resolved host web-1.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 18 (13 by maintainers)

Most upvoted comments

@bparees IIUC you aren’t testing exactly the same thing. You’ve checked the service’s DNS name which works fine for me too (same for the OP I guess).

What isn’t working is the DNS resolution for the individual endpoint names of the StatefulSet resource (eg example-0.example in my setup). To be fair, the OpenShift documentation doesn’t mention this capability while the Kubernetes documentation does.