[헬름 차트를 활용한 쿠버네티스 애플리케이션 패키지 배포] 공개 레파지토리를 활용한 애플리케이션 배포

IMKUNYOUNG·2023년 8월 19일
0

쿠버네티스

목록 보기
56/64

helm 차트 리포지토리 초기화

  • helm은 외부에서 정의된 yaml 파일을 내려 받아 쿠버네티스에 애플리케이션을 배포
  • apt, yum과 같이 저장소를 별도로 두고 있음
  • 이 외부 저장소를 helm repo add 명령으로 추가
  • 다음 명령을 실행해 bitnami 저장소를 helm 목록에 추가한 뒤 업데이트 진행

Bitnami: Bitnami는 가상 어플라이언스 및 웹 애플리케이션, 개발 스택용 소프트웨어 패키지 및 설치 라이브러리이다


# 저장소 추가
imkunyoung@cloudshell:~ (kubernetes-397511)$ helm repo add bitnami https://charts.bitnami.com/bitnami
"bitnami" has been added to your repositories
imkunyoung@cloudshell:~ (kubernetes-397511)$ helm repo list
NAME    URL
bitnami https://charts.bitnami.com/bitnami
# 목록 업데이트
imkunyoung@cloudshell:~ (kubernetes-397511)$ helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "bitnami" chart repository
Update Complete. ⎈Happy Helming!


추가된 리포지토리에 헬름 차트 리스트 확인

  • 추가된 저장소가 어떤 애플리케이션을 설치할 수 있도록 지원하는지 확인
imkunyoung@cloudshell:~ (kubernetes-397511)$ helm search repo bitnami
NAME                                            CHART VERSION   APP VERSION     DESCRIPTION

bitnami/airflow                                 15.0.5          2.7.1           Apache Airflow is a tool to express and execute...
bitnami/apache                                  10.1.2          2.4.57          Apache HTTP Server is an open-source HTTP serve...
bitnami/apisix                                  2.1.2           3.5.0           Apache APISIX is high-performance, real-time AP...
bitnami/appsmith                                1.0.4           1.9.37          Appsmith is an open source platform for buildin...
bitnami/argo-cd                                 5.1.3           2.8.3           Argo CD is a continuous delivery tool for Kuber...
bitnami/argo-workflows                          5.4.3           3.4.11          Argo Workflows is meant to orchestrate Kubernet...
bitnami/aspnet-core                             4.4.2           7.0.11          ASP.NET Core is an open-source framework for we...
bitnami/cassandra                               10.5.3          4.1.3           Apache Cassandra is an open source distributed ...
bitnami/cert-manager                            0.12.4          1.13.0          cert-manager is a Kubernetes add-on to automate...
bitnami/clickhouse                              4.0.1           23.8.2          ClickHouse is an open-source column-oriented OL...
bitnami/common                                  2.11.1          2.11.1          A Library Helm Chart for grouping common logic ...
bitnami/concourse                               2.3.6           7.10.0          Concourse is an automation system written in Go...
bitnami/consul                                  10.13.3         1.16.1          HashiCorp Consul is a tool for discovering and ...
bitnami/contour                                 13.0.0          1.26.0          Contour is an open source Kubernetes ingress co...
bitnami/contour-operator                        4.2.1           1.24.0          DEPRECATED The Contour Operator extends the Kub...
bitnami/dataplatform-bp2                        12.0.5          1.0.1           DEPRECATED This Helm chart can be used for the ...
bitnami/deepspeed                               1.2.3           0.10.3          DeepSpeed is deep learning software suite for e...
bitnami/discourse                               11.0.3          3.1.1           Discourse is an open source discussion platform...
bitnami/dokuwiki                                14.2.2          20230404.1.0    DokuWiki is a standards-compliant wiki optimize...
bitnami/drupal                                  15.1.3          10.1.3          Drupal is one of the most versatile open source...
bitnami/ejbca                                   9.0.1           8.0.20230531    EJBCA is an enterprise class PKI Certificate Au...
bitnami/elasticsearch                           19.11.3         8.10.0          Elasticsearch is a distributed search and analy...
bitnami/etcd                                    9.5.0           3.5.9           etcd is a distributed key-value store designed ...
bitnami/external-dns                            6.26.1          0.13.6          ExternalDNS is a Kubernetes addon that configur...
bitnami/flink                                   0.4.2           1.17.1          Apache Flink is a framework and distributed pro...
bitnami/fluent-bit                              0.5.2           2.1.9           Fluent Bit is a Fast and Lightweight Log Proces...


helm 차트로 mysql 배포하기

  • 목록들 중에 mysql을 설치하고 사용
  • 애플리케이션을 배포할 네임스페이스 생성
  • 해당 네임스페이스에 bitnami/mysql을 설치
# 네임스페이스 생성
imkunyoung@cloudshell:~ (kubernetes-397511)$ kubectl create ns mysql
namespace/mysql created
# 헬름 차트로 mysql 배포
imkunyoung@cloudshell:~ (kubernetes-397511)$ helm install mysqlname bitnami/mysql -n mysql
NAME: mysqlname
LAST DEPLOYED: Tue Sep 19 02:24:17 2023
NAMESPACE: mysql
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: mysql
CHART VERSION: 9.12.2
APP VERSION: 8.0.34

** Please be patient while the chart is being deployed **

Tip:

  Watch the deployment status using the command: kubectl get pods -w --namespace mysql

Services:

  echo Primary: mysqlname.mysql.svc.cluster.local:3306

