Helm은 Kubernetes 애플리케이션을 정의, 설치, 업그레이드할 수 있는 패키지 매니저이다.
-> 다양한 리소스를 각각 관리하지 않고 하나의 패키지로 관리하는 도구
Helm의 주요 구성 요소 3가지
- Helm 차트(Chart) : 쿠버네티스 애플리케이션의 배포 패키지이다. (차트는 여러 리소스의 묶음을 의미)
- Helm 리포지토리(Repository)
- Helm 템플릿(Template)
주요 명령어
helm 유틸리티 설치
[root@k8s-master01 ~]# curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
[root@k8s-master01 ~]# chmod 700 get_helm.sh
[root@k8s-master01 ~]# ./get_helm.sh
[root@k8s-master01 ~]# helm version
version.BuildInfo{Version:"v3.15.2", GitCommit:"1a500d5625419a524fdae4b33de351cc4f58ec35", GitTreeState:"clean", GoVersion:"go1.22.4"}
nginx 설치를 위해 repository 추가
[root@k8s-master01 ~]# helm repo add bitnami https://charts.bitnami.com/bitnami
"bitnami" has been added to your repositories
[root@k8s-master01 ~]# helm search repo nginx
NAME CHART VERSION APP VERSION DESCRIPTION
bitnami/nginx 18.1.0 1.27.0 NGINX Open Source is a web server that can be a...
bitnami/nginx-ingress-controller 11.3.6 1.10.1 NGINX Ingress Controller is an Ingress controll...
bitnami/nginx-intel 2.1.15 0.4.9 DEPRECATED NGINX Open Source for Intel is a lig...
helm 차트 다운로드
[root@k8s-master01 helm]# helm pull bitnami/nginx
[root@k8s-master01 helm]# tar zxvf nginx-18.1.0.tgz
[root@k8s-master01 helm]# rm -f nginx-18.1.0.tgz
[root@k8s-master01 helm]# ll
total 4
drwxr-xr-x 4 root root 4096 Jun 17 16:36 nginx
[root@k8s-master01 helm]# mv nginx nginx-18.1.0
[root@k8s-master01 helm]# ll
total 4
drwxr-xr-x 4 root root 4096 Jun 17 16:36 nginx-18.1.0
[root@k8s-master01 helm]# cd nginx-18.1.0/
[root@k8s-master01 nginx-18.1.0]#
[root@k8s-master01 nginx-18.1.0]# ls templates/
NOTES.txt deployment.yaml health-ingress.yaml ingress-tls-secret.yaml networkpolicy.yaml prometheusrules.yaml serviceaccount.yaml svc.yaml
_helpers.tpl extra-list.yaml hpa.yaml ingress.yaml pdb.yaml server-block-configmap.yaml servicemonitor.yaml tls-secret.yaml
디플로이먼트, 인그레스 등등 다양한 리소스가 있다. 헬름 차트는 다양한 오브젝트를 각각 설치하지 않고
단일 헬름 차트로 일괄 설치가 가능하다.
변경 내역 관리를 위해 헬름 템플릿 변수 파일 복사
[root@k8s-master01 nginx-18.1.0]# cp values.yaml my-values.yaml
replicaCount : 2 로 변경
nginx 네임스페이스 생성
[root@k8s-master01 nginx-18.1.0]# kubectl create ns nginx
[root@k8s-master01 nginx-18.1.0]# kubectl ns nginx
Context "kubernetes-admin@kubernetes" modified.
Active namespace is "nginx".
[root@k8s-master01 nginx-18.1.0]# kubectl ns
calico-apiserver
calico-system
default
default01
kube-node-lease
kube-public
kube-system
nginx
tigera-operator
nginx 네임스페이스에 nginx 헬름 차트 설치
[root@k8s-master01 nginx-18.1.0]# helm install nginx -f my-values.yaml .
> -f 옵션으로 템플릿 파일 이름 지정
[root@k8s-master01 nginx-18.1.0]# helm ls
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
nginx nginx 1 2024-06-17 16:58:43.978606824 +0900 KST deployed nginx-18.1.0 1.27.0
[root@k8s-master01 nginx-18.1.0]# kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
nginx-566b6684cc-54zmd 1/1 Running 0 47s 10.1.69.210 k8s-worker02 <none> <none>
nginx-566b6684cc-vs5w4 1/1 Running 0 47s 10.1.79.85 k8s-worker01 <none> <none>
[root@k8s-master01 nginx-18.1.0]# kubectl get deploy,svc,configmap
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/nginx 2/2 2 2 2m3s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/nginx LoadBalancer 10.102.55.231 <pending> 80:31724/TCP,443:30255/TCP 2m3s
NAME DATA AGE
configmap/kube-root-ca.crt 1 3m49s
Request/Limits 옵션
requests : 설정한 요청량 이상의 여유 자원이 있는 노드에 파드를 할당하게 하여 요청한 자원 이상 만큼 사용이 가능하도록 보장 받게한다.
limits : 사용 가능한 자원을 설정하여 제한한다.