리눅스

Minikube 클러스터에 Helm을 설치하는 방법

변군Dev 2024. 2. 2. 16:33
728x90

Minikube 클러스터에 Helm을 설치하는 방법

Helm은 쿠버네티스 애플리케이션을 손쉽게 관리하기 위한 패키지 관리 도구입니다. Helm은 "차트"라고 불리는 패키지 형식을 사용하여 애플리케이션을 정의하고 배포합니다. 각 차트에는 애플리케이션을 배포하는 데 필요한 모든 Kubernetes 리소스가 포함되어 있습니다.

 

Helm은 다음과 같은 주요 기능을 제공합니다.

 

  1. 패키지 관리 : Helm을 사용하여 쉽게 애플리케이션을 패키지화하고 공유할 수 있습니다. 다른 사용자가 Helm 차트를 사용하여 동일한 애플리케이션을 배포할 수 있습니다.
  2. 템플릿화된 리소스 : Helm 차트는 Kubernetes 리소스를 생성하기 위한 템플릿화된 구성 파일을 포함합니다. 이를 통해 각각의 배포를 위해 필요한 구성을 쉽게 변경하고 관리할 수 있습니다.
  3. 릴리스 관리 : Helm은 "릴리스"라는 개념을 사용하여 각 애플리케이션 배포를 추적합니다. 릴리스를 통해 애플리케이션의 이전 버전을 관리하고 롤백하는 등의 작업을 수행할 수 있습니다.
  4. 사용자 정의 가능 : Helm은 사용자 정의 가능한 많은 옵션을 제공합니다. 사용자는 Helm 차트를 통해 설정을 조정하고 필요에 따라 차트를 수정할 수 있습니다.

Helm은 쿠버네티스 애플리케이션을 더 쉽게 관리하고 배포할 수 있도록 도와주는 강력한 도구입니다.

1. Minikube 시작

Minikube 클러스터를 시작합니다.

minikube start

2. Helm 설치

Helm(Helm 3)을 설치합니다. 공식 Helm 설치 문서에서 제공하는 명령을 사용하여 설치합니다.

curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
chmod +x get_helm.sh
./get_helm.sh
$ ./get_helm.sh
Downloading https://get.helm.sh/helm-v3.14.0-linux-amd64.tar.gz
Verifying checksum... Done.
Preparing to install helm into /usr/local/bin
helm installed into /usr/local/bin/helm

helm 버전 정보

helm version
$ helm version
version.BuildInfo{Version:"v3.14.0", GitCommit:"3fc9f4b2638e76f26739cd77c7017139be81d0ea", GitTreeState:"clean", GoVersion:"go1.21.5"}

3. Helm 레포지토리 추가

helm repo add stable https://charts.helm.sh/stable
$ helm repo add stable https://charts.helm.sh/stable
"stable" has been added to your repositories

Helm 차트 설치

helm install my-mysql stable/mysql
$ helm install my-mysql stable/mysql
WARNING: This chart is deprecated
NAME: my-mysql
LAST DEPLOYED: Fri Feb  2 16:34:45 2024
NAMESPACE: default
STATUS: deployed
REVISION: 1
NOTES:
MySQL can be accessed via port 3306 on the following DNS name from within your cluster:
my-mysql.default.svc.cluster.local

To get your root password run:

    MYSQL_ROOT_PASSWORD=$(kubectl get secret --namespace default my-mysql -o jsonpath="{.data.mysql-root-password}" | base64 --decode; echo)

To connect to your database:

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

    kubectl run -i --tty ubuntu --image=ubuntu:16.04 --restart=Never -- bash -il

2. Install the mysql client:

    $ apt-get update && apt-get install mysql-client -y

3. Connect using the mysql cli, then provide your password:
    $ mysql -h my-mysql -p

To connect to your database directly from outside the K8s cluster:
    MYSQL_HOST=127.0.0.1
    MYSQL_PORT=3306

    # Execute the following command to route the connection:
    kubectl port-forward svc/my-mysql 3306

    mysql -h ${MYSQL_HOST} -P${MYSQL_PORT} -u root -p${MYSQL_ROOT_PASSWORD}

 

MYSQL_ROOT_PASSWORD=$(kubectl get secret --namespace default my-mysql -o jsonpath="{.data.mysql-root-password}" | base64 --decode; echo)
$ MYSQL_ROOT_PASSWORD=$(kubectl get secret --namespace default my-mysql -o jsonpath="{.data.mysql-root-password}" | base64 --decode; echo)
echo $MYSQL_ROOT_PASSWORD
$ echo $MYSQL_ROOT_PASSWORD
Xl9lx5nqu2

 

kubectl run -i --tty ubuntu --image=ubuntu:16.04 --restart=Never -- bash -il
$ kubectl run -i --tty ubuntu --image=ubuntu:16.04 --restart=Never -- bash -il
If you don't see a command prompt, try pressing enter.
root@ubuntu:/#

 

apt-get update && apt-get install mysql-client -y
# apt-get update && apt-get install mysql-client -y

 

mysql -h my-mysql -p
# mysql -h my-mysql -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 51
Server version: 5.7.30 MySQL Community Server (GPL)

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

 

SELECT now();
mysql> SELECT now();
+---------------------+
| now()               |
+---------------------+
| 2024-02-02 07:42:04 |
+---------------------+
1 row in set (0.00 sec)

4. Tiller 제거

Helm 3부터는 Tiller가 필요하지 않으므로 제거할 수 있습니다.

kube-system 네임스페이스에서 Tiller를 삭제합니다.

kubectl delete deployment tiller-deploy -n kube-system

 

이제 Minikube 클러스터에 Helm이 설치되었으며 사용할 준비가 되었습니다. Helm 차트를 추가하고 배포하여 Kubernetes 애플리케이션을 관리할 수 있습니다.

 

728x90