[29] Kube-DNS

Kube-DNS란?

Kube-DNS는 도메인 이름을 IP 주소로 해석하는 역할을 한다. 이를 통해 K8s 클러스터 내부의 다른 리소스(서비스, Pod 등)를 도메인 이름을 통해 찾을 수 있다. Kube-DNS는 각 노드에 배포되며, 클러스터 내의 모든 Pod에서 사용할 수 있는 DNS 서버 역할을 수행 한.

나오는 문제 유형

❓Service and DNS Lookup 구성

Reference

docs에서 DNS 검색

DNS for Services and Pods

DNS 질의하는 법

  1. Service에 대해 질의하는 법

nslookup {service 이름}. {service namespace}.svc.cluster.local

nslookup {Cluster IP}

  1. Pod에 대해 질의하는 법

{Pod IP}. {Pod namespace}.pod.cluster.local

실습

kubectl run nginx-resolver --image=nginx 

kubectl expose pod nginx --name=nginx-resolver-service --port=80 --target-port=80

# 확인
kubectl get pod nginx-resolver -o wide
--> IP정보 확인하기

kubectl get service nginx-resolver-service

kubectl run test --image=busybox:1.28 --rm -it --restart=Never -- /bin/sh 

cat /etc/resolv.conf
--> DNS 서버 IP 확인

nslookup nginx-resolver-service.default.svc.cluster.local
nslookup {Cluster IP}
--> 두 개의 결과가 같은지 확인

nslookup {Pod IP}.default.pod.cluster.local
--> DNS 서버 IP맞는지 확인

exit

vi /tmp/nginx.svc
--> service lookup 결과 안에 결과 넣어주기

vi /tmp/nginx.pod
--> pod lookup 결과 안에 결과 넣어주기

기출문제 (31번)

Create a deployment as follows: Name: nginx-random Exposed via a service nginx-random Ensure that the service & pod are accessible via their respective DNS records.

The container(s) within any pod(s) running as a part of this deployment should use the nginx Image.

Next, use the utility nslookup to look up the DNS records of the service & pod and write the output to /opt/KUNW00601/service.dns and /opt/KUNW00601/pod.dns respectively.


Revision #1
Created 31 May 2023 00:22:26 by 와지
Updated 20 June 2023 13:20:13 by 와지