Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Google Cloud Platform icon

Deploying kube-dns in a Kubernetes Cluster

Pods can communicate with each other and with services via their IP addresses, once networking has been set up in a Kubernetes cluster. But it is easier to locate other pods and services by hostname, since IP addresses can change. In order to do this, the cluster requires a DNS service. In this learning activity, you will learn how to deploy *kube-dns* to a cluster in order to provide DNS service to pods.

Google Cloud Platform icon

Path Info

Clock icon Intermediate
Clock icon 1h 0m
Clock icon Sep 28, 2018

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Deploy kube-dns to the cluster.

    You can deploy kube-dns to the cluster like so:

    kubectl create -f

    Verify that the kube-dns pod starts up correctly:

    kubectl get pods -l k8s-app=kube-dns -n kube-system

    You should get output showing the kube-dns pod. It should look something like this:

    NAME                        READY     STATUS    RESTARTS   AGE
    kube-dns-598d7bf7d4-spbmj   3/3       Running   0          36s

    Make sure that 3/3 containers are ready and that the pod has a status of Running. It may take a moment for the pod to be fully up and running, so if READY is not 3/3 at first, check again after a few moments.

  2. Challenge

    Test the DNS by creating a service, and perform a DNS lookup for service from another pod using the service name

    Test the DNS by creating a service, and access the service from another pod using the service name.

    Create a simple service like so:

    kubectl run nginx --image=nginx
    kubectl expose deployment nginx --port 80

    Get a list of services:

    kubectl get svc

    You should see the nginx service listed.

    Spin up a busybox pod for testing and get the pod name:

    kubectl run busybox --image=busybox:1.28 --command -- sleep 3600
    POD_NAME=$(kubectl get pods -l run=busybox -o jsonpath="{.items[0]}")

    Perform a DNS lookup of the nginx service from within the busybox pod to verify that DNS is working:

    kubectl exec $POD_NAME -- nslookup nginx

    You should get output that looks like this:

    Address 1: kube-dns.kube-system.svc.cluster.local
    Name:      nginx
    Address 1: nginx.default.svc.cluster.local

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.

Start learning by doing today

View Plans