아코디언에서 helm 사용하기
Helm은 Kubernetes 애플리캐이션을 관리하기 위한 도구입니다. Helm chart를 통해 복잡한 Kubernetes 애플리케이션들을 쉽게 배포/관리 할 수 있습니다.
(참고사이트)
– Helm 상세 소개 : https://helm.sh/
– Helm 의 설치 및 기본 설정 방법 : https://docs.helm.sh/using_helm/#quickstart-guide
이번 소개할 내용은 아코디언에서 사용자별로 Helm을 이용하여 애플리케이션 배포하는 방법에 대해 설명드리도록 하겠습니다.
사전설치
사용자 로그인 후 사용자 config key 파일을 다운로드 받습니다. kubectl 파일은 시스템 PATH 설정된 곳에 위치하고, config파일은 Windows OS의 경우 C:\Users\사용자계정\.kube\ Linux OS인 경우 $HOME/.kube/ 아래 위치하면 별도 설정없이 인식 가능합니다.

helm 다운받기 : https://github.com/helm/helm/releases
다운받은 파일의 압축을 해제한 후 PATH에 설정을 추가합니다.
설정

* helm version 명령어 수행 시 발생되는 에러는 helm 기본 프로젝트가 kube-system으로 설정되기 때문에 발생되는 오류로 helm 설정 방법에 대해 알아 보도록 하겠습니다.
1) User 생성
$ kubectl create serviceaccount tiller
2) Role 설정
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: tiller-manager
rules:
- apiGroups: ["", "batch", "extensions", "apps"]
resources: ["*"]
verbs: ["*"]
$ kubectl create -f role-tiller.yaml
role "tiller-manager" created
3) role binding
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: tiller-binding
subjects:
- kind: ServiceAccount
name: tiller
roleRef:
kind: Role
name: tiller-manager
apiGroup: rbac.authorization.k8s.io
$ kubectl create -f rolebinding-tiller.yaml
rolebinding "tiller-binding" created
4) tiller 설치 (tiller는 Kubernetes 클러스터에서 실행되는 서버로 Kubernetes 응용 프로그램을 배포 / 관리하는데 사용됩니다.)
$ helm init --service-account tiller
$HELM_HOME has been configured at C:\Users\thlee\.helm.
Tiller (the Helm server-side component) has been installed into your Kubernetes Cluster.
Please note: by default, Tiller is deployed with an insecure 'allow unauthenticated users' policy.
To prevent this, run `helm init` with the --tiller-tls-verify flag.
For more information on securing your installation see: https://docs.helm.sh/using_helm/#securing-your-helm-installation
Happy Helming!
사용하기
이제 tomcat 애플리케이션을 helm chart를 이용하여 배포 해보겠습니다. 먼제 helm의 기본 namespace가 kube-system이기 때문에 기본 namespace를 아래와 같이 변경하실 수 있습니다.
$ set TILLER_NAMESPACE=test (Linux의 경우 export TILLER_NAMESPACE=test)
그럼, 먼저 tomcat chart를 검색해보겠습니다.
$ helm search tomcat
NAME CHART VERSION APP VERSION DESCRIPTION
stable/tomcat 0.1.0 7 Deploy a basic tomcat application server with sidecar as ...
$ helm install stable/tomcat
NAME: wobbling-possum
LAST DEPLOYED: Sat Dec 29 00:14:36 2018
NAMESPACE: test
STATUS: DEPLOYED
RESOURCES:
==> v1beta2/Deployment
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
wobbling-possum-tomcat 1 1 1 0 1s
==> v1/Pod(related)
NAME READY STATUS RESTARTS AGE
wobbling-possum-tomcat-764957f4d5-dbz4m 0/2 ContainerCreating 0 1s
==> v1/Service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
wobbling-possum-tomcat LoadBalancer 10.111.121.204 <pending> 80:30398/TCP 1s
NOTES:
1. Get the application URL by running these commands:
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get svc -w wobbling-possum-tomcat'
export SERVICE_IP=$(kubectl get svc --namespace test wobbling-possum-tomcat -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')
echo http://$SERVICE_IP:80
정상적으로 생성되었는지 확인해보도록 하겠습니다.
$ kubectl get svc,po
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/monitor-agent ClusterIP 10.96.201.25 <none> 6100/TCP,6188/TCP,6100/UDP 4d
service/tiller-deploy ClusterIP 10.97.197.10 <none> 44134/TCP 14h
service/wobbling-possum-tomcat LoadBalancer 10.111.121.204 <pending> 80:30398/TCP 14h
NAME READY STATUS RESTARTS AGE
pod/tiller-deploy-79c9cd46f-nbvk8 1/1 Running 0 14h
pod/wobbling-possum-tomcat-764957f4d5-dbz4m 2/2 Running 0 14h
정상적으로 생성되었다면 tomcat 서비스를 호출해보도록 하겠습니다. nodeport가 30398로 설정되어있기 때문에 브라우저에서 http://NodeIP:30398로 접속해 보도록 하겠습니다.

지금까지 아코디언에서 helm chart를 이용하여 다양한 애플리케이션을 배포할 수 있는 방법에 대해 알아보았습니다.
