Kwoo'S Blog - IT는 어렵다.
CKA - Networking -1 본문
KodeKloud - CKA - Network 정리
Explore Environment
How many nodes are part of this cluster?
kubectl get nodes
What is the Internal IP address of the controlplane node in this cluster?
kubectl get nodes -o wide
- 클러스터를 구성하는 controlplane IP 주소는 그냥 -o wide 옵션으로 확인
What is the network interface configured for cluster connectivity on the controlplane node?
kubectl get nodes -o wide
ip addr
- 네트워크 인터페이스는 ip 관련 명령어로 확인
What is the MAC address of the interface on the controlplane node?
9463: eth0@if9464: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue state UP group default
link/ether 02:42:0a:22:16:03 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 10.34.22.3/24 brd 10.34.22.255 scope global eth0
valid_lft forever preferred_lft forever
- 조회 했을 떄 네트워크 인터페이스 하위 정보 보고 맥 어드레스 확인
What is the IP address assigned to node01?
(위와 동일)
What is the MAC address assigned to node01?
(위와 동일)
We use Containerd as our container runtime. What is the interface/bridge created by Containerd on this host?
컨테이너 런타임으로 containerd를 사용했는데 이 호스트에서 Containerd가 생성한 인터페이스/브리지는 뭔지
ip link
3: cni0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1400 qdisc noqueue state UP mode DEFAULT group default qlen 1000
link/ether d6:74:a8:ae:7d:e3 brd ff:ff:ff:ff:ff:ff
- ip link 로 조회 -> cni0 확인
What is the state of the interface cni0?
UP
If you were to ping google from the controlplane node, which route does it take?
음 번역하자면 컨트롤 플레인 노드에서 구글에 핑 날렸을때 어떤 경로를 타는지?
ip route show default
default via 172.25.1.1 dev eth1
What is the port the kube-scheduler is listening on in the controlplane node?
컨트롤플레인 노드에서 kube-scheduler 가 listening 중인 포트는 뭔지 (netstat 사용)
netstat -nplt
tcp 0 0 127.0.0.1:10259 0.0.0.0:* LISTEN 1728/kube-schedule
Notice that ETCD is listening on two ports. Which of these have more client connections established?
ETCD가 두개의 포트를 사용하는데 더 많은 클라이언트 연결 이 설정된 포트 알아보기
netstat -anp | grep etcd
netstat -anp | grep etcd | grep 2380 | wc -l
netstat -anp | grep etcd | grep 2379 | wc -l
- 정답은 개수까지 다 파이프로 얻어내는데 제일 먼저 netstat -anp를 하면 아래와 같이 나온다.
tcp 0 0 127.0.0.1:2379 0.0.0.0:* LISTEN 1902/etcd
tcp 0 0 10.34.22.3:2379 0.0.0.0:* LISTEN 1902/etcd
tcp 0 0 10.34.22.3:2380 0.0.0.0:* LISTEN 1902/etcd
tcp 0 0 127.0.0.1:2381 0.0.0.0:* LISTEN 1902/etcd
- 2379,2380 포트만 알고 있으면 된다. 클라이언트 개수가 많아서 세기 귀찮으니 파이프로 결과 도출한게 정답 명령어
여기서 알아둬야 할게 ETCD는 2379 포트는 모든 컨트롤플레인 구성 요소가 연결디는 ETCD 포트이고
2380 포트는 피어 투 피어 연결 전용이다.
CNI
Inspect the kubelet service and identify the container runtime value is set for Kubernetes.
큐블릿 검사하고 컨테이너 런타임 값 알아내보자
ps -aux | grep kubelet | grep runtime
- 큐블렛이 system으로 떠있으니 ps -aux로 식별
(쿠버네티스 설치과정 잘 생각해보면 처음 kubelet 패키지 설치 시 start까지 하는 걸 기억하면 쉬움)
root 2337 0.0 0.0 4227424 79232 ? Ssl 13:32 0:24 /usr/bin/kubelet
--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf
--kubeconfig=/etc/kubernetes/kubelet.conf
--config=/var/lib/kubelet/config.yaml
--container-runtime=remote
--container-runtime-endpoint=unix:///var/run/containerd/containerd.sock
--pod-infra-container-image=k8s.gcr.io/pause:3.7
- --container-runtime=remote 확인
What is the path configured with all binaries of CNI supported plugins?
CNI 지원 플러그인의 모든 바이너리로 구성된 경로 찾기 (그냥 외우자)
/opt/cni/bin
Identify which of the below plugins is not available in the list of available CNI plugins on this host?
이 호스트에서 사용 가능한 CNI 플러그인 목록에서 사용할 수 없는 플러그인을 식별하기
위에서 CNI 지원 플러그인의 모든 바이너리가 뭐있는지 보면 된다.
ls /opt/cni/bin
What is the CNI plugin configured to be used on this kubernetes cluster?
쿠버네티스 클러스터에 사용한 CNI Plugin는 어디에 구성되나?
ls /etc/cni/net.d/
What binary executable file will be run by kubelet after a container and its associated namespace are created.
컨테이너 및 관련 네임스페이스가 생성된 후 kubelet에서 실행되는 바이너리 실행 파일은 무엇인지
cat /etc/cni/net.d/10-flannel.conflist
- 위에서 CNI 정보가 저장된 경로에 가보면 자신의 CNI 구성 파일이 생성 되어 있음
- 해당 파일 조회하여 Type 필드 확인
{
"name": "cbr0",
"cniVersion": "0.3.1",
"plugins": [
{
"type": "flannel",
"delegate": {
"hairpinMode": true,
"isDefaultGateway": true
}
},
{
"type": "portmap",
"capabilities": {
"portMappings": true
}
}
]
}
Deploy Network Solution
In this practice test we will install weave-net POD networking solution to the cluster. Let us first inspect the setup.
현재 주어진 환경에서 weave-net 파드 네트워킹 해결할건데 setup 조사해보고 올려진 Pod가 현재 어떤 상태인지
Not Running
Inspect why the POD is not running.
No Network Configured
kubectl describe pod app
Failed to create pod sandbox: rpc error: code = Unknown desc = [failed to set up sandbox container "0d44b0fdc649b416788b5bbdb1f47fd69ac53b15f9fc213f41e10138cfef1675" network for pod "app": networkPlugin cni failed to set up pod "app_default" network: unable to allocate IP address: Post "http://127.0.0.1:6784/ip/0d44b0fdc649b416788b5bbdb1f47fd69ac53b15f9fc213f41e10138cfef1675": dial tcp 127.0.0.1:6784: connect: connection refused, failed to clean up sandbox container "0d44b0fdc649b416788b5bbdb1f47fd69ac53b15f9fc213f41e10138cfef1675" network for pod "app": networkPlugin cni failed to teardown pod "app_default" network: Delete "http://127.0.0.1:6784/ip/0d44b0fdc649b416788b5bbdb1f47fd69ac53b15f9fc213f41e10138cfef1675": dial tcp 127.0.0.1:6784: connect: connection refused]
Normal SandboxChanged 15s (x4 over 55s) kubelet Pod sandbox changed, it will be killed and re-created.
- 파드 describe로 확인해보면 딱봐도 networkPlugin cni failed to set up pod 이니 connection refused 이니 CNI 네트워크 관련 문제인걸 알수 있음.
Deploy weave-net networking solution to the cluster.
kubectl create -f weave-daemonset-k8s.yaml
- 파드가 정상적으로 running 될 수 있도록 weave cni를 배포하자
Networking Weave
How many Nodes are part of this cluster?
kubectl get nodes
What is the Networking Solution used by this cluster?
ls /etc/cni/net.d/
- 위에서 이미 한번 했지만, cni를 설치할때 해당 경로에 cni 구성이 생성된다.
How many weave agents/peers are deployed in this cluster?
kubectl get pod -n kube-system
- kube-system 네임스페이스에 weave pod가 올라간다
- 데몬셋으로 구성되어 있으므로 노드의 개수만큼 올라가고 running 된거 확인
On which nodes are the weave peers present?
one on every node
- 데몬셋이라서
Identify the name of the bridge network/interface created by weave on each node.
각 노드에서 weave에 의해 만들어진 네트워크 인터페이스 브리지 이름 확인하기
ip link
What is the POD IP address range configured by weave?
ip addr show weave
What is the default gateway configured on the PODs scheduled on node01?
node01에 스케줄된 POD에 구성된 기본 게이트웨이는 무엇인가
ssh node01
ip route
default via 172.25.0.1 dev eth1
10.44.237.0/24 dev eth0 proto kernel scope link src 10.44.237.12
10.50.0.0/16 dev weave proto kernel scope link src 10.50.192.0
172.25.0.0/24 dev eth1 proto kernel scope link src 172.25.0.76
10.50.192.0
'Devops > 쿠버네티스' 카테고리의 다른 글
k8s 환경에 Harbor Helm으로 배포하기 (0) | 2022.11.15 |
---|---|
CKA - Networking -2 (0) | 2022.11.09 |
CKA - Storage (0) | 2022.11.08 |
k8s에서 NFS Provisioning 사용 (0) | 2022.10.26 |