helm을 통해 kubernetes jenkins을 설치할 때. 주의해야 할 점이 있다.

 

 

 

jenkins 잡이 실행, 에러 정보가 모두 pods로 쌓인다. (Completed|Error)

 

 

처음에는 대수롭게 생각하지 않았는데. 이게 싸이면 결국 kubernetes 클러스터는 자원 부족으로 문제가 발생한다.

 

그래서 아래와 같은 커맨드로 종료하거나..

 

 

kubectl delete pod $(kubectl get pods | grep -E "Completed|Error" | awk '{print $1}') —force —grace-period=0

 

 

kubernetes job 등록해서.. 삭제하도록 해야 한다.

 

spec:
schedule: "*/30 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: kubectl-runner
image: wernight/kubectl
command: ["sh", "-c", "kubectl get jobs | awk '$4 ~ /[2-9]d$/ || $3 ~ 1' | awk '{print $1}' | xargs kubectl delete job"]
restartPolicy: Never

 

 

Posted by '김용환'
,