본문 바로가기
cloud/k8s(문제풀이)

[따배쿠29]Kube-DNS

by mozi2 2022. 9. 1.
반응형
Create a nginx pod called nginx-resolver using image nginx, expose it internally with a service called nginx-resolver-service.

Test that you are able to look up the service and pod namaes from within the cluster. Use the image: busybox1.28 for dns lookup.
- Record results in /tmp/nginx.svc and /tmp/nginx.pod
- Pod: nginx-resolver created
- Service DNS Resolution recorded correctly
- Pod DNS resolution recorded correctly
k run nginx-resolver --image=nginx
k expose nginx-resolver --name=nginx-resolver --target-port=80 --port=80

1번 문제 해결 

k get pods -o wide
k get svc  -o wide

*svc IP Address 기억하기

 

2. Dns lookup 보기

# my-svc.my-namespace.svc.cluster-domain.example

 

service: nginx-resolver.defaults.svc.cluster.local

k run test --image=busybox:1.28 --rm -it --restart=Never -- /bin/sh
/ # cat /etc/resolv.conf
/ # nslookup nginx-resolver-service.defaults.svc.cluster.local
*Svc
nslookup  nginx-resolver-service.defaults.svc.cluster.local
nslookup  [svc IP] 

*Pod
nslookup [pod ip].default.pod.cluster.local

 

*추후 조금 더 쉬운 방법으로 정리할 예정 

 

https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/

 

DNS for Services and Pods

Kubernetes creates DNS records for Services and Pods. You can contact Services with consistent DNS names instead of IP addresses. Introduction Kubernetes DNS schedules a DNS Pod and Service on the cluster, and configures the kubelets to tell individual con

kubernetes.io

 

728x90
반응형