Execute the following to get the administrator credentials:

  echo Username: root
  MYSQL_ROOT_PASSWORD=$(kubectl get secret --namespace mysql mysqlname -o jsonpath="{.data.mysql-root-password}" | base64 -d)

To connect to your database:

  1. Run a pod that you can use as a client:

      kubectl run mysqlname-client --rm --tty -i --restart='Never' --image  docker.io/bitnami/mysql:8.0.34-debian-11-r31 --namespace mysql --env MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD --command -- bash

  2. To connect to primary service (read/write):

      mysql -h mysqlname.mysql.svc.cluster.local -uroot -p"$MYSQL_ROOT_PASSWORD"
# 헬름 통해 구성된 워크로드,
imkunyoung@cloudshell:~ (kubernetes-397511)$ kubectl get all -n mysql
NAME              READY   STATUS    RESTARTS   AGE
pod/mysqlname-0   1/1     Running   0          8m6s

NAME                         TYPE        CLUSTER-IP    EXTERNAL-IP   PORT(S)    AGE
service/mysqlname            ClusterIP   10.44.10.42   <none>        3306/TCP   8m6s
service/mysqlname-headless   ClusterIP   None          <none>        3306/TCP   8m6s

NAME                         READY   AGE
statefulset.apps/mysqlname   1/1     8m7s


배포된 mysql 확인하기

  • mysql 컨테이너를 배포할 때는 패스워드가 필요한데 패스워드까지 모두 자동으로 구성

mysql 컨테이너가 올라왔는지 확인

imkunyoung@cloudshell:~ (kubernetes-397511)$ kubectl get pods -n mysql
NAME          READY   STATUS    RESTARTS   AGE
mysqlname-0   1/1     Running   0          2m15s

mysql의 root 패스워드는 아래와 같이 확인

imkunyoung@cloudshell:~ (kubernetes-397511)$ kubectl get secret -n mysql
NAME                              TYPE                 DATA   AGE
mysqlname                         Opaque               2      4m58s
sh.helm.release.v1.mysqlname.v1   helm.sh/release.v1   1      4m59s
imkunyoung@cloudshell:~ (kubernetes-397511)$ kubectl get secret mysqlname -n mysql -o yaml
apiVersion: v1
data:
  mysql-password: alVoUE9EMW5YeQ==
  mysql-root-password: akpPQ0NZa0tkMA==
kind: Secret
metadata:
  annotations:
    meta.helm.sh/release-name: mysqlname
    meta.helm.sh/release-namespace: mysql
  creationTimestamp: "2023-09-19T02:24:24Z"
  labels:
    app.kubernetes.io/instance: mysqlname
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: mysql
    helm.sh/chart: mysql-9.12.2
  name: mysqlname
  namespace: mysql
  resourceVersion: "8190276"
  uid: d89dcb56-5754-49eb-ad39-39856093aa3d
type: Opaque


배포된 헬름 차트 리스트 확인하기

리스트 확인하기

imkunyoung@cloudshell:~ (kubernetes-397511)$ helm list -A
NAME            NAMESPACE       REVISION        UPDATED                                 STATUS          CHART           APP VERSION
mysqlname       mysql           1               2023-09-19 02:24:17.037549476 +0000 UTC deployed        mysql-9.12.2    8.0.34

상태 확인하기

imkunyoung@cloudshell:~ (kubernetes-397511)$ helm status mysqlname -n mysql
NAME: mysqlname
LAST DEPLOYED: Tue Sep 19 02:24:17 2023
NAMESPACE: mysql
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: mysql
CHART VERSION: 9.12.2
APP VERSION: 8.0.34

** Please be patient while the chart is being deployed **

Tip:

  Watch the deployment status using the command: kubectl get pods -w --namespace mysql

Services:

  echo Primary: mysqlname.mysql.svc.cluster.local:3306

Execute the following to get the administrator credentials:

  echo Username: root
  MYSQL_ROOT_PASSWORD=$(kubectl get secret --namespace mysql mysqlname -o jsonpath="{.data.mysql-root-password}" | base64 -d)

To connect to your database:

  1. Run a pod that you can use as a client:

      kubectl run mysqlname-client --rm --tty -i --restart='Never' --image  docker.io/bitnami/mysql:8.0.34-debian-11-r31 --namespace mysql --env MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD --command -- bash

  2. To connect to primary service (read/write):

      mysql -h mysqlname.mysql.svc.cluster.local -uroot -p"$MYSQL_ROOT_PASSWORD"


배포된 패키지 삭제하기

배포된 패키지는 uninstall 명령으로 삭제

imkunyoung@cloudshell:~ (kubernetes-397511)$ helm list -A
heNAME          NAMESPACE       REVISION        UPDATED                                 STATUS          CHART           APP VERSION
mysqlname       mysql           1               2023-09-19 02:24:17.037549476 +0000 UTC deployed        mysql-9.12.2    8.0.34

imkunyoung@cloudshell:~ (kubernetes-397511)$ helm uninstall mysqlname -n mysql
release "mysqlname" uninstalled

imkunyoung@cloudshell:~ (kubernetes-397511)$ helm list -n mysql
NAME    NAMESPACE       REVISION        UPDATED STATUS  CHART   APP VERSION


헬름 리포지토리 삭제

imkunyoung@cloudshell:~ (kubernetes-397511)$ helm repo list
NAME    URL
bitnami https://charts.bitnami.com/bitnami

imkunyoung@cloudshell:~ (kubernetes-397511)$ helm repo remove bitnami
"bitnami" has been removed from your repositories

imkunyoung@cloudshell:~ (kubernetes-397511)$ helm repo list
Error: no repositories to show

0개의 댓글