반응형
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
반응형
'cloud > k8s(문제풀이)' 카테고리의 다른 글
[따배쿠 CKA]30.Network Policy (0) | 2022.09.01 |
---|---|
[cka] Mock exam-1 (0) | 2022.08.19 |
[따배쿠 CKA]28. ServiceAccount Cluster Role binding (0) | 2022.08.17 |
[따배쿠 CKA]27. ServiceAccount Role Binding (0) | 2022.08.17 |
[따배쿠 CKA] 26.User Cluster Role binding (0) | 2022.08.17 |