- helm 시리즈 목차
- 1편 helm이란? : https://malwareanalysis.tistory.com/193
 - 2편 helm 설치 : https://malwareanalysis.tistory.com/194
 - 3편 helm차트 생성: https://malwareanalysis.tistory.com/195
 - 4편 helm 차트 설치, 조회, 삭제: https://malwareanalysis.tistory.com/196
 - 5편 helm 차트 템플릿 값 동적 수정: https://malwareanalysis.tistory.com/197
 - 6편 values.yaml 오버라이딩: https://malwareanalysis.tistory.com/198
 - 7편 Release Object사용: https://malwareanalysis.tistory.com/200
 - 8편 namespace설정: https://malwareanalysis.tistory.com/201
 - 9편 Release 업그레이드: https://malwareanalysis.tistory.com/202
 - 10편 Rollback: https://malwareanalysis.tistory.com/203
 
 
6편에서는 values.yaml파일 값을 변경하는 오버라이딩을 설명합니다.
영상에서는 38:00 ~ 43:25 내용에 해당합니다.
https://youtu.be/ajcyC_6velc?t=2276
1. valeus.yaml 오버라이딩이란?
5편에서 values.yaml파일을 이용해서 템플릿 값을 동적 수정했습니다. 오버라이딩은 values.yaml파일의 필드 값을 변경해서, 최종적으로 템플릿 값이 오버라이딩 된 값으로 변경됩니다.
2. 오버라이딩 장점
오버라이딩 덕분에 기존 helm차트에 설정된 values.yaml 필드값을 외부에서 변경할 수 있습니다. 오버라이딩은 helm 저장소에 공개된 helm차트 정말 많이 사용됩니다.
helm차트 개발자는 사용자가 변경할 수 있는 템플릿 필드를 values.yaml파일에 설정합니다. 그리고 각 필드의 의미를 설명하면, 마치 values.yaml파일을 설정파일처럼 사용할 수 있습니다.
3. 오버라이딩 사용방법
오버라이딩은 2가지 방법으로 사용할 수 있습니다. [3.1], [3.2]챕터 설명은 아래 예제를 사용합니다.
- templates/deployment.yaml
 
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-test
  labels:
    app: nginx-test
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx-test
  template:
    metadata:
      labels:
        app: nginx-test
    spec:
      containers:
      - name: nginx
        image: {{ .Values.image }}
        ports:
        - containerPort: 80
- values.yaml
 
image: nginx:stable
3.1 명령어 --set
helm install(또는 upgrade)할 때 --set이라는 인자를 사용하면 values.yaml필드를 오버라이딩 할 수있습니다.
helm install --set <오버라이딩 필드>=<값> <Release 이름> <차트경로>
아래 예제는 image필드를 nginx:latest로 오버라이딩합니다. Release된 리소스는 nginx:latest 컨테이너 이미지로 pod가 생성됩니다.
helm install --set image=nginx:latest test ./
3.2 파일사용
helm install(또는 upgrade)할 때 -f <파일경로>를 설정하면, 지정한 파일의 필드 값으로 오버라이딩 됩니다.
helm install -f <오버라이딩 파일경로> <Release 이름> <차트경로>
예를 들어 override_files.yaml파일을 생성하고 파일 내용을 아래처럼 설정합니다.
image: nginx:latest
그리고 -f로 override_values.yaml파일을 설정하여 helm install 명령어를 사용하면, image 필드가 오버라이딩 되어 차트가 Release됩니다.
helm install -f override_values.yaml test ./
'연재 시리즈' 카테고리의 다른 글
| Helm 시작하기 - 8편. namespace설정 (0) | 2021.11.25 | 
|---|---|
| Helm 시작하기 - 7편. Release Object사용 (0) | 2021.11.25 | 
| Helm 시작하기 - 5편. helm 차트 템플릿 값 동적 수정 (0) | 2021.11.23 | 
| Helm 시작하기 - 4편. helm 차트 설치, 조회, 삭제 (0) | 2021.11.22 | 
| Helm 시작하기 - 3편. helm 차트 생성 (0) | 2021.11.22 |