Killer Shell CKA - Application Multi Container Issue

Jmnote (토론 | 기여)님의 2025년 9월 23일 (화) 11:26 판 (새 문서: ==개요== ;Killer Shell CKA - Application Multi Container Issue (Gather logs) * https://killercoda.com/killer-shell-cka/scenario/application-multi-container-issue * Namespace <code>m...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요

Killer Shell CKA - Application Multi Container Issue (Gather logs)

2 요구사항

- Deployment의 모든 컨테이너 로그를 /root/logs.log 파일에 저장 - 실패 원인 파악

3 진단

Deployment와 파드 상태를 확인한다.

controlplane:~$ kubectl -n management get deploy
NAME            READY   UP-TO-DATE   AVAILABLE   AGE
collect-data    0/1     1            0           6m

controlplane:~$ kubectl -n management get pods -o wide
NAME                             READY   STATUS             RESTARTS   AGE     IP            NODE           NOMINATED NODE   READINESS GATES
collect-data-7bcd8c8f4f-9d2w8    0/2     CrashLoopBackOff   3          6m32s   10.244.0.23   controlplane   <none>           <none>

kubectl logs 도움말에서 멀티 컨테이너/워크로드 리소스 로그 출력 옵션을 확인한다.

controlplane:~$ kubectl -n management logs -h | sed -n '1,40p'

4 로그 수집

아래 두 방법 중 하나를 사용한다.

- 방법 A: 모든 컨테이너 로그를 한 번에 수집

controlplane:~$ kubectl -n management logs --all-containers deploy/collect-data > /root/logs.log

- 방법 B: 컨테이너명 별로 개별 수집 후 같은 파일에 합치기

controlplane:~$ kubectl -n management logs deploy/collect-data -c nginx  > /root/logs.log
controlplane:~$ kubectl -n management logs deploy/collect-data -c httpd >> /root/logs.log

수집 결과 확인:

controlplane:~$ ls -l /root/logs.log
-rw-r--r-- 1 root root 5482 Sep 23 10:12 /root/logs.log

controlplane:~$ tail -n 50 /root/logs.log
2025/09/23 10:11:41 [notice] 1#1: start worker processes
2025/09/23 10:11:41 [notice] 1#1: start worker process 25
2025/09/23 10:11:41 [emerg] 25#25: bind() to 0.0.0.0:80 failed (98: Address already in use)
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
(98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
(98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs

5 원인 분석

- 파드 안에 nginxhttpd 두 컨테이너가 모두 TCP 포트 80을 리스닝하도록 설정되어 있다. - 먼저 시작한 컨테이너가 80 포트를 점유하면, 나중에 시작한 컨테이너는 Address already in use 오류로 실패한다. - 멀티 컨테이너 파드에서는 각 컨테이너의 리스닝 포트가 충돌하지 않도록 조정해야 한다. 예:

 - 한 컨테이너는 8080, 다른 컨테이너는 80 포트 사용
 - 또는 프록시/사이드카 설계 재검토

6 추가 팁

- CrashLoop 상황이면 이전 컨테이너 로그도 함께 확인 가능:

 - kubectl -n management logs --previous deploy/collect-data -c nginx

- 여러 파드가 있을 경우 레이블 셀렉터를 사용할 수도 있다:

 - kubectl -n management logs -l app=collect-data --all-containers

7 같이 보기

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