💡 핵심 요약 (Executive Summary)
본 가이드는 쿠버네티스 Helm 패키지 매니저 쿠버네티스 Helm 패키지 매니저file 핵심 가이드 및 실전 아키텍처의 핵심 개념, 실전 구성 명령어 및 아키텍처 베스트 프랙티스를 다룹니다. 클라우드 네이티브 및 인프라 엔지니어링 실무에 즉시 활용 가능하도록 체계적으로 정리했습니다.
📑 Table of Contents
Installation
required
-
kube-proxy: 8080
yaml
k proxy --port=8080 &
macOS
bash
brew install helmfile
amd64
bash
LATEST=$(curl -sL https://github.com/helmfile/helmfile/releases/latest \
| grep -oP 'tag/\K[v0-9\.]+' | head -1)
curl -LO https://github.com/helmfile/helmfile/releases/download/${LATEST}/helmfile_$(echo $LATEST | sed 's/v//')_linux_amd64.tar.gz
https://github.com/helmfile/helmfile/releases/download/v1.1.9/helmfile_1.1.9_linux_amd64.tar.gz
tar -xvzf helmfile_$(echo $LATEST | sed 's/v//')_linux_amd64.tar.gz
chmod +x helmfile
mv ./helmfile /usr/local/bin
rm helmfile_$(echo $LATEST | sed 's/v//')_linux_amd64.tar.gz LICENSE README-zh_CN.md README.md
Exec
yaml
#Helm 차트를 실제로 설치 또는 업데이트
helmfile sync
#diff 후 변경사항이 있을 때만 적용 (권장)
helmfile apply
#실제 적용 전 변경점 확인
helmfile diff
#Helm 템플릿만 렌더링
helmfile template
#배포된 Helm 리소스 삭제
helmfile destroy
#배포된 Helm 리소스 삭제
helmfile -l name=build-image sync 특정 릴리스만 배포
#특정 릴리스만 삭제
helmfile -l name=old-build-deploy-image destroy
#특정 환경(dev)으로 배포 (environments 사용 시)
helmfile -e dev apply
sync vs apply 차이점 상세 비교
| 항목 |
helmfile sync
|
helmfile apply
|
| 실행 방식 | 모든 릴리스 강제 동기화 | 변경사항 있는 릴리스만 배포 |
| revision 증가 여부 | 항상 증가 (helm upgrade 강제 실행됨) | 변경 없으면 유지됨 |
| 예시 상황 | 설정이 같아도 revision 1 → 2 | 설정이 같으면 revision 1 유지 |
| 권장 사용처 | 강제 재배포, 초기 설치 | 일상적인 배포, 변경 점검 후 진행 |
일상적인 배포에는 helmfile apply 를 추천! 변경 사항이 있는 릴리스만 업데이트되므로 효율적이고 안전하다.
모든 릴리스를 강제로 재배포해야 할 때만 helmfile sync 를 사용
Global Flags
bash
# ./helmfile.yaml 외 지정
helmfile -f $filename
Samples
Basic
yaml
# helmfile.yaml
repositories:
- name: bitnami
url: https://charts.bitnami.com/bitnami
releases:
- name: redis
namespace: default
chart: bitnami/redis
version: 17.1.3
values:
- values/redis-values.yaml
git Repo로 release 지정
- public
yaml
# helm-git powered repository: You can treat any Git repository as a charts repository
- name: polaris
url: git+https://github.com/reactiveops/polaris@deploy/helm?ref=master
- private
yaml
repositories:
- name: polaris
url: git+https:/
/<USERNAME>:<TOKEN>@github.com/reactiveops/polaris@deploy/helm?ref=master
ArgoCD 설치 예시
helmfile.yaml
yaml
#Argo Helm 저장소 추가
repositories:
- name: argo
url: https://argoproj.github.io/argo-helm
- name: dandydeveloper
url: https://dandydeveloper.github.io/charts/
releases:
- name: argocd
namespace: argocd
createNamespace: true
chart: ./
version: 7.7.0
values:
- values/mgmt.yaml
helmDefaults:
#설치 완료까지 대기
wait: true
#600초(10분)
timeout: 600
#실패 시 롤백
atomic: true
#실패 시 정리
cleanupOnFail: true
# Hooks to ensure proper installation and upgrades
hooks:
#설치 전 의존성 업데이트
- events: ["presync"]
showlogs: true
command: "helm"
args:
- "dependency"
- "update"
- "."
#네임스페이스 생성 확인
- events: ["presync"]
showlogs: true
command: "kubectl"
args:
- "create"
- "namespace"
- "argocd"
- "--dry-run=client"
- "-o"
- "yaml"
- "||"
- "true"
Application.yaml
yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: gitlab-runners
spec:
source:
repoURL: [email protected]:server/argocd-applicationset.git
path: kuberntes-infra/cicd/gitlab-runner # helmfile.yaml이 있는 디렉토리
plugin:
name: helmfile # ArgoCD에 helmfile 플러그인 설치 필요
destination:
server: https://kubernetes.default.svc
namespace: gitlab-runner
Applicationset.yaml
yaml
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: gitlab-runners-applicationset
spec:
generators:
- list:
elements:
- name: build-image
values: build.yaml
- name: deploy-image
values: deploy.yaml
template:
metadata:
name: '{{name}}-runner'
spec:
source:
repoURL: [email protected]:server/argocd-applicationset.git
path: kuberntes-infra/cicd/gitlab-runner
plugin:
name: helmfile
env:
- name: HELMFILE_RELEASE_NAME
value: '{{name}}'
- name: HELMFILE_VALUES_FILE
value: 'values/{{values}}'
Features
환경에 따른 배포
bash
helmfile -e dev apply
helmfile -e prod apply
환경 구분방식
- dir 구분
bash
helmfile.d/dev/helmfile.yaml
helmfile.d/prod/helmfile.yaml
- yaml내 구분
yaml
environments:
dev:
values:
- values/dev.yaml
prod:
values:
- values/prod.yaml
ArgoCD Plugin 설정
- required
- helm-git
bash
helm plugin install https://github.com/aslafy-z/helm-git --version 1.4.1f
- age
bash
go install filippo.io/age/cmd/...@latest
- Repo-server
ARGOCD_EXEC_TIMEOUT정의되지 않음. 기본값: 90s- 템플릿 시간이 오래걸릴 경우 다음의 에러 발생
bash
Failed to load target state: failed to generate manifest for source 1 of 1: rpc error: code = DeadlineExceeded desc = context deadline exceeded
- 다음 두 리소스안의 모든 사이드카
deploy/argocd-repo-serverwith pluginsts/argocd-application-controller
bash
ARGOCD_EXEC_TIMEOUT=5m
- Nginx-Ingress
- 기본 타임아웃 60s
- 템플릿 시간이 오래걸릴 경우 다음의 에러 발생
bash
{"level":"fatal","msg":"rpc error: code = Unknown desc = POST https://argocd.Enterprise Cloud.hanacloudia.com:443/application.ApplicationService/Get failed with status code 504","time":"2025-12-24T15:01:43+09:00"}
ing/argo-cd-argocd-server
bash
annotations:
nginx.ingress.kubernetes.io/proxy-connect-timeout: "450"
nginx.ingress.kubernetes.io/proxy-send-timeout: "450"
nginx.ingress.kubernetes.io/proxy-read-timeout: "450"
- ArgoCD Installation Sample
- age키 파일 없이
bash
#값 파일의 중요한 속성을 암호화하는 데 개인 키를 사용하고 싶지 않다면 다음 명령을 사용하면 Argo CD와 Helmfile 플러그인을 설치할 수 있습니다... Helmfile .
cat <<EOF | helmfile apply -f -
repositories:
- name: argo
url: https://argoproj.github.io/argo-helm
releases:
- name: argocd
namespace: argocd
labels:
app: argocd
chart: argo/argo-cd
version: ~7.8.23
values:
- repoServer:
extraContainers:
- name: plugin
image: lucj/argocd-plugin-helmfile:latest
command: ["/var/run/argocd/argocd-cmp-server"]
securityContext:
runAsNonRoot: true
runAsUser: 999
volumeMounts:
- mountPath: /var/run/argocd
name: var-files
- mountPath: /home/argocd/cmp-server/plugins
name: plugins
EOF
- age키 파일 포함
bash
#값 파일의 민감한 속성을 암호화하기 위해 개인 키를 사용하려면 다음과 같이 Argo CD를 설치하세요. 이렇게 하면 key.txt 파일에 age 키가 생성되거나 기존 키를 사용할 수 있습니다.
cat <<EOF | helmfile apply -f -
repositories:
- name: argo
url: https://argoproj.github.io/argo-helm
releases:
- name: argocd
namespace: argocd
labels:
app: argocd
chart: argo/argo-cd
version: ~7.8.23
values:
- repoServer:
volumes:
- name: age
secret:
secretName: age
extraContainers:
- name: plugin
image: lucj/argocd-plugin-helmfile:latest
command: ["/var/run/argocd/argocd-cmp-server"]
securityContext:
runAsNonRoot: true
runAsUser: 999
env:
- name: SOPS_AGE_KEY_FILE
value: /app/config/age/key.txt
volumeMounts:
- name: age
mountPath: "/app/config/age/"
- mountPath: /var/run/argocd
name: var-files
- mountPath: /home/argocd/cmp-server/plugins
name: plugins
hooks:
- events: ["presync"]
showlogs: true
command: "/bin/bash"
args:
- "-ec"
- |
# Create a sops / age secret key if none already exists
if [[ -f ./key.txt ]]; then
echo "age key.txt file already exists"
else
age-keygen > ./key.txt
fi
# Create secret to give Argo access to the age key
kubectl create ns argocd || true
kubectl -n argocd create secret generic age --from-file=key.txt=./key.txt || true
- events: ["postuninstall"]
showlogs: true
command: "/bin/bash"
args:
- "-ec"
- |
# Remove secret created in the presync hook
kubectl -n argocd delete secret age
EOF
- Application Sample
bash
#샘플 마이크로서비스 애플리케이션인 VotingApp을 정의하는 다음 Argo CD 애플리케이션 리소스를 생성하세요. Argo CD는 지정된 (데모) 저장소에 있는 helmfile.yaml 파일을 사용하여 이 애플리케이션을 자동으로 배포합니다.
cat <<EOF | kubectl apply -f -
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: votingapp
namespace: argocd
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
project: default
source:
repoURL: https://gitlab.com/lucj/luc.run.git
targetRevision: main
path: misc/helmfiles/votingapp
plugin: {}
destination:
server: https://kubernetes.default.svc
namespace: vote
syncPolicy:
automated: {}
syncOptions:
- CreateNamespace=true
EOF
Leave a Reply