...
일단 먼저 사용 방법을 익히고, 어떻게 사용하는 것이 good practice인지 알아가 보려고 한다.
Terms
Chart는 Helm 패키지이다. 이 패키지에는 k8s 클러스터 내에서 애플리게이션, 도구, 서비스를 구동하는데 필요한 모들 리소스 정의가 포함되어 있다. k8s에서의 Homebrew 포뮬러, Apt dpkg, YUM RPM 파일과 같은 것으로 생각할 수 있다.
...
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 버전을 유지 보수한다.
...
해서, 원하는 application package 버전의 Chart를 찾아서 repo add 하여 사용한다.
다음 섹션에서 자세히 다루기로 한다.
Using Helm
Using Helm Repo
Find a package
이 전 섹션에서 다룬 것처럼, 기본 stable repo는 DEPRECATED 된 chart가 많아서, 최신 버전 혹은 원하는 버전을 찾기 어렵다.
...
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 stable/influxdb 4.3.2 1.7.9 DEPRECATED Scalable datastore for metrics, even... bitnami/grafana 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 1.1.5 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
대부분의 경우 선호하는 구성을 사용하기 위해 차트를 커스터마이징 하게 될 것이다.
...
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 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 # 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 -g -n ns-test01 -f 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 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 # 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 nginx-1606197987 NodePort 10.96.87.201 <none> 80:30435/TCP 3m8s |
--set
과 --values(or -f)
를 지정하는 자세한 가이드는 Helm 공식 가이드(링크)를 참고하도록 한다.
Via Download Chart package
위 섹션들에서와 같이 설치를 원하는 chart의 내용을 조회 후, --set
등을 통해 설치할 수도 있지만, helm pull
명령을 통해 chart package를 다운로드 후 직접 수정하여 설치할 수도 있다.
...