Kubernetes
[Helm] 설치 및 기본 사용법
밝은숲
2021. 5. 11. 14:10
Helm
- Kubernetes Package Managing Tool
- Kubernetes 패키지 배포를 위한 Tool
- Chart라고 부르는 패키지 포멧을 사용
- Chart는 쿠버네티스 리소스를 desribe하는 파일들의 집합
- 특정 디렉토리 하위에 모여있는 파일들을 Chart라고 함.
구조
Client - 엔드유저를 위한 Command line Client
Server(Tiller) - in-cluster 서버로 chart의 배포, 릴리즈를 관리
#helm 최신 버전을 자동으로 가져와서 로컬에 설치하는 스크립트 root@ubuntu-k8s-master01:/opt# curl https://raw.githubusercontent.com/helm/helm/master/scripts/get > get_helm.sh root@ubuntu-k8s-master01:/opt# chmod +x *.sh root@ubuntu-k8s-master01:/opt# ./get_helm.sh |
#tiller 서비스 account 생성 root@ubuntu-k8s-master01:/opt# kubectl -n kube-system create sa tiller serviceaccount/tiller created #tiller에 cluster-admin 롤 부여 kubectl create clusterrolebinding tiller --clusterrole cluster-admin --serviceaccount=kube-system:tiller clusterrolebinding.rbac.authorization.k8s.io/tiller created |
#버전 확인 root@ubuntu-k8s-master01:/opt# helm version version.BuildInfo{Version:"v3.5.4", GitCommit:"1b5edb69df3d3a08df77c9902dc17af864ff05d1", GitTreeState:"clean", GoVersion:"go1.15.11"} #차트 찾기 - 여러 저장소들에 있는 헬름 차트들을 포관하는 헬름 허브 검색 root@ubuntu-k8s-master01:/opt# helm search hub root@ubuntu-k8s-master01:/opt# helm search hub -o json kubernetes-dashboard | jq #차트 찾기 - [helm repo add]를 사용하여 로컬 헬름 클라이언트에 추가된 저장소들을 검색. 퍼블릭 네트워크 접속 필요없음. root@ubuntu-k8s-master01:/opt# helm repo add stable https://charts.helm.sh/stable root@ubuntu-k8s-master01:/opt# helm repo add bitnami https://charts.bitnami.com/bitnami root@ubuntu-k8s-master01:/opt# helm search repo root@ubuntu-k8s-master01:/opt# helm search repo stable root@ubuntu-k8s-master01:/opt# helm search repo bitnami #패키지 설치 root@ubuntu-k8s-master01:/opt# helm install sllee stable/tomcat root@ubuntu-k8s-master01:/opt# helm install my-nginx bitnami/nginx #상태 확인 root@ubuntu-k8s-master01:/opt# helm status sllee *기타 설치 방법 helm install foo foo.0.1.1.tgz helm install foo path/to/foo helm install foo https://example.com/charts/foo-1.2.3.tgz |
#차트 커스터마이징 #차트에 어떤 구성이 가능한지 확인 root@ubuntu-k8s-master01:/opt# helm show values stable/tomcat #차트 옵션 변경 [--values] 옵션 : Override 할 YAML 파일을 지정 [--set] 옵션 : 명령줄 상에서 Override 지정 ex) --set a=b --set servers[0].port=80 (공식 문서 참고. https://helm.sh/ko/docs/intro/using_helm/) |
#release 업그레이드 helm upgrade -f panda.yaml sllee stable/tomcat #Release 롤백 helm rollback [RELEASE] [REVISION] helm rollback sllee 1 #Revision 확인 (설치, 롤백, 업그레이드마다 리비전 번호 1씩 증가) root@ubuntu-k8s-master01:/opt# helm history sllee REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION 1 Fri May 7 01:58:30 2021 superseded tomcat-0.4.3 7.0 Install complete 2 Fri May 7 02:25:10 2021 deployed tomcat-0.4.3 7.0 Upgrade complete #Release 제거 root@ubuntu-k8s-master01:/opt# helm uninstall sllee release "sllee" uninstalled #설치된 차트 확인 root@ubuntu-k8s-master01:/opt# helm list NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION sllee default 1 2021-05-07 04:06:28.803759344 +0000 UTC deployed tomcat-0.4.3 7.0 #실패, 삭제된 릴리즈 포함 확인 root@ubuntu-k8s-master01:/opt# helm list --all |