본문 바로가기

Container/Kubernetes

[K8S] Helm

Helm은 쿠버네티스에서 애플리케이션을 정의하고, 설치하고, 관리하기 위한 패키지 매니저이다.

  • Helm 차트는 쿠버네티스 애플리케이션의 패키지를 정의하는 템플릿으로, YAML파일로 구성된다.
    •  application, tool, service를 돌리기 위해 필요한 모든 resource definition을 포함한다.
  • Helm은 쿠버네티스 리소스를 동적으로 생성할 수 있도록 템플릿 기능을 제공한다.
$ helm --help                                     
The Kubernetes package manager

Common actions for Helm:

- helm search:    search for charts
- helm pull:      download a chart to your local directory to view
- helm install:   upload the chart to Kubernetes
- helm list:      list releases of charts

Available Commands:
  completion  generate autocompletion scripts for the specified shell
  create      create a new chart with the given name
  dependency  manage a chart's dependencies
  env         helm client environment information
  get         download extended information of a named release
  help        Help about any command
  history     fetch release history
wordpress 설치 (revision 1)
$ helm install wordpress

wordpress 업그레이드 (revision 2)
$ helm upgrade wordpress
wordpress 롤백 (revision 3)
$ helm rollback wordpress

$ helm uninstall wordpress

 

$ sudo snap install helm --classic
$ pkg install helm
controlplane ~ ➜ curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3

controlplane ~ ➜  chmod 700 get_helm.sh 

controlplane ~ ➜  ./get_helm.sh 
Helm v3.17.1 is already latest
  •  Helm 2 vs Helm 3
  Helm 2 Helm 3
Tiller O X
3-way strategic Merge Patch X O
apiVersion v1 v2
  • Tiller
    • Helm CLI는 사용자가 명령줄에서 사용하는 클라이언트 프로그램으로, 쿠버네티스 애플리케이션을 패키지화하고 설치하며 관리하는 데 사용된다.
    • Tiller는 Helm 2 버전에서 클러스터 내에서 실행되며, Helm CLI로부터 명령을 받아 실제로 쿠버네티스 리소스를 생성, 업데이트, 삭제하는 역할을 했다. ( Helm CLI는 사용자로부터 명령을 받아 Tiller로 전달하며, Tiller는 클러스터 내에서 필요한 작업을 수행하고 그 결과를 Helm CLI로 반환함)
    • 하지만 Tiller는 클러스터 내에서 실행되기 때문에 복잡성과 보안 문제가 존재했다.
    • 이 때문에 Tiller 3에서는 Tiller가 완전히 제거되고 Helm CLI가 직접 쿠버네티스 API 서버와 상호작용하도록 변경되었다. ( Helm 3에서는 쿠버네티스의 네이티브 역할 기반 접근 제어(RBAC)를 활용하여 보안 관리)
  • Helm Char Structure
Templates directory
ㄴ values.yaml # Configurable values
ㄴ Chart.yaml # Chart information 
ㄴ LICENSE   # Chart License
ㄴ README.md
ㄴ Charts # Dependency Charts directory

 

  • Helm CLI
$ helm repo --help                                 
This command consists of multiple subcommands to interact with chart repositories.

It can be used to add, remove, list, and index chart repositories.

Usage:
  helm repo [command]

Available Commands:
  add         add a chart repository
  index       generate an index file given a directory containing packaged charts
  list        list chart repositories
  remove      remove one or more chart repositories
  update      update information of available charts locally from chart repositories
# 로컬 시스템에 있는 Helm 차트 저장소의 index를 업데이트하는 데 사용한다.
$ helm repo update --help                          
Update gets the latest information about charts from the respective chart repositories.
Information is cached locally, where it is used by commands like 'helm search'.

You can optionally specify a list of repositories you want to update.
        $ helm repo update <repo_name> ...
To update all the repositories, use 'helm repo update'.

Usage:
  helm repo update [REPO1 [REPO2 ...]] [flags]
  • Finding Charts
$ helm search wordpress 

Search provides the ability to search for Helm charts in the various places
they can be stored including the Artifact Hub and repositories you have added.
Use search subcommands to search different locations for charts.

Usage:
  helm search [command]

Available Commands:
  hub         search for charts in the Artifact Hub or your own hub instance
  repo        search repositories for a keyword in charts
  
