파란하늘의 지식창고
반응형

어떤 경우 helm chart로 kubernetes yaml 파일을 만들고 싶어 질까

설정이나 구성이 복잡한 경우 docker image로 설치할 수 있는 안내를 하지 않고 helm을 사용하는 걸 안내하는 경우가 있다.
helm이 간편하게 설치를 할 수 있게 해 주지만 해당 image의 사용이 어떻게 구성이 되었는지 알고 싶거나 또는 helm으로 제공되는 설정을 적당히 참고해서 내가 원하는 구성으로 kubernetes yaml파일을 만들고 싶은데 docker hub를 검색해도 해당 docker image에 대한 커스텀 옵션 안내가 없고 docker file tag를 살펴보거나 해당 소스의 github을 찾아봐도 어떻게 kubernetes yaml을 작성해야 하는지 알기 어려운데 helm으로 사용하는 법만 안내하는 경우가 있다.

이런 경우 helm 정보를 기준으로 kubernetes yaml 파일을 만들어서 확인하면 확인하기 수월하다.

예를 들어 grafana tempo의 경우 helm 설치를 다음과 같이 안내하고 있다.

https://github.com/grafana/helm-charts/tree/main/charts/tempo

# repository 추가
helm repo add grafana https://grafana.github.io/helm-charts

# install
helm install my-release grafana/tempo

# uninstall
helm delete my-release

해당 github의 template 폴더를 보면 helm template 문법으로 구성되어 있어서 helm template 문법을 알지 못하면 이해하는데 시간이 걸린다.
하지만 kubernetes yaml 문법에 좀 더 친숙한 경우 이 chart로 kubernetes yaml 파일을 만들어 살펴보면 좀 더 수월하게 파악할 수 있다.

helm template command 사용하기

yaml 파일을 만드는 건 다음과 같이 template command를 사용하면 된다.

# helm template [name] [chart] [flags]

# grafana tempo의 경우 예
helm template tempo grafana/tempo --output-dir .

# 아래처럼 결과가 생성된다.
wrote .\tempo/templates/serviceaccount.yaml 
wrote .\tempo/templates/configmap-tempo-query.yaml 
wrote .\tempo/templates/configmap-tempo.yaml 
wrote .\tempo/templates/service.yaml 
wrote .\tempo/templates/statefulset.yaml

template command는 로컬에서 template을 렌더링 한다.
https://helm.sh/ko/docs/helm/helm_template/

커스텀 매개변수를 사용하는 경우 

opentelemetry-collector의 경우 mode 값의 지정이 필수이다.
https://github.com/open-telemetry/opentelemetry-helm-charts/tree/main/charts/opentelemetry-collector

helm에서는 커스텀하게 지정할 수 있는 값을 values.yaml에서 관리한다.
해당 파일을 적절하게 수정하여 사용하면 된다.

https://helm.sh/ko/docs/chart_template_guide/values_files/

values.yaml을 따로 만들어 다수의 값을 설정하여 사용하고 싶은 경우 -f 옵션으로 로컬의 values.yaml을 지정하여 사용한다.

helm template opentelemetry-collector open-telemetry/opentelemetry-collector --output-dir . -f myvalues.yaml

만약 간단하게 몇 개의 값만 직접 지정하려는 경우 values.yaml 파일을 사용하지 않고 다음과 같이 --set flag를 사용할 수도 있다.

helm template opentelemetry-collector open-telemetry/opentelemetry-collector --output-dir . --set mode=deployment
반응형
profile

파란하늘의 지식창고

@Bluesky_

내용이 유익했다면 광고 배너를 클릭 해주세요