티스토리 뷰

DevOps/System&Tools

Helm usage

Jacob_baek 2020. 1. 23. 13:40

초기사용설정

repo 추가

helm 사용을 위해 아래 repo를 추가한다.

helm repo add stable https://kubernetes-charts.storage.googleapis.com/chart

일반적으로 stable(google에서 제공하는 repo)를 많이 사용한다

incubator의 경우 다른 repo를 추가해야한다.

$ helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/

관련 내용은 다음 링크에 상세히 나와 있다.

repo 추가가 완료되면 다음과 같이 설치를 진행할 수 있다.

helm chart 설치 진행 (앞서 설정한 repo로 부터)

jacob@jacob-laptop:~/workspace/helmcharts/sonarqube$ helm install stable/sonarqube

custom helm chart 설치

만약 helm chart의 설정을 변경하고자 한다면 다음과 같은 방식을 사용해보면 좋다.

jacob@jacob-laptop:~/workspace/helmcharts$ helm fetch stable/sonarqube
jacob@jacob-laptop:~/workspace/helmcharts$ tar xvf sonarqube.tgz

받아온 helm chart 압축파일을 해제하고 그안에 values.yaml 파일을 입맛에 맞게 수정한다.

jacob@jacob-laptop:~/workspace/helmcharts$ cd sonarqube
jacob@jacob-laptop:~/workspace/helmcharts/sonarqube$ ## values.yaml 수정

위와 같은 방법외에도 아래와 같이 values.yaml파일을 생성하여 수정할수도 있다.

jacob@jacob-laptop:~/workspace/helmcharts$ helm show values stable/sonarqube > values.yaml

이후 다음과 같이 해당 디렉토리에서 명령을 실행해 변경된 values.yaml이 반영된 설치가 진행되도록 한다.

jacob@jacob-laptop:~/workspace/helmcharts/sonarqube$ helm install sonarqube . 

만약 helm list 에 있는 chart의 설정을 변경하여 업그레이드를 수행해야 하는 경우는 다음과 같이 명령을 수행할 수 있다.

혹은 다음과 같이 values.yaml파일을 지정하여 설치를 수행할 수도 있다.

jacob@jacob-laptop:~/workspace/helmcharts/sonarqube$ helm install --name sonarqube -f values.yaml ./ --namespace sonarqube

helm chart 삭제 방법

만약 기존에 설치된 helm을 삭제하고자 한다면 아래와 같이 삭제를 진행해야 동일한 이름으로 재배포가 가능하다.

jacob@jacob-laptop:~/workspace/helmcharts/sonarqube$ helm install --name sonarqube -f values.yaml ./ --namespace sonarqube
Error: a release named sonarqube already exists.
Run: helm ls --all sonarqube; to check the status of the release
Or run: helm del --purge sonarqube; to delete it
jacob@jacob-laptop:~/workspace/helmcharts/sonarqube$ helm ls --all
NAME                   REVISION    UPDATED                     STATUS      CHART                    APP VERSION    NAMESPACE    
jenkins                5           Tue Feb  4 22:04:35 2020    DEPLOYED    jenkins-1.9.4            lts            jenkins      
nginx-ingress          1           Wed Jan 15 21:19:34 2020    DEPLOYED    nginx-ingress-1.29.1     0.27.0         nginx-ingress
sonarqube              1           Wed Feb  5 16:47:00 2020    DELETED     sonarqube-3.4.0          7.9.2          default      
jacob@jacob-laptop:~/workspace/helmcharts/sonarqube$ helm delete sonarqube --purge
release "sonarqube" deleted
jacob@jacob-laptop:~/workspace/helmcharts/sonarqube$ helm ls --all
NAME                   REVISION    UPDATED                     STATUS      CHART                    APP VERSION    NAMESPACE    
jenkins                5           Tue Feb  4 22:04:35 2020    DEPLOYED    jenkins-1.9.4            lts            jenkins      
nginx-ingress          1           Wed Jan 15 21:19:34 2020    DEPLOYED    nginx-ingress-1.29.1     0.27.0         nginx-ingress

