1 minute read

بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم

Deploying the DNS Cluster Add-on (Kubernetes The Hardway)

Lanjutkeunn, Lab FinalPart 9 In this lab you will deploy the DNS add-on which provides DNS based service discovery, backed by CoreDNS, to applications running inside the Kubernetes cluster.

The DNS Cluster Add-on

Deploy the coredns cluster add-on:

kubectl apply -f https://storage.googleapis.com/kubernetes-the-hard-way/coredns.yaml

output

serviceaccount/coredns created
clusterrole.rbac.authorization.k8s.io/system:coredns created
clusterrolebinding.rbac.authorization.k8s.io/system:coredns created
configmap/coredns created
deployment.extensions/coredns created
service/kube-dns created

cek namespaces system,

kubectl -n kube-system get all

Output

NAME                           READY   STATUS    RESTARTS   AGE
pod/coredns-788cdf8b7b-dxpxp   1/1     Running   0          46s
pod/coredns-788cdf8b7b-fbfd6   1/1     Running   0          46s

NAME               TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)                  AGE
service/kube-dns   ClusterIP   10.32.0.10   <none>        53/UDP,53/TCP,9153/TCP   46s

NAME                      DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/coredns   2         2         2            0           46s

NAME                                 DESIRED   CURRENT   READY   AGE
replicaset.apps/coredns-788cdf8b7b   2         2         0       46s

Verification

Create a busybox deployment:

kubectl run busybox --image=busybox:1.28 --command -- sleep 3600

List the pod created by the busybox deployment:

kubectl get pods -l run=busybox

output

NAME                      READY   STATUS    RESTARTS   AGE
busybox-bd8fb7cbd-vflm9   1/1     Running   0          10s

Retrieve the full name of the busybox pod:

POD_NAME=$(kubectl get pods -l run=busybox -o jsonpath="{.items[0].metadata.name}")

Execute a DNS lookup for the kubernetes service inside the busybox pod:

kubectl exec -ti $POD_NAME -- nslookup kubernetes

output

Server:    10.32.0.10
Address 1: 10.32.0.10 kube-dns.kube-system.svc.cluster.local

Name:      kubernetes
Address 1: 10.32.0.1 kubernetes.default.svc.cluster.local

Lanjutnye: SMOKE-TEST

Gaskunnnn

Referensi

Happy, Enjoy Ngoprek ~

Comments