DNS not working with Kubernetes PetSet

Ok, following the examples and documentation on the Kubernetes website along with extensive research on Google, I still cannot get DNS resolution between the containers within my Pod.

I have a Service and a PetSet with 2 containers defined. When I deploy the PetSet and Service, they start and run successfully, but if I attempt to ping the host of one of my containers from the other by hostname or by the full domain name I get destination unreachable. I can ping by IP address though.

  • WordPress causing Docker to crash
  • Is this possible to tag latest to multiple images in docker?
  • Docker Node JS Installation
  • Dockerfile automatically run passenger start with Rails
  • Connecting docker-machine to Azure using the generic driver
  • Kitchen login failed :Could not resolve host name
  • Here is my Kubernetes configuration file:

    apiVersion: v1
    kind: Service
    metadata:
      name: ml-service
      labels:
        app: marklogic
      annotations:
        service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
    spec:
      #restartPolicy: OnFailure
      clusterIP: None
      selector:
        app: marklogic
      ports:
        - protocol: TCP
          port: 7997
          #nodePort: 31997
          name: ml7997
        - protocol: TCP
          port: 8000
          #nodePort: 32000
          name: ml8000
        # ... More ports defined
      #type: NodePort
    
    ---
    apiVersion: apps/v1alpha1
    kind: PetSet
    metadata:
      name: marklogic
    spec:
      serviceName: "ml-service"
      replicas: 2
      template:
        metadata:
          labels:
            app: marklogic
          annotations:
            pod.alpha.kubernetes.io/initialized: "true"
        spec:
          terminationGracePeriodSeconds: 30
          containers:
            - name: 'marklogic'
              image: "{local docker registry ip}:5000/dcgs-sof/ml8-docker-final:v1"
              imagePullPolicy: Always
              command: ["/opt/entry-point.sh", "-l", "/opt/mlconfig.sh"]
              ports:
                - containerPort: 7997
                  name: ml7997
                - containerPort: 8000
                  name: ml8000
                - containerPort: 8001
                  name: ml8001
                - containerPort: 8002
                  name: ml8002
                - containerPort: 8040
                  name: ml8040
                - containerPort: 8041
                  name: ml8041
                - containerPort: 8042
                  name: ml8042
                - containerPort: 8050
                  name: ml8050
                - containerPort: 8051
                  name: ml8051
                - containerPort: 8060
                  name: ml8060
              env:
                - name: POD_IP
                  valueFrom:
                    fieldRef:
                      fieldPath: status.podIP
              lifecycle:
                preStop:
                  exec:
                    command: ["/etc/init.d/MarkLogic stop"]
              volumeMounts:
                - name: ml-data
                  mountPath: /data
      volumeClaimTemplates:
        - metadata:
            name: ml-data
            annotations:
              volume.alpha.kubernetes.io/storage-class: anything
          spec:
            accessModes: [ "ReadWriteOnce" ]
            resources:
              requests:
                storage: 1Gi
    

    I commented out the type: NodePort definition as I thought that might be the culprit, but still no success.

    Additionally, if I run docker@minikube:/$ docker exec b4d21c4bc065 /bin/bash -c 'nslookup marklogic-1.marklogic.default.svc.cluster.local' it cannot resolve the name.

    What am I missing???

  • Running installer within docker file without user interaction
  • Is it ok to run docker from inside docker?
  • mysql container linking to only one containers
  • Cannot detect Linux distribution or it’s unsupported
  • Mounting local volumes to docker container
  • Consul and registrator to single host, it's possible?
  • One Solution collect form web for “DNS not working with Kubernetes PetSet”

    You are resolving the wrong domain name.
    See http://kubernetes.io/docs/user-guide/petset/#network-identity

    You should try to resolve:

    marklogic-0.ml-service.default.svc.cluster.local

    If everything is within the default namespace, the DNS name is:

    <pod_name>.<svc_name>.default.svc.cluster.local

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.