개인적으론 helm 은 yum/apt/apk 와 비슷한 형태로 보고 있다.
그래서, helm을 이용하면, Kubernetes에 APP들을 편하게 한 번에 설치할 수 있다.
최근에 작업했던 클라우드 DNS상품을 helm chart로 직접 패키징 해서 배포하는 환경을 만들었었는데, helm chart배포가 선언적 형태(Declarative)의 성격을 가지고 있어서 배포한 쿠버네티스가 망가져도 얼마든지 다른 쿠버네티스에서 바로 복구할 수 있다는 자신감이 생기더라.
(언제든 helm chart 만 있으면, 어느 쿠버네티스 클러스터에서도 동일한 형태의 앱을 띄울 수 있다.)
helm2 까지는 Tiller까지 잘 떴는지 확인해야 해서 조금 신경 쓸게 있었는데, helm3 에선 그냥 kubectl 이 설치된 환경에 설치만 하면 되니 아주 편해졌다.
저번에 DigitalOcean Kubernetes Pool 만든거에 편하게 배포를 좀 해보려고, helm을 설치하고 테스트해봤다.
신기한 건 helm 홈페이지에 한국어도 지원이 되어 있다는 사실이었다. 😱
## helm 설치하기
- kubectl 설정이 된 환경에서 진행을 해주는 게 포인트고, 여러 설치 방법이 있지만 나는 script 설치 방식으로 설치를 진행했다.
alinos@DESKTOP-A52MBHK:~/helm$ curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
alinos@DESKTOP-A52MBHK:~/helm$ chmod 700 get_helm.sh
alinos@DESKTOP-A52MBHK:~/helm$ vi get_helm.sh
alinos@DESKTOP-A52MBHK:~/helm$ ./get_helm.sh
Downloading https://get.helm.sh/helm-v3.2.4-linux-amd64.tar.gz
Preparing to install helm into /usr/local/bin
[sudo] password for alinos:
helm installed into /usr/local/bin/helm
alinos@DESKTOP-A52MBHK:~/helm$ source <(helm completion bash)
alinos@DESKTOP-A52MBHK:~/helm$ echo "source <(helm completion bash)" >> ~/.profile
### helm repo 추가 후 테스트 app 설치하기
- helm stable repo를 추가하면, 최신 트렌드의 app 들을 찾아서 쉽게 설치할 수 있다.
- helm hub에서도 여러 패키지를 찾을 수 있는데, 그중 간단한 app인 echo-server를 설치해본다. 다음과 같이 echo-server를 찾은 후에 helm repo를 추가하고 설치를 진행한다.
- https://hub.helm.sh 사이트에 들어가면 웹뷰로도 패키지들을 살펴볼 수 있다.
alinos@DESKTOP-A52MBHK:~/helm$ # helm stable repo
alinos@DESKTOP-A52MBHK:~/helm$ helm repo add stable https://kubernetes-charts.storage.googleapis.com/
"stable" has been added to your repositories
alinos@DESKTOP-A52MBHK:~/helm$ helm search repo stable/minio
NAME CHART VERSION APP VERSION DESCRIPTION
stable/minio 5.0.32 master MinIO is a high performance data infrastructure...
alinos@DESKTOP-A52MBHK:~/helm$ # helm hub repo
alinos@DESKTOP-A52MBHK:~/helm$ helm search hub echo
URL CHART VERSION APP VERSION DESCRIPTION
https://hub.helm.sh/charts/ealenn/echo-server 0.3.0 0.4.0 Echo-Server for Kubernetes
https://hub.helm.sh/charts/banzaicloud-stable/e... 0.0.1 0.0.1 echo server chart
alinos@DESKTOP-A52MBHK:~/helm$ helm repo add ealenn "https://ealenn.github.io/charts"
"ealenn" has been added to your repositories
alinos@DESKTOP-A52MBHK:~/helm$ helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "ealenn" chart repository
Update Complete. ⎈ Happy Helming!⎈
alinos@DESKTOP-A52MBHK:~/helm$ helm repo list
NAME URL
ealenn https://ealenn.github.io/charts
alinos@DESKTOP-A52MBHK:~/istio/istio-1.6.5$ helm install --set service.type=NodePort alinos-echo --create-namespace --namespace echo ealenn/echo-server
NAME: alinos-echo
LAST DEPLOYED: Thu Jul 30 00:02:26 2020
NAMESPACE: echo
STATUS: deployed
REVISION: 1
alinos@DESKTOP-A52MBHK:~/istio/istio-1.6.5$ helm ls -n echo
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
alinos-echo echo 1 2020-07-30 00:02:26.7035449 +0900 KST deployed echo-server-0.3.0 0.4.0
### 서비스 IP/Port 확인하고 호출해보기
- NodePort로 띄웠기 때문에 $(NodeIP:NodePort) 호출하면 확인할 수 있다.
alinos@DESKTOP-A52MBHK:~/helm$ kubectl get svc -n echo
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
alinos-echo-echo-server NodePort 10.245.130.70 <none> 80:32234/TCP 20m
alinos@DESKTOP-A52MBHK:~/helm$ kubectl get nodes -o jsonpath='{ $.items[*].status.addresses[?(@.type=="ExternalIP")].address }'
8.8.8.8 8.8.4.4alinos@DESKTOP-A52MBHK:~/helm$
alinos@DESKTOP-A52MBHK:~/helm$ NODE_FIRST_IP=$(kubectl get nodes -o jsonpath='{ $.items[1].status.addresses[?(@.type=="ExternalIP")].address }')
alinos@DESKTOP-A52MBHK:~/helm$ curl -s http://$NODE_FIRST_IP:32234 | jq '.http, .host, .request'
{
"method": "GET",
"baseUrl": "",
"originalUrl": "/",
"protocol": "http"
}
{
"hostname": "8.8.8.8",
"ip": "::ffff:8.8.8.8",
"ips": []
}
{
"params": {
"0": "/"
},
"query": {},
"cookies": {},
"body": {},
"headers": {
"host": "8.8.8.8:32234",
"user-agent": "curl/7.58.0",
"accept": "*/*"
}
}
참조
https://helm.sh/docs/intro/install/
Installing Helm
Learn how to install and get running with Helm.
helm.sh
https://hub.helm.sh/
hub.helm.sh