...
일단 먼저 사용 방법을 익히고, 어떻게 사용하는 것이 good practice인지 알아가 보려고 한다.
Terms
Chart는 Helm 패키지이다. 이 패키지에는 k8s 클러스터 내에서 애플리게이션, 도구, 서비스를 구동하는데 필요한 모들 리소스 정의가 포함되어 있다. k8s에서의 Homebrew 포뮬러, Apt dpkg, YUM RPM 파일과 같은 것으로 생각할 수 있다.
...
모든 SW가 그렇듯, Helm도 버전에 따라 차이가 있는데, 이 글에서 사용하는 v3과 version1,2의 아키텍처 상으로 가장 큰 차이는 더 이상 Tiller server가 필요하지 않고, Helm 클라이언트 만으로 chart 배포 관리를 할 수 있다는 점이다.
Code Block |
---|
$ helm version
version.BuildInfo{Version:"v3.4.1", GitCommit:"c4e74854886b2efe3321e185578e6db9be0a6e29", GitTreeState:"clean", GoVersion:"go1.14.11"} |
How to install
Helm은 k8s 용 소프트웨어를 검색하거나, 공유하고 사용하기 위한 K8s Package Manager이며,
...
먼저 여기서는 Linux 환경에서 설치할 것이므로, snap을 사용하여 설치하겠다.
Install Snap
...
Code Block |
---|
$ sudo ln -s /var/lib/snapd/snap /snap |
Install Helm
Snapcrafters 커뮤니티는 Helm 패키지의 Snap 버전을 유지 보수한다.
...
Code Block | ||
---|---|---|
| ||
$ helm search repo stable|head -n10 NAME CHART VERSION APP VERSION DESCRIPTION nginx-stable/nginx-ingress 0.7.0 1.9.0 NGINX Ingress Controller stable/acs-engine-autoscaler 2.2.2 2.1.1 NAME DEPRECATED Scales worker nodes within agent pools stable/aerospike CHART VERSION APP VERSION 0.3.5 DESCRIPTIONv4.5.0.5 DEPRECATED A Helm chart for Aerospike in Kubern... stable/airflow 7.13.3 1.10.12 DEPRECATED - please use: https://github.com/air... stable/ambassador stable/acs-engine-autoscaler 2.25.3.2 20.186.1 DEPRECATED ScalesA workerHelm nodeschart withinfor agentDatawire poolsAmbassador stable/anchore-engine 1.7.0 0.7.3 Anchore container analysis and policy stable/aerospikeevaluatio... stable/apm-server 02.31.57 v47.50.0.5 DEPRECATED AThe Helmserver chartreceives fordata Aerospikefrom inthe KubernEl... stable/ark 4.2.2 0.10.2 DEPRECATED A stable/airflowHelm chart for ark stable/artifactory 7.133.32 6.1.10.120 DEPRECATED -Universal pleaseRepository use: https://github.com/air... stable/ambassador 5.3.2 0.86.1 DEPRECATED A Helm chart for Datawire Ambassador stable/anchore-engine 1.7.0 0.7.3 Anchore container analysis and policy evaluatio... stable/apm-server 2.1.7 7.0.0 DEPRECATED The server receives data from the El... stable/ark 4.2.2 0.10.2 DEPRECATED A Helm chart for ark stable/artifactory 7.3.2 6.1.0 DEPRECATED Universal Repository Manager support... stable/artifactory-ha 0.4.2 6.2.0 DEPRECATED Universal Repository Manager support... |
해서, 원하는 application package 버전의 Chart를 찾아서 repo add 하여 사용한다.
다음 섹션에서 자세히 다루기로 한다.
Using Helm
Using Helm Repo
Find a package
이 전 섹션에서 다룬 것처럼, 기본 stable repo는 DEPRECATED 된 chart가 많아서, 최신 버전 혹은 원하는 버전을 찾기 어렵다.
원하는 application의 chart를 찾기 위해서는 여러 방법이 있는데,
여기에서는 Helm에서 공식 관리하는 Artifact Hub를 사용하여 원하는 chart를 가진 repo를 등록해보자.
Artifact Hub: https://artifacthub.io/
위 사이트에 접속하여 influxdb를 검색해보자.
아래와 같이 결과 화면이 출력 될 것이다.
Info |
---|
|
원하는 버전의 repo를 아래와 같이 복사한다.
...
Info |
---|
이 외에도 자사 제품의 손쉬운 배포 관리를 지원하기 위해, 예, https://github.com/influxdata/helm-charts 또한, https://github.com/helm/monocular 도 많이 사용한다. |
Add into the repo.
Code Block | ||
---|---|---|
| ||
# Add repository
$ helm repo add bitnami https://charts.bitnami.com/bitnami
# List up repo
$ helm repo list
NAME URL
stable https://charts.helm.sh/stable
nginx-stable https://helm.nginx.com/stable
bitnami https://charts.bitnami.com/bitnami # bitnami repo가 추가되었다.
monocular https://helm.github.io/monocular
influxdata https://helm.influxdata.com/ |
Search Chart
아래와 같이 localhost에 등록된 모든 repo에서 influxdb chart를 찾는다.
Code Block | ||
---|---|---|
| ||
$ helm search repo influxdb NAME CHART VERSION APP VERSION DESCRIPTION bitnami/influxdb 1.0.0 1.8.3 InfluxDB is an open source time-series database... influxdata/influxdb 4.8.9 1.8.0 Scalable datastore for metrics, events, and rea... influxdata/influxdb-enterprise 0.1.12 1.8.0 Run InfluxDB Enterprise on Kubernetes influxdata/influxdb2 1.0.11 2.0.0-rc A Helm chart for InfluxDB v2 Manager support... |
해서, 원하는 application package 버전의 Chart를 찾아서 repo add 하여 사용한다.
다음 섹션에서 자세히 다루기로 한다.
Using Helm
Using Helm Repo
Find a package
이 전 섹션에서 다룬 것처럼, 기본 stable repo는 DEPRECATED 된 chart가 많아서, 최신 버전 혹은 원하는 버전을 찾기 어렵다.
원하는 application의 chart를 찾기 위해서는 여러 방법이 있는데,
여기에서는 Helm에서 공식 관리하는 Artifact Hub를 사용하여 원하는 chart를 가진 repo를 등록해보자.
Artifact Hub: https://artifacthub.io/
위 사이트에 접속하여 influxdb를 검색해보자.
아래와 같이 결과 화면이 출력 될 것이다.
Info |
---|
|
원하는 버전의 repo를 아래와 같이 복사한다.
...
Info |
---|
이 외에도 자사 제품의 손쉬운 배포 관리를 지원하기 위해, 예, https://github.com/influxdata/helm-charts
|
Add into the repo.
Code Block | ||
---|---|---|
| ||
# Add repository $ helm repo add bitnami https://charts.bitnami.com/bitnami # List up repo $ helm repo list NAME URL stable https://charts.helm.sh/stable nginx-stable https://helm.nginx.com/stable bitnami stable/influxdb https://charts.bitnami.com/bitnami # bitnami repo가 추가되었다. monocular 4.3.2 https://helm.github.io/monocular influxdata 1.7.9 https://helm.influxdata.com/ |
Search Chart
아래와 같이 localhost에 등록된 모든 repo에서 influxdb chart를 찾는다.
Code Block | ||
---|---|---|
| ||
$ helm search repo influxdb NAME DEPRECATED Scalable datastore for metrics, even... CHART VERSION APP VERSION DESCRIPTION bitnami/influxdb 1.0.0 1.8.3 InfluxDB is an open source time-series bitnami/grafana database... influxdata/influxdb 4.08.29 71.38.30 GrafanaScalable isdatastore anfor openmetrics, sourceevents, featureand rich metricsrea... influxdata/influxdb-enterprise 0.1.12 1.8.0 Run InfluxDB Enterprise on Kubernetes influxdata/influxdb2 1.0.11 2.0.0-rc A Helm chart for InfluxDB v2 stable/influxdb influxdata/kapacitor 4.3.2 1.37.19 DEPRECATED 1.5.4Scalable datastore for metrics, even... bitnami/grafana InfluxDB's native data processing engine. It ca... 4.0.2 7.3.3 Grafana is an open source, feature rich metrics... influxdata/kapacitor 1.3.1 1.5.4 InfluxDB's native data processing engine. It ca... stable/kapacitor 1.2.2 1.5.2 DEPRECATED InfluxDB's native data processing en... influxdata/chronograf 1.1.19 1.8.8 Open-source web application written in Go and R... influxdata/telegraf 1.7.32 1.16 Telegraf is an agent written in Go for collecti... influxdata/telegraf-operator influxdata/chronograf1.1.5 v1.1.1.19 1.8.8A Helm chart for Kubernetes to deploy Open-source web application written in Go and R... influxdata/telegraf 1.7.32 1.16 Telegraf is an agent written in Go for collecti... telegraf-... |
Install Chart
Basic install Chart
기본적인 chart 설치 명령은 다음과 같다.
Code Block | ||
---|---|---|
| ||
# Generate Release name.
$ helm install bitnami/nginx -n ns-test01 -g
# Or Specify Release name as "nginx-test".
$ helm install nginx-test bitnami/nginx -n ns-test01 |
Install Customized Chart
대부분의 경우 선호하는 구성을 사용하기 위해 차트를 커스터마이징 하게 될 것이다.
차트에 어떤 옵션이 구성 가능한지 보려면, helm show values
를 사용한다.
Code Block | ||
---|---|---|
| ||
$ helm show values bitnami/nginx
## Global Docker image parameters
## Please, note that this will override the image parameters, including dependencies, configured to use the global value
## Current available global Docker image parameters: imageRegistry and imagePullSecrets
##
# global:
# imageRegistry: myRegistryName
# imagePullSecrets:
# - myRegistryKeySecretName
## Bitnami NGINX image version
## ref: https://hub.docker.com/r/bitnami/nginx/tags/
##
image:
registry: docker.io
...
(omit)
## NGINX Service properties
##
service:
## Service type
##
type: LoadBalancer
## HTTP Port
##
port: 80
## HTTPS Port
##
httpsPort: 443
...
(omit) |
Using with --set
옵션
위에서 type: LoadBalancer
를 NodePort
로 변경하길 원한다면, 아래와 같이 설정할 수 있다.
(namespace
지정하지 않으면 default namespace
로 지정된다.)
Code Block | ||
---|---|---|
| ||
$ kubectl create ns ns-test01 $ helm install bitnami/nginx -n ns-test01 -g --set service.type=NodePort # 확인 $ helm ls -n ns-test01 NAME NAMESPACE influxdata/telegraf-operator 1.1.5REVISION UPDATED v1.1.1 A Helm chart for Kubernetes to deploy telegraf-... |
Install Chart
Basic install Chart
기본적인 chart 설치 명령은 다음과 같다.
Code Block | ||
---|---|---|
| ||
# Generate Release name.
$ helm install bitnami/nginx -n ns-test01 -g
# Specify Release name as "nginx-test".
$ helm install nginx-test bitnami/nginx -n ns-test01 |
Install Customized Chart
대부분의 경우 선호하는 구성을 사용하기 위해 차트를 커스터마이징 하게 될 것이다.
차트에 어떤 옵션이 구성 가능한지 보려면, helm show values
를 사용한다.
Code Block | ||
---|---|---|
| ||
$ helm show values bitnami/nginx
## Global Docker image parameters
## Please, note that this will override the image parameters, including dependencies, configured to use the global value
## Current available global Docker image parameters: imageRegistry and imagePullSecrets
##
# global:
# imageRegistry: myRegistryName
# imagePullSecrets:
# - myRegistryKeySecretName
## Bitnami NGINX image version
## ref: https://hub.docker.com/r/bitnami/nginx/tags/
##
image:
registry: docker.io
...
(omit)
## NGINX Service properties
##
service:
## Service type
##
type: LoadBalancer
## HTTP Port
##
port: 80
## HTTPS Port
##
httpsPort: 443
...
(omit) |
Using with --set
옵션
위에서 type: LoadBalancer
를 NodePort
로 변경하길 원한다면, 아래와 같이 설정할 수 있다.
(namespace
지정하지 않으면 default namespace
로 지정된다.)
Code Block | ||
---|---|---|
| ||
$ kubectl create ns ns-test01 STATUS CHART APP VERSION nginx-1606192435 ns-test01 1 2020-11-24 13:33:57.905368836 +0900 KST deployed nginx-8.1.0 1.19.4 # svc 확인 $ kubectl get svc -n ns-test01 NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE nginx-1606192435 NodePort 10.100.99.47 <none> 80:31639/TCP 95m |
Using with --values(or -f)
옵션
Code Block | ||
---|---|---|
| ||
# Make yaml file with overrides. $ vim config.yaml service: type: NodePort $ helm install bitnami/nginx-g -n ns-test01 -g --set service.type=NodePortf config.yaml bitnami/nginx # 확인 $ helm ls -n ns-test01 NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION nginx-1606192435 ns-test01 1 2020-11-24 13:33:57.905368836 +0900 KST deployed CHART nginx-8.1.0 APP VERSION1.19.4 nginx-16061924351606197987 ns-test01 1 2020-11-24 1315:3306:5730.905368836102370781 +0900 KST deployed nginx-8.1.0 1.19.4 # svc 확인 $ kubectl get svc -n ns-test01 NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S)IP EXTERNAL-IP PORT(S) AGE nginx-1606192435 NodePort 10.100.99.47 <none> 80:31639/TCP AGE95m nginx-16061924351606197987 NodePort 10.10096.9987.47201 <none> 80:3163930435/TCP 95m |
...
3m8s |
--set
과 --values(or
...
-f)
를 지정하는 자세한 가이드는 Helm 공식 가이드(링크)를 참고하도록 한다.
Via Download Chart package
위 섹션들에서와 같이 설치를 원하는 chart의 내용을 조회 후, --set
등을 통해 설치할 수도 있지만, helm pull
명령을 통해 chart package를 다운로드 후 직접 수정하여 설치할 수도 있다.
Code Block | ||
---|---|---|
| ||
# Make yaml file with overrides. $ vim config.yaml service: type: NodePort $ helm install -g -n ns-test01 -f config.yamlhelm pull bitnami/nginx # 확인 $ helm ls -n ns-test01 NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION nginx-1606192435 ns-test01 1 2020-11-24 13:33:57.905368836 +0900 KST deployed nginx-8.1.0 1.19.4 nginx-1606197987 ns-test01 1nginx-8.1.0.tgz $ tar xzf nginx-8.1.0.tgz $ cd nginx $ ls -l total 76 -rw-r--r--. 1 root root 219 Nov 18 23:45 Chart.lock drwxr-xr-x. 3 root root 20 Nov 23 13:25 charts -rw-r--r--. 1 root root 599 Nov 18 23:45 Chart.yaml drwxr-xr-x. 2 root root 84 Nov 23 13:25 ci -rw-r--r--. 1 root root 38884 Nov 18 23:45 README.md drwxr-xr-x. 2 root root 4096 Nov 23 13:25 templates -rw-r--r--. 1 root root 1880 Nov 18 23:45 values.schema.json -rw-r--r--. 1 root root 19786 Nov 23 13:58 values.yaml |
위에 압축 해제된 파일들 중 원하는(보통의 경우 values.yaml이 될 것이다) 파일을 수정하여, 아래 명령으로 설치하면 된다.
Code Block | ||
---|---|---|
| ||
# bitnami/nginx 대신 ./nginx로 지정.
$ helm install -g -n ns-test01 ./nginx |
Uninstall Chart
Helm Release 확인
Code Block | ||
---|---|---|
| ||
$ helm ls -A NAME 2020-11-24 15:06:30.102370781 +0900 KST deployed NAMESPACE nginx-8.1.0 REVISION 1.19.4 # svc 확인 $UPDATED kubectl get svc -n ns-test01 NAME TYPE CLUSTER-IP EXTERNAL-IPSTATUS PORT(S) CHART AGE nginx-1606192435 NodePort 10.100.99.47 <none>APP VERSION nginx-1606191524 80:31639/TCP default 95m nginx-1606197987 NodePort 10.96.87.201 1 <none> 80:30435/TCP 3m8s2020- |
...
Via Download Chart package
위 섹션들에서와 같이 설치를 원하는 chart의 내용을 조회 후, --set
등을 통해 설치할 수도 있지만, helm pull
명령을 통해 chart package를 다운로드 후 직접 수정하여 설치할 수도 있다.
Code Block | ||
---|---|---|
| ||
$ helm pull bitnami/nginx $ ls11-24 13:18:46.768504183 +0900 KST deployed nginx-8.1.0.tgz $ tar xzf nginx-8.1.0.tgz $ cd nginx $ ls -l total 76 -rw-r--r--. 1 root root 219 Nov 18 23:45 Chart.lock drwxr-xr-x. 3 root root 20 Nov 23 13:25 charts -rw-r--r--. 1 root root 599 Nov 18 23:45 Chart.yaml drwxr-xr-x. 2 root root 84 Nov 23 13:25 ci -rw-r--r--. 1 root root 38884 Nov 18 23:45 README.md drwxr-xr-x. 2 root root 4096 Nov 23 13:25 templates -rw-r--r--. 1 root root 1880 Nov 18 23:45 values.schema.json -rw-r--r--. 1 root root 19786 Nov 23 13:58 values.yaml |
위에 압축 해제된 파일들 중 원하는(보통의 경우 values.yaml이 될 것이다) 파일을 수정하여, 아래 명령으로 설치하면 된다.
Code Block | ||
---|---|---|
| ||
# bitnami/nginx 대신 ./nginx로 지정. $ helm install -g -n ns-test01 ./nginx19.4 nginx-1606192435 ns-test01 1 2020-11-24 13:33:57.905368836 +0900 KST deployed nginx-8.1.0 1.19.4 nginx-1606197987 ns-test01 1 2020-11-24 15:06:30.102370781 +0900 KST deployed nginx-8.1.0 1.19.4 |
Uninstall a certain Release
Code Block |
---|
# Usage:
# helm uninstall RELEASE_NAME [...] [flags]
# Aliases:
# uninstall, del, delete, un
$ helm uninstall -n default nginx-1606191524
release "nginx-1606191524" uninstalled |