Search code examples
kubernetesgoogle-kubernetes-enginekubectl

Not able to perform nslookup to Kubernetes service


I am trying to do a nslookup of the Service but it always gives ** server can't find kubernetes: NXDOMAIN error.

I have already checked all the answers which suggest using a busybox image but that too is not working. Below are screenshots.

enter image description here

enter image description here

Anyone has any idea what might be wrong here?


Solution

  • The busybox image solution is still patchy, for some it works and for some it doesn't. Try creating a pod as per below spec from kubernetes.io:

    apiVersion: v1
    kind: Pod
    metadata:
      name: dnsutils
      namespace: default
    spec:
      containers:
      - name: dnsutils
        image: registry.k8s.io/e2e-test-images/jessie-dnsutils:1.3
        command:
          - sleep
          - "infinity"
        imagePullPolicy: IfNotPresent
      restartPolicy: Always
    

    And then use this command - kubectl exec -ti dnsutils -- nslookup <<Service_Name>>.