환경(자주 배포 안하는)에 따라 최신 차트와 현재 배포된 차트의 버전이 차이가 많이 나버리는 경우가 종종 있다.
그런 경우 코드만 비교해 보는 것 만으로는 어떤 변화가 일어날지 가늠이 잘 안가서 Manifest를 가져와서 확인하는 편이 안심이 되기에 다음과 같은 방법을 사용해 보았다.
시나리오 0. 헬름 리비전 간 비교 시
helm diff : Preview helm upgrade as a coloured diff
https://github.com/databus23/helm-diff
- 최신 REVISION과 특정 REVISION 비교
$ helm diff revision [flags] RELEASE REVISION1
Example:
$ helm diff revision my-release 2
- REVISION1과 REVISION2 비교
$ helm diff revision [flags] RELEASE REVISION1 REVISION2
Example:
$ helm diff revision my-release 2 3
시나리오 1. 배포하기 전에 현재 배포된 차트와 앞으로 배포 할 차트를 비교하고 싶을 때
https://helm.sh/docs/helm/helm_get_manifest/
helm get manifest - download the manifest for a named release
# 배포 예정 차트를 Manifest로 변환
helm upgrade -i <NAME> . -f ./values-<ENV>.yaml --dry-run > resource.yaml
# 현재 배포돼있는 차트의 Manifest를 가져오기
helm get manifest <NAME> > resource_current.yaml
diff resource.yaml resource_current.yaml
본 시나리오 역시 helm diff를 사용하면 보다 간편하게 확인할 수 있다.
# 사용법
helm diff upgrade [flags] [RELEASE] [CHART]
# 예시
helm diff upgrade my-release stable/postgresql --values values.yaml
# [CHART] 대신 .(마침표)를 입력하는 것으로도 실행 가능
helm diff upgrade <RELEASE> . --values values-e1-np.yaml
helm diff upgrade <RELEASE> . -f values-e1-np.yaml
시나리오 2. 현재 배포된 차트와 이전 차트의 values.yaml 파일을 비교하고 싶을 때
https://helm.sh/docs/helm/helm_get_values/
helm get values : download the values file for a named release
# 현재 배포된 차트의 values 파일을 출력
$ helm get values <NAME>
# 특정 리비전 차트의 values 파일을 출력
$ helm get values <NAME> --revision <:INT>
# 실제 사용 예
$ helm get values front-app > resource.yaml
$ helm get values front-app --revision 5 > resource_5.yaml
$ diff resource.yaml resource_5.yaml
'Kubernetes' 카테고리의 다른 글
Kubernetes Namespace 설계에 관해 (3) | 2023.02.13 |
---|---|
CKA 취득 후기 (0) | 2023.01.27 |