일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- task queue
- useLayoutEffect
- AJIT
- TypeScript
- helm-chart
- Render Queue
- 명시적 타입 변환
- 프로세스
- Custom Hook
- 클라이언트 상태 관리 라이브러리
- prettier-plugin-tailwindcss
- JavaScript
- Microtask Queue
- Sparkplug
- Redux Toolkit
- linux 배포판
- Recoil
- react
- docker
- 암묵적 타입 변환
- 주니어개발자
- jotai
- 좋은 PR
- CS
- 회고
- type assertion
- Compound Component
- Headless 컴포넌트
- 타입 단언
- zustand
- Today
- Total
구리
[k8s] imagePullPolicy: Always를 사용해도 latest 이미지로 업그레이드 되지 않는 현상 본문
이슈
회사 서비스는 ArgoCD를 사용해 helm-chart를 배포하고 있다. helm chart 리포지토리에는 배포 환경, 서비스에 따라 폴더별로 구분되어 있으며 굉장히 많은 commit, push가 일어난다.
배포시 가장 최신의 이미지를 사용하기 위해 deployment에서 imagePullPolicy : always
옵션을 사용해 k8s에 해당 도커 이미지가 있든 없든 무조건 다운로드하게끔 설정했다. 그러면 로컬에서 개발 후 Dockerhub에 동일한 버전의 이미지를 push 해도 배포시 항상 최신 이미지를 가져오기에 변경사항이 반영되어 있을 거라 생각했지만... 아무런 반응이 없었다.
apiVersion: apps/v1
kind: Deployment
metadata:
name: test
spec:
selector:
matchLabels:
app: test
template:
metadata:
labels:
app: test
version: dev
spec:
containers:
- env:
{{- range $k1, $v1 := .Values.env }}
- name: {{ $k1 }}
value: {{ quote $v1 }}
{{- end }}
image: {{ .Values.app.image }}:{{ .Values.app.tag }}
name: test-app
imagePullPolicy: Always
ports:
- containerPort: 80
workingDir: /var/www/html
imagePullSecrets:
- name: {{ .Values.imagePullSecrets.name }}
원인
결론적으로는 deployment manifest가 변경되지 않았기 때문이다. 버전도 동일하고 파일 자체의 변경점이 없기에 해당 옵션을 넣어도 최신 이미지를 받아오지 않는 것이다.
해결
1. deployment.yaml 파일에 변화를 주기 위해 date label을 추가
helm upgrade 할 때마다 deployment yaml에 변화를 주기 위해 현재 시간을 label로 추가하는 방법을 생각해봤었다.
그러나 현재 helm chart repo는 다른 서비스도 포함되어 있었기에 관련 없는 commit으로 인해 무분별한 배포가 진행될 것 같아 사용하지 않았다...
apiVersion: apps/v1
kind: Deployment
metadata:
name: example-deployment
spec:
replicas: 3
selector:
matchLabels:
name: example
template:
metadata:
labels:
name: example
################ 여기 #################
date: "{{ now | unixEpoch }}"
######################################
spec:
containers:
- name: sample
image: sample-image
imagePullPolicy: Always
2. 랜덤 변수를 env로 사용
현재 서비스는 Github Actions을 이용해 helm chart repo commit 자동화를 구현했다. 따라서 빌드 시점에 랜덤한 변수를 생성해 values.yaml의 env에 주입하는 것이다. (자세한 건 요기 참고)
그러면 deployment 설정에서 container env로 주입되기 때문에 빌드할 때마다 deployment 파일이 업데이트되어 새로운 이미지를 가져오게 된다.
또한 다른 서비스가 helm chart repo에 commit, push를 날려도 deployment 파일은 변경되지 않으니 helm 업그레이드가 되지 않는다.
참고
'오류해결' 카테고리의 다른 글
[Vue] iframe 태그에서 동적인 src 속성값을 사용할 경우, 뒤로 가기 안되는 버그 (0) | 2024.09.24 |
---|---|
[Nginx] 동적 IP일 때 proxy_pass 연결 끊기는 에러 (4) | 2023.12.05 |
[Prettier] Next.js13 + Prettier 관련 에러 해결 (2) | 2023.12.03 |
[Oracle] IO Error : could not resolve the connect identifier specified (0) | 2021.09.27 |
[Mac] java.sql.SQLException: 로케일을 인식할 수 없습니다. (0) | 2021.08.29 |