k8s 환경에서 batch 동시 작동 하지 않도록 하는 삽질기
·
Debug
백엔드에 배치가 함께있는 형태의 환경백엔드 pod는 2개가 떠있는 상황2개의 pod에서 동시에 실행되면 안되었음1개의 백엔드 pod 에서만 동작하도록 하는 방법 모색k8s에서 특정 pod이름으로 구분하여 배치를 동작하도록 하는 것은 어려워 보였음pod이름이 랜덤으로 생성되고 특정 1개의 pod중 어느것으로 동작할지 정해야하는 상황이었는데, k8s 환경 상 특정 pod에서만 돌도록 설정하는 것은 어려움이 있어보였음 -> statefulset 사용하면 되지 않을까?be-pod-0be-pod-1 statefulset의 네이밍은 순서대로 진행되니까 가능하지 않을까?0번에서만 배치가 돌도록?-> 0번이 죽으면 배치가 실패이중화 불가백엔드 실패 인지 배치 실패인지 확인하려면 일일이 로그 확인 필요결론 현실적으로 어..
413 Request entity too large : nginx 파일 업로드 용량 설정 (k8s ingress)
·
Debug
파일 업로드 기능 구현 후 업로드 진행 시413 Request entity too large 에러 발생# 해결 방법nginx.conf 에서 client max body size 관련 설정 진행 필요server { ... client_max_body_size 10M ...} BUT reverse proxy 서버의 nginx 설정을 진행했지만 동일한 문제 발생이유는 ingress도 nginx로 이루어져서 동일한 설정을 ingress에도 해주어야 했음# 해결 방법ingress yml에서annotations.nginx.ingress.kubernetes.io/proxy-body-size: 11M해결 완료
K8s 에서 Client IP를 BE에 전달하기 : nginx ingress annotation 설정
·
Debug
X-forwarded-header 전달 옵션 설정 필요nginx.ingress.kubernetes.io/use-fowarded-headers: 'true'nginx.ingress.kubernetes.io/x-forwarded-for: $proxy_add_x_forwarded_forBUTSNAT 되면 client ip가 lb ip로 변경되어 진짜 client ip 알 수없음k8s cluster 환경 구성마다 다름 필자는 ingress 관련 expose가 nodeport 로 되어있고 lb를 사용하는 환경이므로 해결안되었음참고barisein.tistory.com/999sawaca96.tistory.com/18findstar.pe.kr/2021/08/22/nginx-ingress-controller-use-fo..