본문 바로가기

리눅스

[draft] Kubernetes Helm 패키지 관리자

728x90

Kubernetes Helm 패키지 관리자

Helm은 Kubernetes의 패키지 관리자로 애플리케이션을 배포하고 관리하는 데 유용한 도구입니다. Helm을 사용하면 애플리케이션과 관련된 모든 Kubernetes 리소스를 패키지화하여 배포하고 버전 관리를 하며 재사용할 수 있습니다.

Helm 패키지 설치

Helm 스크립트 설치

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 바이너리 다운로드

curl -fsSL -o helm.tar.gz https://get.helm.sh/helm-v3.7.2-linux-amd64.tar.gz

압축 해제

tar xfz elm.tar.gz

Helm 바이너리 이동

sudo mv linux-amd64/helm /usr/local/bin/.

설치 확인

helm version
$ helm version
version.BuildInfo{Version:"v3.7.2", GitCommit:"663a896f4a815053445eec4153677ddc24a0a361", GitTreeState:"clean", GoVersion:"go1.16.10"}

Helm 사용 방법

helm search 명령

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

Flags:
  -h, --help   help for search

Global Flags:
      --debug                       enable verbose output
      --kube-apiserver string       the address and the port for the Kubernetes API server
      --kube-as-group stringArray   group to impersonate for the operation, this flag can be repeated to specify multiple groups.
      --kube-as-user string         username to impersonate for the operation
      --kube-ca-file string         the certificate authority file for the Kubernetes API server connection
      --kube-context string         name of the kubeconfig context to use
      --kube-token string           bearer token used for authentication
      --kubeconfig string           path to the kubeconfig file
  -n, --namespace string            namespace scope for this request
      --registry-config string      path to the registry config file (default "/home/edu/.config/helm/registry.json")
      --repository-cache string     path to the file containing cached repository indexes (default "/home/edu/.cache/helm/repository")
      --repository-config string    path to the file containing repository names and URLs (default "/home/edu/.config/helm/repositories.yaml")

Use "helm search [command] --help" for more information about a command.

현재 저장소의 목록

helm repo list
$ helm repo list
Error: no repositories to show

Artifact HUB

Artifact_HUB
Artifact_HUB

bitnami 저장소 추가

helm repo add bitnami https://charts.bitnami.com/bitnami
$ helm repo add bitnami https://charts.bitnami.com/bitnami
"bitnami" has been added to your repositories
helm repo list
$ helm repo list
NAME   	URL
bitnami	https://charts.bitnami.com/bitnami

Helm 차트 저장소 검색

helm search repo mysql
$ helm search repo mysql
NAME                  	CHART VERSION	APP VERSION	DESCRIPTION
bitnami/mysql         	9.3.4        	8.0.30     	MySQL is a fast, reliable, scalable, and easy t...
bitnami/phpmyadmin    	10.3.4       	5.2.0      	phpMyAdmin is a free software tool written in P...
bitnami/mariadb       	11.3.1       	10.6.10    	MariaDB is an open source, community-developed ...
bitnami/mariadb-galera	7.4.3        	10.6.10    	MariaDB Galera is a multi-primary database clus...

Helm 차트 저장소 최신 목록 업데이트

helm repo update
$ helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "bitnami" chart repository
Update Complete. ⎈Happy Helming!⎈

Helm 차트 저장소 삭제

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

Helm 차트 저장소의 전체 차트 목록 확인

helm search hub

helm search hub mysql

Helm 저장소 전체 차트 목록 확인

helm search repo
$ helm search repo
Error: no repositories configured

Helm 차트 정보 확인

  • helm show chart [CAHRT] : 차트 정보(버전, 홈페이지, 키워드, 소스 주소 등)
  • helm show readme [CAHRT] : 차트 설명(사용법, 파라미터 등)
  • helm show values [CAHRT] : 차트 설정 파라미터
  • helm show all [CAHRT] : Chart, Readme, Values

Helm 차트 설치 및 관리

mysql 설치

helm repo add bitnami https://charts.bitnami.com/bitnami
$ helm repo list
NAME   	URL
bitnami	https://charts.bitnami.com/bitnami
helm install mydb bitnami/mysql
$ helm list
NAME	NAMESPACE	REVISION	UPDATED                                	STATUS  	CHART      	APP VERSION
mydb	default  	1       	2022-09-24 11:28:52.527728869 +0900 KST	deployed	mysql-9.3.4	8.0.30
$ helm show chart bitnami/mysql
annotations:
  category: Database
apiVersion: v2
appVersion: 8.0.30
dependencies:
- name: common
  repository: https://charts.bitnami.com/bitnami
  tags:
  - bitnami-common
  version: 2.x.x
description: MySQL is a fast, reliable, scalable, and easy to use open source relational
  database system. Designed to handle mission-critical, heavy-load production applications.
home: https://github.com/bitnami/charts/tree/master/bitnami/mysql
icon: https://bitnami.com/assets/stacks/mysql/img/mysql-stack-220x234.png
keywords:
- mysql
- database
- sql
- cluster
- high availability
maintainers:
- name: Bitnami
  url: https://github.com/bitnami/charts
name: mysql
sources:
- https://github.com/bitnami/containers/tree/main/bitnami/mysql
- https://mysql.com
version: 9.3.4

mysql root 패드워드 사용자 정의

helm install mydb bitnami/mysql --set "auth.rootPassword=Passw0rd!"

설정한 mysql root 패스워드 확인

$ kubectl get secrets --namespace default mydb-mysql -o jsonpath="{.data.mysql-root-password}" | base64 -d
Passw0rd!
$ kubectl get svc
NAME                  TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE
kubernetes            ClusterIP   10.100.0.1       <none>        443/TCP    20h
mydb-mysql            ClusterIP   10.100.192.148   <none>        3306/TCP   37s
mydb-mysql-headless   ClusterIP   None             <none>        3306/TCP   37s

다른 컨테이너에서 mysql 접근 테스트

kubectl run centos7 --image anti1346/centos:7 -it --rm -- bash
mysql -h10.100.192.148 -uroot -p'P@ssw0rd'
select version();
$ mysql -h10.100.192.148 -uroot -p'P@ssw0rd'
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 19
Server version: 8.0.30 Source distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]> select version();
+-----------+
| version() |
+-----------+
| 8.0.30    |
+-----------+
1 row in set (0.00 sec)

MySQL [(none)]>

 

참고URL

- https://github.com/helm/helm/releases

- https://helm.sh/docs/intro/install/

- https://artifacthub.io/packages/helm/bitnami/mysql

- https://community.chocolatey.org/packages/kubernetes-helm/3.7.2#install

 

728x90