Helm
Kubernetes Helm
A Kubernetes package manager. Defines, deploys, and manages applications as charts.
Kubernetes Helm
A Kubernetes package manager. Defines, deploys, and manages applications as charts.
Helm is the package manager for Kubernetes applications. Like apt/yum on Linux and npm for Node.js, Helm bundles complex Kubernetes resources into packages called "Charts," making installation, upgrades, and rollbacks easy. As a CNCF graduated project, it is a core tool in the Kubernetes ecosystem.
# Chart.yaml
apiVersion: v2
name: my-app
description: A Helm chart for My Application
type: application
version: 1.0.0 # ์ฐจํธ ๋ฒ์
appVersion: "2.1.0" # ์ ํ๋ฆฌ์ผ์ด์
๋ฒ์
keywords:
- app
- web
home: https://github.com/myorg/my-app
sources:
- https://github.com/myorg/my-app
maintainers:
- name: Platform Team
email: platform@myorg.com
dependencies:
- name: postgresql
version: "12.x.x"
repository: https://charts.bitnami.com/bitnami
condition: postgresql.enabled
- name: redis
version: "17.x.x"
repository: https://charts.bitnami.com/bitnami
condition: redis.enabled
# values.yaml
replicaCount: 2
image:
repository: myorg/my-app
tag: "" # Chart.yaml์ appVersion ์ฌ์ฉ
pullPolicy: IfNotPresent
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
serviceAccount:
create: true
annotations: {}
name: ""
service:
type: ClusterIP
port: 80
ingress:
enabled: false
className: nginx
annotations: {}
hosts:
- host: my-app.local
paths:
- path: /
pathType: Prefix
tls: []
resources:
limits:
cpu: 500m
memory: 512Mi
requests:
cpu: 100m
memory: 128Mi
autoscaling:
enabled: false
minReplicas: 2
maxReplicas: 10
targetCPUUtilizationPercentage: 80
nodeSelector: {}
tolerations: []
affinity: {}
# ํ๊ฒฝ ๋ณ์
env:
LOG_LEVEL: info
DB_HOST: postgresql
# ์์กด์ฑ ์ค์
postgresql:
enabled: true
auth:
database: myapp
username: myapp
redis:
enabled: false
# templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "my-app.fullname" . }}
labels:
{{- include "my-app.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "my-app.selectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
labels:
{{- include "my-app.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "my-app.serviceAccountName" . }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 8080
protocol: TCP
env:
{{- range $key, $value := .Values.env }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
livenessProbe:
httpGet:
path: /health
port: http
initialDelaySeconds: 30
readinessProbe:
httpGet:
path: /ready
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
# ์ ์ฅ์ ๊ด๋ฆฌ
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update
helm search repo nginx
# ์ฐจํธ ์ค์น
helm install my-release bitnami/nginx
helm install my-app ./my-app-chart -f values-prod.yaml
helm install my-app ./my-app-chart --set replicaCount=3
# ๋ฆด๋ฆฌ์ค ๊ด๋ฆฌ
helm list
helm status my-release
helm get values my-release
# ์
๊ทธ๋ ์ด๋
helm upgrade my-release bitnami/nginx --version 15.0.0
helm upgrade my-app ./my-app-chart -f values-prod.yaml
# ๋กค๋ฐฑ
helm history my-release
helm rollback my-release 2
# ์ญ์
helm uninstall my-release
# ๋๋ฒ๊น
helm template my-app ./my-app-chart # ๋ ๋๋ง๋ YAML ํ์ธ
helm lint ./my-app-chart # ์ฐจํธ ๊ฒ์ฆ
helm install my-app ./my-app-chart --dry-run --debug # ์ค์ ์ค์น ์์ด ํ
์คํธ
Do not store plaintext passwords in values.yaml. Use the helm-secrets plugin or External Secrets Operator.
Helm stores release information in a Secret (default) or ConfigMap. Limit old revisions with the `--history-max` option.
In production, always specify the chart version. Specifying a particular version with `helm upgrade --version 12.3.4` can prevent unexpected changes.
If Go templates become overly complex, they are hard to maintain. Avoid too many conditionals, and split into multiple charts when necessary.