CKA SimA 17 Pod의 컨테이너 정보 확인

1 개요[ | ]

k8s Pod 및 컨테이너 정보 확인
Pod가 어느 노드에 스케줄되었는지 확인하고, 해당 노드에서 containerd 컨테이너 정보를 crictl로 추출하기

2 Pod 생성[ | ]

  • 테스트용 Pod를 생성
# k -n project-ark run ark-site --image=httpd:2-alpine --labels "pod=container,container=pod"
pod/ark-site created

3 스케줄된 노드 확인[ | ]

  • 해당 Pod가 어떤 노드에 배치되었는지 확인
# k -n project-ark get po ark-site -o wide
NAME       READY   STATUS    RESTARTS   AGE   IP            NODE             ...
ark-site   1/1     Running   0          21s   10.44.0.29    cka2556-node1    ...

4 노드 접속 및 컨테이너 확인[ | ]

  • Pod가 위치한 노드에 SSH로 접속
  • crictl ps를 통해 컨테이너 ID 확인
# ssh cka2556-node1
# sudo -i
# crictl ps | grep ark-site
ba62e5d465ff0   a7ccaadd632cf   2 minutes ago   Running   ark-site   ...

5 컨테이너 정보 추출[ | ]

  • crictl inspect로 런타임 유형 확인
# crictl inspect ba62e5d465ff0 | grep runtimeType
"runtimeType": "io.containerd.runc.v2",
  • 결과를 파일에 저장
# echo "ba62e5d465ff0 io.containerd.runc.v2" > /opt/course/17/pod-container.txt
# cat /opt/course/17/pod-container.txt
ba62e5d465ff0 io.containerd.runc.v2

6 컨테이너 로그 확인[ | ]

  • crictl logs 명령어로 컨테이너 로그 출력
# crictl logs ba62e5d465ff0
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 10.44.0.29. Set the 'ServerName' directive globally to suppress this message
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 10.44.0.29. Set the 'ServerName' directive globally to suppress this message
[Tue Oct 29 15:12:57.211347 2024] [mpm_event:notice] [pid 1:tid 1] AH00489: Apache/2.4.62 (Unix) configured -- resuming normal operations
[Tue Oct 29 15:12:57.211841 2024] [core:notice] [pid 1:tid 1] AH00094: Command line: 'httpd -D FOREGROUND'
  • 로그를 파일로 저장
# crictl logs ba62e5d465ff0 > /opt/course/17/pod-container.log

7 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}