CKA (Certified Kubernetes Administrator)/Kode Kloud

07. Networking - CoreDNS in Kubernetes

seulseul 2022. 2. 3. 13:42
07. Networking

01. Explore Environment
02. CNI weave
03. Deploy Network Solution
04. Networking Weave
05. Service Networking
06. CoreDNS in Kubernetes
07. CKA – Ingress Networking – 1
08. CKA – Ingress Networking – 2
 
 
01.
 
ask : coreDNS
 
root@controlplane:~# k describe deployment.apps/coredns -n kube-system
Name:                   coredns
Namespace:              kube-system
CreationTimestamp:      Thu, 03 Feb 2022 01:55:46 +0000
Labels:                 k8s-app=kube-dns
Annotations:            deployment.kubernetes.io/revision: 1
Selector:               k8s-app=kube-dns
Replicas:               2 desired | 2 updated | 2 total | 2 available | 0 unavailable
StrategyType:           RollingUpdate
MinReadySeconds:        0
RollingUpdateStrategy:  1 max unavailable, 25% max surge
Pod Template:

02. How many pods of the DNS server are deployed?

ask :) 2

 

NAME                      READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/coredns   2/2     2            2           13m

 

03.  What is the name of the service created for accessing CoreDNS?

 ask : kube-dns

 

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

 

04. What is the IP of the CoreDNS server that should be configured on PODs to resolve services?

서비스를 해결하기 위해 POD에서 구성해야 하는 CoreDNS 서버의 IP는 무엇입니까?

 

ask : 10.96.0.10

 

service 의 클러스터 ip 가 10.96.0.10 이었음.

 

05. Where is the configuration file located for configuring the CoreDNS service?

 

ask : /etc/coredns/Corefile

 

root@controlplane:~# k describe deployment.apps/coredns -n kube-system
Name:                   coredns
Namespace:              kube-system
CreationTimestamp:      Thu, 03 Feb 2022 01:55:46 +0000
Labels:                 k8s-app=kube-dns
Annotations:            deployment.kubernetes.io/revision: 1
Selector:               k8s-app=kube-dns
Replicas:               2 desired | 2 updated | 2 total | 2 available | 0 unavailable
StrategyType:           RollingUpdate
MinReadySeconds:        0
RollingUpdateStrategy:  1 max unavailable, 25% max surge
Pod Template:
  Labels:           k8s-app=kube-dns
  Service Account:  coredns
  Containers:
   coredns:
    Image:       k8s.gcr.io/coredns:1.7.0
    Ports:       53/UDP, 53/TCP, 9153/TCP
    Host Ports:  0/UDP, 0/TCP, 0/TCP
    Args:
      -conf
      /etc/coredns/Corefile
    Limits:
      memory:  170Mi
    Requests:
      cpu:        100m
      memory:     70Mi
    Liveness:     http-get http://:8080/health delay=60s timeout=5s period=10s #success=1 #failure=5
    Readiness:    http-get http://:8181/ready delay=0s timeout=1s period=10s #success=1 #failure=3
    Environment:  <none>
    Mounts:
      /etc/coredns from config-volume (ro)
  Volumes:
   config-volume:
    Type:               ConfigMap (a volume populated by a ConfigMap)
    Name:               coredns
    Optional:           false
  Priority Class Name:  system-cluster-critical
Conditions:
  Type           Status  Reason
  ----           ------  ------
  Available      True    MinimumReplicasAvailable
  Progressing    True    NewReplicaSetAvailable
OldReplicaSets:  <none>
NewReplicaSet:   coredns-74ff55c5b (2/2 replicas created)
Events:
  Type    Reason             Age   From                   Message
  ----    ------             ----  ----                   -------
  Normal  ScalingReplicaSet  16m   deployment-controller  Scaled up replica set coredns-74ff55c5b to 2

 

06. How is the Corefile passed in to the CoreDNS POD?

Corefile은 CoreDNS POD에 어떻게 전달됩니까?

 

1) Stored on the kube master

2) pulled from git

3) Configured as a ConfigMap object

4) Corefile comes built-in with CoreDNS pod

 

root@controlplane:~# kubectl get configmap
NAME               DATA   AGE
kube-root-ca.crt   1      19m
Use the kubectl get configmap command for 

kube-system namespace and inspect the correct ConfigMap.

 

07.  What is the name of the ConfigMap object created for Corefile?

1) dns-config

2) corefile-config

3) coredns

4) kube-proxy

 

root@controlplane:~# k get cm -n kube-system
NAME                                 DATA   AGE
coredns                              1      23m
extension-apiserver-authentication   6      24m
kube-flannel-cfg                     2      23m
kube-proxy                           2      23m
kube-root-ca.crt                     1      23m
kubeadm-config                       2      23m
kubelet-config-1.20                  1      23m

 

08. What is the root domain/zone configured for this kubernetes cluster?

 

ask : cluster.local

 