직접 수정한 helm chart를 통한 업그레이드 방법

간혹 helm 으로 배포한 application을 업그레이드 해야 하는 경우가 있다.

(필자의 경우 plugin을 추가해서 업그레이드 수행이 필요했다.)

이와 같은 경우 values.yaml파일을 수정한 후 아래와 같이 수행해서 업그레이드를 수행했다.

jacob@jacob-laptop:~/workspace/helmcharts/sonarqube$ helm upgrade --namespace sqns sonarqube -f ./values.yaml ./

간단히 추가설명을 하자면 sqns라는 namespace에 sonarqube라는 deployment를 재배포하는것을 의미한다.

Rollback

아래와 같이 release name과 version을 입력하여 upgrade 및 rollback을 수행할 수도 있다.

jacob@jacob-laptop:~/workspace/helmcharts$ helm history spinnaker
REVISION    UPDATED                     STATUS             CHART               APP VERSION    DESCRIPTION                                                                               
1           Tue Mar 31 08:11:44 2020    superseded         spinnaker-1.23.3    1.16.2         Install complete                                                                          
2           Wed Apr  1 06:51:25 2020    failed             spinnaker-1.23.3    1.16.2         Upgrade "spinnaker" failed: post-upgrade hooks failed: timed out waiting for the condition
3           Thu Apr  2 01:12:38 2020    pending-upgrade    spinnaker-1.23.3    1.16.2         Preparing upgrade                                                                         
4           Thu Apr  2 01:13:51 2020    pending-upgrade    spinnaker-1.23.3    1.16.2         Preparing upgrade                                                                         
5           Thu Apr  2 01:14:24 2020    superseded         spinnaker-1.23.3    1.16.2         Rollback to 3                                                                             
jacob@jacob-laptop:~/workspace/helmcharts$ helm search repo stable/spinnaker
NAME                CHART VERSION    APP VERSION    DESCRIPTION                                       
stable/spinnaker    1.23.3           1.16.2         Open source, multi-cloud continuous delivery pl...

jacob@jacob-laptop:~/workspace/helmcharts$ helm rollback spinnaker 1
Rollback was a success! Happy Helming!
jacob@jacob-laptop:~/workspace/helmcharts$ helm history spinnaker
REVISION    UPDATED                     STATUS             CHART               APP VERSION    DESCRIPTION                                                                               
1           Tue Mar 31 08:11:44 2020    superseded         spinnaker-1.23.3    1.16.2         Install complete                                                                          
2           Wed Apr  1 06:51:25 2020    failed             spinnaker-1.23.3    1.16.2         Upgrade "spinnaker" failed: post-upgrade hooks failed: timed out waiting for the condition
3           Thu Apr  2 01:12:38 2020    pending-upgrade    spinnaker-1.23.3    1.16.2         Preparing upgrade                                                                         
4           Thu Apr  2 01:13:51 2020    pending-upgrade    spinnaker-1.23.3    1.16.2         Preparing upgrade                                                                         
5           Thu Apr  2 01:14:24 2020    superseded         spinnaker-1.23.3    1.16.2         Rollback to 3                                                                             
6           Thu Apr  2 01:16:42 2020    superseded         spinnaker-1.23.3    1.16.2         Rollback to 1                                                                             

참고로 Rollback과 관련된 위 명령은 helm 3 기반으로 --name option없이 수행되었다.

'DevOps > System&Tools' 카테고리의 다른 글

Jenkins Debugging  (0) 2020.08.13
How to use minio as Terraform backend  (0) 2020.05.28
Use ssh with jenkinsfile as scripted pipeline  (0) 2019.12.11
How to use GitLab API  (0) 2019.11.27
Jenkinsfile example using ssh and scp  (0) 2019.11.25
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함