본문 바로가기
IT 기술/k8s

[cka] Explore Environment

by Geunny 2024. 8. 7.
반응형

 

1. How many nodes are part of this cluster? Including the controlplane and worker nodes.

controlplane ~ ➜  k get nodes
NAME           STATUS   ROLES           AGE     VERSION
controlplane   Ready    control-plane   4m8s    v1.30.0
node01         Ready    <none>          3m19s   v1.30.0

 

answer : 2

 

2. What is the Internal IP address of the controlplane node in this cluster?

controlplane ~ ➜  k describe node controlplane 
Name:               controlplane
Roles:              control-plane
Labels:             beta.kubernetes.io/arch=amd64
                    beta.kubernetes.io/os=linux
                    kubernetes.io/arch=amd64
                    kubernetes.io/hostname=controlplane
                    kubernetes.io/os=linux
                    node-role.kubernetes.io/control-plane=
                    node.kubernetes.io/exclude-from-external-load-balancers=
Annotations:        flannel.alpha.coreos.com/backend-data: {"VNI":1,"VtepMAC":"02:03:d9:b9:37:b9"}
                    flannel.alpha.coreos.com/backend-type: vxlan
                    flannel.alpha.coreos.com/kube-subnet-manager: true
                    flannel.alpha.coreos.com/public-ip: 192.29.36.9
                    kubeadm.alpha.kubernetes.io/cri-socket: unix:///var/run/containerd/containerd.sock

 

answer :  192.29.36.9

 

3. What is the network interface configured for cluster connectivity on the controlplane node? node-to-node communication

controlplane ~ ➜  k get nodes -o wide
NAME           STATUS   ROLES           AGE     VERSION   INTERNAL-IP    EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION   CONTAINER-RUNTIME
controlplane   Ready    control-plane   7m6s    v1.30.0   192.29.36.9    <none>        Ubuntu 22.04.4 LTS   5.4.0-1106-gcp   containerd://1.6.26
node01         Ready    <none>          6m24s   v1.30.0   192.29.36.11   <none>        Ubuntu 22.04.4 LTS   5.4.0-1106-gcp   containerd://1.6.26

controlplane ~ ➜  ifconfig | grep 192.29.36.9
        inet 192.29.36.9  netmask 255.255.255.0  broadcast 192.29.36.255

controlplane ~ ➜  ipc | grep 192.29.36.9
-bash: ipc: command not found

controlplane ~ ✖ ip a | grep 192.29.36.9
    inet 192.29.36.9/24 brd 192.29.36.255 scope global eth0

 

answer : eth0

 

4. What is the MAC address of the interface on the controlplane node?

 

7217: eth0@if7218: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue state UP group default 
    link/ether 02:42:c0:1d:24:09 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 192.29.36.9/24 brd 192.29.36.255 scope global eth0

 

answer : 02:42:c0:1d:24:09

 

5. What is the IP address assigned to node01?

NAME           STATUS   ROLES           AGE   VERSION   INTERNAL-IP    EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION   CONTAINER-RUNTIME
node01         Ready    <none>          11m   v1.30.0   192.29.36.11   <none>        Ubuntu 22.04.4 LTS   5.4.0-1106-gcp   containerd://1.6.26

 

answer : 192.29.36.11

 

6. What is the MAC address assigned to node01?

 

controlplane ~ ✖ ssh node01

11561: eth0@if11562: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue state UP group default 
    link/ether 02:42:c0:1d:24:0b brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 192.29.36.11/24 brd 192.29.36.255 scope global eth

 

answer : 02:42:c0:1d:24:0b

 

7. We use Containerd as our container runtime. What is the interface/bridge created by Containerd on the controlplane node?

 

네트워크 확인 명령어

 

ip a

ip aip address의 약어로, 시스템의 모든 네트워크 인터페이스에 대한 IP 주소 정보를 출력합니다.

 

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 02:42:ac:11:00:02 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.2/16 brd 172.17.255.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::42:acff:fe11:2/64 scope link
       valid_lft forever preferred_lft forever

 

ip link

 

ip link는 네트워크 인터페이스의 상태 및 속성 정보를 출력합니다. 여기에는 인터페이스의 상태 (업/다운), MAC 주소, MTU, 큐 길이, 플래그 등이 포함됩니다.

 

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether 02:42:ac:11:00:02 brd ff:ff:ff:ff:ff:ff

 

 

주요 차이점

 

ip a: 네트워크 인터페이스의 IP 주소 정보 및 관련 세부 사항을 표시합니다.

IP 주소 (IPv4 및 IPv6)

네트워크 마스크

범위 (scope)

기타 IP 관련 정보

ip link: 네트워크 인터페이스의 상태 및 속성 정보를 표시합니다.

MAC 주소

인터페이스 상태 (업/다운)

MTU (Maximum Transmission Unit)

큐 길이 (qlen)

플래그 및 기타 링크 관련 정보

 