networking:
  dnsDomain: cluster.local
  podSubnet: 10.244.0.0/16
  serviceSubnet: 10.96.0.0/12

 

info

09. We have deployed a set of PODs and Services in the default and payroll namespaces.

Inspect them and go to the next question.

기본 및 급여 네임스페이스에 POD 및 서비스 세트를 배포했습니다.

그것들을 조사하고 다음 질문으로 가십시오.

Ok

 

 

10. What name can be used to access the hr web server from the test Application?

You can execute a curl command on the test pod to test.

Alternatively, the test Application also has a UI.

Access it using the tab at the top of your terminal named test-app.

 

테스트 응용 프로그램에서 hr 웹 서버에 액세스하는 데 사용할 수 있는 이름은 무엇입니까?

테스트할 테스트 포드에서 curl 명령을 실행할 수 있습니다.

또는 테스트 애플리케이션에도 UI가 있습니다.

test-app이라는 터미널 상단의 탭을 사용하여 액세스하십시오.

 

1) web-service

2) test-service

3) web

4) web-service.payroll

 

11. Which of the names CANNOT be used to access the HR service from the test pod?

테스트 포드에서 HR 서비스에 액세스하는 데 사용할 수 없는 이름은 무엇입니까?

1) web-service.default

2) web-service

3) web-service.default.svc

4) web-service.default.pod

 

 

12. Which of the below name can be used to access the payroll service from the test application?

테스트 애플리케이션에서 급여 서비스에 액세스하는 데 사용할 수 있는 이름은 다음 중 무엇입니까?

 

1) web

2) web-service.default

3) web-service.payroll

4) web-service

 

root@controlplane:~# k get svc --all-namespaces
NAMESPACE     NAME           TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                  AGE
default       kubernetes     ClusterIP   10.96.0.1        <none>        443/TCP                  35m
default       test-service   NodePort    10.101.148.120   <none>        80:30080/TCP             27m
default       web-service    ClusterIP   10.111.195.66    <none>        80/TCP                   27m
kube-system   kube-dns       ClusterIP   10.96.0.10       <none>        53/UDP,53/TCP,9153/TCP   35m
payroll       web-service    ClusterIP   10.106.241.53    <none>        80/TCP                   27m

 

13. Which of the below name CANNOT be used to access the payroll service from the test application?

테스트 애플리케이션에서 급여 서비스에 액세스하는 데 사용할 수 없는 이름은 다음 중 무엇입니까?

1) web-service.payroll.svc.cluster.local

2) web-service.payroll.svc

3) web-service.payroll.svc.cluster

4) web-service.payroll

 

14. We just deployed a web server - webapp - that accesses a database mysql - server.

However the web server is failing to connect to the database server. Troubleshoot and fix the issue.

데이터베이스 mysql에 액세스하는 웹 서버(webapp)를 방금 배포했습니다.

그러나 웹 서버는 데이터베이스 서버에 연결하는 데 실패합니다. 문제를 해결하고 수정합니다.

They could be in different namespaces.

First locate the applications.

The web server interface can be seen by clicking the tab Web Server at the top of your terminal.

다른 네임스페이스에 있을 수 있습니다.

먼저 응용 프로그램을 찾습니다.

웹 서버 인터페이스는 터미널 상단의 웹 서버 탭을 클릭하여 볼 수 있습니다.


  • Web Server: webapp
  • Uses the right DB_Host name

 

mysql >> mysql.payroll

apiVersion: apps/v1
kind: Deployment
metadata:
  name: webapp
  labels:
    name: webapp
spec:
  selector:
    matchLabels:
      name: webapp
  template:
    metadata:
      labels:
        name: webapp
    spec:
      containers:
      - name: simple-webapp-mysql
        image: mmumshad/simple-webapp-mysql
        ports:
        - containerPort: 8080
        env:
          - name: DB_Host
            value: mysql.payroll
          - name: DB_User
            value: root
          - name: DB_Password
            value: paswrd

---
kind: Service
apiVersion: v1
metadata:
  name: webapp-service
spec:
  selector:
    name: webapp
  type: NodePort
  ports:
  - port: 8080
    targetPort: 8080

 

15. From the hr pod nslookup the mysql service and redirect the output to a file /root/CKA/nslookup.out

hr pod nslookup mysql 서비스에서 출력을 /root/CKA/nslookup.out 파일로 리디렉션합니다.


  • nslookup output redirected
Run the command: 

kubectl exec -it hr -- nslookup mysql.payroll > /root/CKA/nslookup.out

https://kubernetes.io/ko/docs/tasks/administer-cluster/coredns/

 

서비스 디스커버리를 위해 CoreDNS 사용하기

이 페이지는 CoreDNS 업그레이드 프로세스와 kube-dns 대신 CoreDNS를 설치하는 방법을 보여준다. 시작하기 전에 쿠버네티스 클러스터가 필요하고, kubectl 커맨드-라인 툴이 클러스터와 통신할 수 있도

kubernetes.io