# hub나 repository 지정 필요
# 관련된 모든 차트 나열
$ helm search hub wordpress                        
URL                                                     CHART VERSION   APP VERSION             DESCRIPTION                                       
https://artifacthub.io/packages/helm/wordpress-...      1.0.2           1.0.0                   A Helm chart for deploying Wordpress+Mariadb st...
https://artifacthub.io/packages/helm/kube-wordp...      0.1.0           1.1                     this is my wordpress package                      
https://artifacthub.io/packages/helm/bitnami/wo...      24.1.11         6.7.2                   WordPress is the world's most popular blogging ...
https://artifacthub.io/packages/helm/bitnami-ak...      15.2.13         6.1.0                   WordPress is the world's most popular blogging ...
..
  • Deploying Wordpress
# 레파지토리 추가
$ helm repo add bitnami https://charts.bitnami.com/bitnami
"bitnami" has been added to your repositories

# 새로 추가된 bitnami repo로부터 wordpress 패키지 찾기
$ helm search repo wordpress
NAME                    CHART VERSION   APP VERSION     DESCRIPTION                                       
bitnami/wordpress       24.1.12         6.7.2           WordPress is the worlds most popular blogging ...
bitnami/wordpress-intel 2.1.31          6.1.1           DEPRECATED WordPress for Intel is the most popu...

$ helm install my-release bitnami/wordpress

# helm install release-name repo/application
$ helm install amaze-surf bitnami/apache
Pulled: us-central1-docker.pkg.dev/kk-lab-prod/helm-charts/bitnami/apache:11.3.2
Digest: sha256:1bd45c97bb7a0000534e3abc5797143661e34ea7165aa33068853c567e6df9f2
NAME: amaze-surf
LAST DEPLOYED: Fri Feb 21 08:26:05 2025
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: apache
CHART VERSION: 11.3.2
APP VERSION: 2.4.63
  • Helm Release
# 설치된 package 또는 오랫동안 update되지 않은 package 확인
$helm list
NAME            NAMESPACE       REVISION        UPDATED                                  STATUS          CHART           APP VERSION
amaze-surf      default         1               2025-02-21 08:26:05.630345493 +0000 UTC  deployed        apache-11.3.2   2.4.63     
crazy-web       default         1               2025-02-21 08:27:04.226973057 +0000 UTC  deployed        nginx-19.0.0    1.27.4     
happy-browse    default         1               2025-02-21 08:27:02.270144437 +0000 UTC  deployed        nginx-19.0.0    1.27.4 

# release uninstall
$ helm uninstall happy-browse
release "happy-browse" uninstalled
  • Helm Repo
$ helm repo

This command consists of multiple subcommands to interact with chart repositories.

It can be used to add, remove, list, and index chart repositories.

Usage:
  helm repo [command]

Available Commands:
  add         add a chart repository
  index       generate an index file given a directory containing packaged charts
  list        list chart repositories
  remove      remove one or more chart repositories
  update      update information of available charts locally from chart repositories

$ helm repo list
NAME            URL                                                 
bitnami         https://charts.bitnami.com/bitnami                  
puppet          https://puppetlabs.github.io/puppetserver-helm-chart
hashicorp       https://helm.releases.hashicorp.com

$ helm repo remove hashicorp
"hashicorp" has been removed from your repositories

$ helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "puppet" chart repository
...Successfully got an update from the "bitnami" chart repository
Update Complete. ⎈Happy Helming!⎈
  • Flag Parsing
    • --debug: If this is specified, $HELM_DEBUG is set to 1
    • --registry-config: This is converted to $HELM_REGISTRY_CONFIG
    • --repository-cache: This is converted to $HELM_REPOSITORY_CACHE
    • --repository-config: This is converted to $HELM_REPOSITORY_CONFIG
    • --namespace and -n: This is converted to $HELM_NAMESPACE
    • --kube-context: This is converted to $HELM_KUBECONTEXT
    • --kubeconfig: This is converted to $KUBECONFIG

참고: https://helm.sh/docs/intro/quickstart/

반응형

'Container > Kubernetes' 카테고리의 다른 글

[K8S] Upgrading a helm chart - kodekloud 실습  (0) 2025.02.21
[K8S] Lifecycle management with Helm  (0) 2025.02.21
[K8S] Troubleshoot Network 예제  (0) 2025.02.12
[K8S] Kubectl - jsonpath  (0) 2025.02.10
[K8S] Network & CNI  (0) 2025.02.06