이전 포스팅에서 Probe를 체크하는 방법이 3가지가 있었는데
그중 Command로 Probe를 체크하는 방법에 대해서 포스팅을 진행해 봤다.
Command probe
성공 : Command 실행 후 결괏값이 0이면 정상
실패 : Command 실행 후 결과값이 0이 아니면 실패
readinessProbe or livenessProbe 적용
readinessProbe:
exec:
command:
- /test/probe/probe.sh
test shell 파일 생성 후 테스트
- 권한이 없는 경우 chmod 777을 통해 권한 추가 필요
#!/bin/bash
exit 0
소켓 or 스레드 개수를 확인 후 true / false 체크
#!/bin/bash
#소켓 결과
RESULT=$(ls /proc/1/fd -l | wc -l)
#thread 결과
RESULT=$(ps -eLf | grep root | grep -vE "grep|ps -eLf" | wc -l)
if [ ${RESULT} -gt 500 ]; then
echo 'fail'
exit 1
fi
echo 'ok'
exit 0
if문에 []를 사용할때 띄워쓰기 필수
exit 0 -> true
exit 1 -> false
로 구분해서 pod 실행 여부를 판단한다
-lt <
-gt >
-le <=
-ge >=
-eq ==
-ne !=
'Kubernetes' 카테고리의 다른 글
kubespray kubernetes 설치하기 (4) | 2023.10.17 |
---|---|
kubernetes pod 기동 시 오류(networkPlugin cni failed to teardown pod) (0) | 2023.08.16 |
Pod Lifecycle(readiness,liveness Probe) (0) | 2023.05.30 |
podAntiAffinity 정책 (0) | 2023.05.24 |
Pod Resource 관리(cpu, mem limits) (0) | 2023.05.22 |