holssi 님의 블로그
[CKA] 기출문제 pod 로그 추출 본문
작업 클러스터는 k8s이고, 파드 custom-app의 Log를 모니터링하고, file not found 메시지를 포함하는 Log 라인 추출하기
추출된 결과는 /opt/REPORT/2026/custom-app-log에 기록하기
0. 클러스터 전환
kubectl config use-context k8s
kubectl config current-context
1. custom-app 파드 모니터링하기
kubectl logs custom-app
2. 특정 메시지 추출 후 지정 경로에 저장
# file not found 라는 메시지를 추출
kubectl logs custom-app | grep "file not found"
# 지정 경로에 메시지 저장 후 확인
kubectl logs custom-app | grep "file not found" > /opt/REPORT/2026/custom-app-log
'CKA' 카테고리의 다른 글
| [CKA] 기출문제 static pod 생성 (0) | 2026.01.14 |
|---|---|
| [CKA] 기출문제 kubeadm 업그레이드 (3) (0) | 2026.01.14 |
| [CKA] 기출문제 ETCD (3) (0) | 2026.01.14 |
| [CKA] 기출문제 ClusterRole, ClusterRoleBinding (3) (0) | 2026.01.14 |
| [CKA] ClusterRole, ClusterRoleBinding 문제 (2) (0) | 2026.01.14 |