controlplane ~ ➜  ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: flannel.1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1400 qdisc noqueue state UNKNOWN mode DEFAULT group default 
    link/ether 02:03:d9:b9:37:b9 brd ff:ff:ff:ff:ff:ff
3: cni0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1400 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether 4e:37:be:f5:2b:8f brd ff:ff:ff:ff:ff:ff
4: veth0f0378f0@if2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1400 qdisc noqueue master cni0 state UP mode DEFAULT group default 
    link/ether e6:53:a2:4d:91:0f brd ff:ff:ff:ff:ff:ff link-netns cni-e8b77061-fb2a-aa82-a801-fb8cc1899ac9
5: vetha6dcdb17@if2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1400 qdisc noqueue master cni0 state UP mode DEFAULT group default 
    link/ether ea:96:3a:71:0b:82 brd ff:ff:ff:ff:ff:ff link-netns cni-d3a02887-f450-c62e-9eba-584b64af4c44
7217: eth0@if7218: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue state UP mode DEFAULT group default 
    link/ether 02:42:c0:1d:24:09 brd ff:ff:ff:ff:ff:ff link-netnsid 0
7221: eth1@if7222: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default 
    link/ether 02:42:ac:19:00:0f brd ff:ff:ff:ff:ff:ff link-netnsid 1

 

주요 인터페이스 설명

 

lo: 루프백 인터페이스로, 로컬 통신에 사용됩니다.

flannel.1: Flannel 네트워크 플러그인에서 생성된 인터페이스로, 네트워크 오버레이를 제공합니다.

cni0: CNI(Container Network Interface) 브리지로, 주로 컨테이너 네트워크를 관리합니다. Containerd가 생성한 인터페이스입니다.

veth0f0378f0, vetha6dcdb17: veth 페어로, 가상 이더넷 인터페이스입니다. 이 인터페이스들은 주로 컨테이너와 호스트 네트워크를 연결합니다.

eth0, eth1: 일반 네트워크 인터페이스로, 실제 네트워크 인터페이스입니다.

 

answer : cni0

 

8. What is the state of the interface cni0?

answer : UP

 

9. If you were to ping google from the controlplane node, which route does it take? What is the IP address of the Default Gateway?

 

controlplane ~ ➜  ip route
default via 172.25.0.1 dev eth1 
10.244.0.0/24 dev cni0 proto kernel scope link src 10.244.0.1 
10.244.1.0/24 via 10.244.1.0 dev flannel.1 onlink 
172.25.0.0/24 dev eth1 proto kernel scope link src 172.25.0.15 
192.29.36.0/24 dev eth0 proto kernel scope link src 192.29.36.9

 

default route ip 정보.

answer : 172.25.0.1

 

10. What is the port the kube-scheduler is listening on in the controlplane node?

controlplane ~ ✖ ps -ef | grep kube-sche
root        3702    3248  0 12:31 ?        00:00:07 kube-scheduler --authentication-kubeconfig=/etc/kubernetes/scheduler.conf --authorization-kubeconfig=/etc/kubernetes/scheduler.conf --bind-address=127.0.0.1 --kubeconfig=/etc/kubernetes/scheduler.conf --leader-elect=true
root       18763    8067  0 13:03 pts/0    00:00:00 grep --color=auto kube-sche

controlplane ~ ➜  netstat -palnt | grep 3702
tcp        0      0 127.0.0.1:10259         0.0.0.0:*               LISTEN      3702/kube-scheduler 
tcp        0      0 192.29.36.9:49044       192.29.36.9:6443        ESTABLISHED 3702/kube-scheduler 
tcp        0      0 192.29.36.9:49032       192.29.36.9:6443        ESTABLISHED 3702/kube-scheduler

 

answer : 10259

 

11. Notice that ETCD is listening on two ports. Which of these have more client connections established?

controlplane ~ ➜  netstat -palnt | grep etcd | grep LISTEN
tcp        0      0 127.0.0.1:2379          0.0.0.0:*               LISTEN      3811/etcd           
tcp        0      0 192.29.36.9:2379        0.0.0.0:*               LISTEN      3811/etcd           
tcp        0      0 192.29.36.9:2380        0.0.0.0:*               LISTEN      3811/etcd           
tcp        0      0 127.0.0.1:2381          0.0.0.0:*               LISTEN      3811/etcd


controlplane ~ ➜  netstat -palnt | grep 2379 | wc -l
120

controlplane ~ ➜  netstat -palnt | grep 2380 | wc -l
1

 

answer : 2379

 

12. Correct! That's because 2379 is the port of ETCD to which all control plane components connect to. 2380 is only for etcd peer-to-peer connectivity. When you have multiple controlplane nodes. In this case we don't.

'IT 기술 > k8s' 카테고리의 다른 글

[cka] Deploy Network Solution  (0) 2024.08.09
[cka] CNI  (0) 2024.08.09
[cka] Storage Class  (0) 2024.08.06
[cka] Persistent Volume Claims  (0) 2024.07.28
[cka] Network Policies  (0) 2024.07.28

댓글