Overview
Kubernetes 환경에서 반복적인 리소스 배포를 효율화하고자 할 때, 단순한 kubectl apply만으로는 한계가 있다. 이럴 때 유용하게 활용되는 것이 바로 Helm이다.
Helm은 Kubernetes용 패키지 매니저로, 애플리케이션을 정의하고, 설치하고, 업그레이드하는 작업을 코드로 템플릿화하여 수행할 수 있도록 도와준다. Helm을 사용하면 복잡한 Kubernetes 리소스 정의도 하나의 패키지(Chart)로 관리할 수 있고, 배포, 업데이트, 롤백까지 일관되고 쉽게 처리할 수 있다.
이 글에서는 Helm의 개념과 구조부터 설치 방법, 실무에서 자주 사용하는 명령어, 그리고 helm create를 통한 차트 생성 및 관리 방법까지 실용적인 내용을 정리했다. Helm을 처음 접하거나 실무 적용을 고민하고 있는 분들께 좋은 입문서와 실전 가이드가 될 것이다.

📅 관련 글
2023.05.16 - [Container Orchestration/Kubernetes] - Helm Chart 작성방법
2024.11.15 - [Container Orchestration/Kubernetes] - Helm Chart Template 문법
2024.12.20 - [Container Orchestration/Kubernetes] - Helm Chart 생성 및 패키징 (gh-pages)
2025.01.06 - [Container Orchestration/Kubernetes] - Helm Base App Chart 생성(With ArgoCD)
Helm 이란?
Helm 이란 쿠버네티스 오픈 소스 패키지 매니저이다.
Kubernetes용으로 구축된 소프트웨어를 제공, 공유 및 사용할 수 있는 기능을 제공한다.
Helm 은 chart라는 패키지 형식을 사용한다. 여기서 chart는 Kubernetes 리소스 집합을 설명하는 파일 모음이다.
단일 차트를 사용하여 memcached 파드와 같은 단순한 것 부터 HTTP 서버, 데이터베이스, 캐시 등이 포함된 전체 웹 앱 스택과 같은 복잡한 것을 배포할 수 있다.
차트는 디렉토리 내부의 파일 모음으로 구성된다. 디렉토리 이름은 차트의 이름이다.(버전 정보 제외).
Helm Chart의 구조 시각화
따라서 wordpress를 설명하는 차트는 wordpress 디렉토리에 저장된다.
wordpress/
Chart.yaml # A YAML file containing information about the chart
LICENSE # OPTIONAL: A plain text file containing the license for the chart
README.md # OPTIONAL: A human-readable README file
values.yaml # The default configuration values for this chart
values.schema.json # OPTIONAL: A JSON Schema for imposing a structure on the values.yaml file
charts/ # A directory containing any charts upon which this chart depends.
crds/ # Custom Resource Definitions
templates/ # A directory of templates that, when combined with values,
# will generate valid Kubernetes manifest files.
templates/NOTES.txt # OPTIONAL: A plain text file containing short usage notes
Chart.yaml
: 차트 자체의 이름, 설명, 버전 정보가 들어간다.values.yaml
: 템플릿에서 사용할 기본 값들이 정의되어 있으며, 환경별로 이 값을 덮어씌워서 재사용할 수 있다.templates/
: 실제 Kubernetes 매니페스트가 생성되는 템플릿들이 들어갑니다. 여기엔deployment.yaml, service.yaml
등 익숙한 리소스 템플릿이 담긴다.
Helm은 Helm 차트를 저장하고 공유하는 데 사용할 수 있는 차트 리포지토리를 지원한다.
분산형 커뮤니티 Helm 차트 저장소는 Artifact Hub에 있다.
Artifact Hub는 공개적으로 사용 가능한 분산형 Helm 차트를 포함하여 CNCF(Cloud Native Computing Foundation) 프로젝트에 대한 패키지 및 구성을 찾고, 설치하고, 게시할 수 있는 웹 기반 응용 프로그램이다.
Helm Chart를 구조적으로 이해하면, 자신만의 차트를 만들거나 기존 차트를 수정할 때 훨씬 수월해진다.
Helm 설치
1. 설치 전 전제조건
helm 을 설치하기 전에 다음과 같은 전제조건이 필요하다.
- Kubernetes 클러스터
- 설치에 적용할 보안 구성 결정(있는 경우)
- Helm 설치 및 구성
Kubernetes 클러스터는 아래의 페이지에 설치방법을 정리해 놓았다.
2022.08.29 - [교육, 커뮤니티 후기] - <인프런> 대세는 쿠버네티스 [초급] - No.6 Kubernetes Cluster 설치(v1.22)
2. Helm 설치방법
Helm 프로젝트는 Helm을 가져오고 설치하는 두 가지 방법을 제공한다.
다음은 Helm 릴리스를 가져오는 공식 방법이다.
그 외에도 Helm 커뮤니티는 다양한 패키지 관리자를 통해 Helm을 설치하는 방법을 제공한다.
1.) Binary Release
- Download your desired version
- Unpack it (tar -zxvf helm-v3.0.0-linux-amd64.tar.gz)
- Find the helm binary in the unpacked directory, and move it to its desired destination (mv linux-amd64/helm /usr/local/bin/helm)
2.) Script
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
helm init
helm version
// 버전 확인
helm init --upgrade
// 최신 버전으로 업그레이드
3.) Source
소스에서 Helm을 빌드하는 것은 약간 더 많은 작업이 필요하지만
최신(시험판) Helm 버전을 테스트하려는 경우 가장 좋은 방법이다.
작동하는 Go 환경이 있어야 한다.
git clone https://github.com/helm/helm.git
cd helm
make
OS에 따른 설치방법은 여기에서 확인하면 된다.
Helm 사용법
Helm 사용을 설명하기에 앞서 Helm 에는 3 가지 요소가 있다.
- Chart는 Helm Package이다. Kubernetes 클러스터 내에서 application, tool, service를 실행하는데 필요한 모든 리소스 정의가 포함된다. Apt의 dpkg, Yum의 RPM 과 같다고 보면 된다.
- Repository는 Chart를 수집하고 공유할 수 있는 장소이다. Perl's CPAN archive 와 Fedora Package Database 와 비슷하지만 Chart는 Kubernetes 패키지 용이다.
- Release는 Kubernetes Cluster에서 실행되는 차트의 instance이다. 하나의 Chart는 동일한 클러스터에 여러번 설치할 수 있다. 그리고 설치될 때마다 새 Release가 생성된다. Cluster에서 두개의 Database를 실행하려면 해당 Chart를 두 번 설치할 수 있다.
Helm Chart 생성방법
처음 Helm Chart를 생성할 땐 아래와 같은 방법으로 생성하면 된다.
그러면 somaz라는 디렉토리가 생기고, Chart.yaml
과 values.yaml
그리고 template
이 생긴다.
$ helm create somaz
Creating somaz
$ ls
somaz
$ cd somaz/
$ ls
Chart.yaml charts templates values.yaml
$ ls -l templates/
total 32
-rw-r--r-- 1 somaz somaz 1739 May 16 11:07 NOTES.txt
-rw-r--r-- 1 somaz somaz 1762 May 16 11:07 _helpers.tpl
-rw-r--r-- 1 somaz somaz 1850 May 16 11:07 deployment.yaml
-rw-r--r-- 1 somaz somaz 910 May 16 11:07 hpa.yaml
-rw-r--r-- 1 somaz somaz 2075 May 16 11:07 ingress.yaml
-rw-r--r-- 1 somaz somaz 355 May 16 11:07 service.yaml
-rw-r--r-- 1 somaz somaz 316 May 16 11:07 serviceaccount.yaml
drwxr-xr-x 2 somaz somaz 4096 May 16 11:07 tests
Chart.yaml
차트 자체에 대한 메타데이터가 포함된 기본 파일이다.
여기에는 name, version, description, home, keywords, sources, dependencies
등과 같은 필드가 포함된다.
apiVersion: v2
name: my-awesome-app
description: A Helm chart for Kubernetes
version: 1.0.0
appVersion: 1.16.0
values.yaml
차트의 기본 구성 값을 정의한다. 기본적으로 제공되는 values.yaml
을 복사해서 사용한다.
# Default values for somaz.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
image:
repository: nginx
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
serviceAccount:
# Specifies whether a service account should be created
create: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""
...
templates
유효한 Kubernetes 매니페스트 파일을 생성하는 템플릿의 디렉터리이다. 템플릿은 Go 템플릿 언어를 사용한다.
Helm은 값을 values.yaml
의 값으로 대체하고 Kubernetes 구성 파일을 생성한다.
기본적으로 아래와 같은 template들이 생성된다.
$ ls
NOTES.txt _helpers.tpl deployment.yaml hpa.yaml ingress.yaml service.yaml serviceaccount.yaml tests
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.name }}
spec:
replicas: {{ .Values.replicaCount }}
template:
metadata:
labels:
app: {{ .Values.name }}
spec:
containers:
- name: {{ .Values.name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
ports:
- containerPort: {{ .Values.service.port }}
1. helm search
해당 명령어를 사용하여 공개적으로 사용 가능한 차트를 찾을 수 있다.
$ helm search -h
Usage:
helm search [keyword] [flags]
ex.)
$ helm search hub
$ helm search repo
// 로컬 클라이언트에 추가한 저장소를 검색합니다.
2. helm install
해당 명령어를 이용하여 새로운 패키지를 설치할 수 있다.
install 인수는 차트 참조, 패키지 된 차트 경로, 압축 해제 된 차트 디렉토리 경로 또는 URL 이어야한다.
$ helm install -h
Usage:
helm install [RELEASE_NAME] [CHART] [flags]
ex.)
$ helm install --namespace <namespace> --name <release_name> \
<chart path> \
-f <chart override value path>
3. helm status
해당 명령어를 이용해 릴리스 상태를 추적하거나 구성 정보를 다시 읽을 수 있다.
$ helm status -h
Usage:
helm status [flags] RELEASE_NAME
ex.)
$ helm status <Release_Name>
4. helm upgrade / helm history / helm rollback
해당 명령어를 이용해 새 버전의 차트가 릴리스되거나 릴리스의 구성을 변경하려는 경우 사용할 수 있다.
1.) helm upgrade
$ helm upgrade -h
Usage:
helm upgrade [RELEASE_Name] [CHART] [flags]
$ helm upgrade <release_name> \
<chart path> \
-f <chart override value path>
2.) helm history / helm rollback
$ helm history -h
Usage:
helm history [flags] RELEASE_NAME
ex.)
$ helm history angry-bird --max=4
REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION
1 Mon Oct 3 10:15:13 2016 SUPERSEDED alpine-0.1.0 1.1 Initial install
2 Mon Oct 3 10:15:13 2016 SUPERSEDED alpine-0.1.0 1.2 Upgraded successfully
3 Mon Oct 3 10:15:13 2016 SUPERSEDED alpine-0.1.0 1.1 Rolled back to 2
4 Mon Oct 3 10:15:13 2016 DEPLOYED alpine-0.1.0 1.3 Upgraded successfully
$ helm rollback -h
Usage:
helm rollback [flags] [RELEASE] [REVISION]
ex.)
$ helm rollback <REVISION>
# 해당 REVISION으로 rollback이 된다.
5. helm delete
해당 명령어를 사용해 helm chart를 삭제할 수 있다.
$ helm delete -h
Usage:
helm delete [flags] RELEASE_NAME [...]
...
Aliases:
delete, del
ex.)
$ helm del --purge <RELEASE_Name>
// --purge Remove the release from the store and make its name free for later use
6. helm list
해당 명령어를 사용해 helm chart로 배포된 모든 릴리스를 확인할 수 있다.
$ helm list -h
Usage:
helm list [flags] [FILTER]
Aliases:
list, ls
ex.)
$ helm list 'ara[a-z]+'
NAME UPDATED CHART
maudlin-arachnid Mon May 9 16:07:08 2016 alpine-0.1.0
$ helm list --all
// 모든 차트를 확인할 수 있다.
7. helm lint
해당 명령어를 사용하면 helm chart 문법검사를 할 수 있다. 상당히 유용하다!
$ hlem lint -h
Usage:
helm lint PATH [flags]
helm lint --values dev2.values.yaml
==> Linting .
[INFO] Chart.yaml: icon is recommended
1 chart(s) linted, 0 chart(s) failed
8. Helm 디버깅 꿀팁 - helm template / --dry-run --debug
Helm을 사용하면서 가장 많이 발생하는 문제는 템플릿 오류이다. 특히 values 값을 잘못 전달하거나, 템플릿 문법(Gotpl)을 실수하면 배포가 실패하거나 예상치 못한 리소스가 생성되기도 한다.
이럴 때는 다음과 같은 명령어로 템플릿 렌더링 결과를 사전에 확인하는 것이 매우 유용하다.
helm template <chart-directory> -f dev.values.yaml
또는 설치 전 시뮬레이션 할 경우
helm install myapp ./mychart -f dev.values.yaml --dry-run --debug
helm template
은 실제로 설치하지 않고도 Kubernetes 리소스 매니페스트(YAML)가 어떻게 생성될지 출력해준다.--dry-run --debug
는 설치 과정을 시뮬레이션하면서 내부 흐름까지 자세히 보여준다.
이 과정을 통해 실수로 빠진 변수나 잘못된 문법을 미리 잡을 수 있고, CI/CD 과정에서도 테스트 단계에 포함하기 좋다.
Helm과 GitOps의 연계
Helm은 GitOps 기반의 도구들과도 아주 잘 어울린다.
대표적으로 ArgoCD와 FluxCD는 Git 저장소에 있는 Helm Chart를 읽어와서 자동으로 Kubernetes 클러스터에 배포하고, 상태를 지속적으로 동기화해준다.
예를 들어, ArgoCD에서는 다음과 같이 Helm Chart의 Git 경로만 지정하면
Application.yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: myapp
spec:
source:
repoURL: https://github.com/my-org/my-helm-charts
path: myapp
targetRevision: HEAD
helm:
valueFiles:
- values-prod.yaml
destination:
server: https://kubernetes.default.svc
namespace: prod
아래와 같이 Application을 묶어서 ApplicationSet.yaml
로 생성할수도 있다.
ApplicationSet.yaml
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: onpremise-appicationset
spec:
generators:
- matrix:
generators:
- list:
elements:
- cluster: master-node.somaz.link # your cluster name
url: https://xx.xx.xxx.xx:6443 # your cluster url
values:
project: somaz-onpremise
environment: dev1
- git:
repoURL: git@github.com:somaz94/helm-chart-template.git # your source repo
revision: HEAD
directories:
- path: onpremise/ke-use-nfs-server/*
# refreshInterval: 180s # default is 180s
template:
metadata:
name: '{{values.environment}}-{{values.project}}-{{path.basename}}'
labels:
environment: '{{values.environment}}'
project: '{{values.project}}'
app-name: '{{path.basename}}'
spec:
project: '{{values.project}}'
source:
repoURL: git@github.com:somaz94/helm-chart-template.git
targetRevision: HEAD
path: '{{path}}'
helm:
version: v3
valueFiles:
- '{{path.basename}}.values.yaml'
destination:
server: '{{url}}'
namespace: '{{values.project}}-{{path.basename}}'
syncPolicy:
automated:
prune: true
selfHeal: true
# preserveResourcesOnDeletion: false # default is true
syncOptions:
- CreateNamespace=true
- ApplyOutOfSyncOnly=true
이렇게 구성해두면 Git에 변경사항을 푸시하는 것만으로도 자동 배포가 이루어지고, 상태가 달라지면 자동 복구도 수행된다.
GitOps 방식은 CI/CD의 흐름을 단순화하면서도 안정성을 높여주며, Helm과 결합하면 더욱 강력한 자동화 환경을 만들 수 있다.
마무리
Helm은 Kubernetes의 복잡한 리소스 정의를 템플릿 기반으로 관리할 수 있게 해주는 강력한 패키지 매니저이다. Helm을 도입하면 애플리케이션 배포의 표준화와 버전 관리를 손쉽게 구현할 수 있으며, GitOps 기반 워크플로우와도 자연스럽게 연계된다.
특히, helm install, helm upgrade, helm rollback
과 같은 명령어들을 잘 활용하면 안정적인 운영 및 빠른 장애 대응이 가능하다.
실제 운영 환경에서는 Chart Template의 구조를 팀의 개발/운영 환경에 맞게 커스터마이징하고, values.yaml
을 환경별로 구분하여 관리하면 생산성과 유지보수성이 크게 향상된다.
이제 더 이상 수십 개의 YAML 파일을 수작업으로 관리하지 말고, Helm으로 통합 관리해보세요!
Reference
https://kubebyexample.com/learning-paths/argo-cd/argo-cd-working-helm
'Container Orchestration > Kubernetes' 카테고리의 다른 글
Kubernetes Autoscaling & Karpenter (0) | 2023.05.24 |
---|---|
Helm Chart 작성방법 (0) | 2023.05.18 |
Kuberntes Service Account란? (0) | 2023.05.10 |
Kubernetes Secret이란? (0) | 2023.05.09 |
MetalLB란? (2) | 2023.05.03 |