기본 정보:
투구 v3.12.3
쿠버네티스 v1.28.0
Containerd.io 1.6.22
다음은 helm을 사용하여 Zookeeper를 설치, 업그레이드, 롤백, 제거하는 연습 과정을 참고용으로 정리한 것입니다.
1. helm에 BitNami 창고 추가
helm repo에 bitnami 추가 https://charts.bitnami.com/bitnami
zhangzk@k8smaster:~$ helm repo add bitnami https://charts.bitnami.com/bitnami
"bitnami" has been added to your repositories
2. 사육사 차트 보기
헬름 검색 레포 사육사
zhangzk@k8smaster:~$ helm search repo zookeeper
NAME CHART VERSION APP VERSION DESCRIPTION
bitnami/zookeeper 12.1.0 3.9.0 Apache ZooKeeper provides a reliable, centraliz...
bitnami/dataplatform-bp2 12.0.5 1.0.1 DEPRECATED This Helm chart can be used for the ...
bitnami/kafka 25.1.0 3.5.1 Apache Kafka is a distributed streaming platfor...
bitnami/schema-registry 13.1.0 7.4.1 Confluent Schema Registry provides a RESTful in...
bitnami/solr 8.0.0 9.3.0 Apache Solr is an extremely powerful, open sour...
3. 차트를 로컬로 가져옵니다.
헬름 풀 비트나미/사육사
zhangzk@k8smaster:~/helm$ helm pull bitnami/zookeeper
zhangzk@k8smaster:~/helm$ ll
total 52
drwxrwxr-x 2 zhangzk zhangzk 4096 Aug 25 10:17 ./
drwxr-x--- 8 zhangzk zhangzk 4096 Aug 25 10:17 ../
-rw-r--r-- 1 zhangzk zhangzk 42792 Aug 25 10:17 zookeeper-12.1.0.tgz
4. value.yaml 수정
Zookeeper-12.1.0.tgz의 압축을 풉니다.
zhangzk@k8smaster:~/helm$ tar -zxvf zookeeper-12.1.0.tgz
zhangzk@k8smaster:~/helm$ cd zookeeper
zhangzk@k8smaster:~/helm/zookeeper$ ll
total 124
drwxrwxr-x 4 zhangzk zhangzk 4096 Aug 25 10:18 ./
drwxrwxr-x 3 zhangzk zhangzk 4096 Aug 25 10:18 ../
-rw-r--r-- 1 zhangzk zhangzk 333 Aug 22 22:43 .helmignore
-rw-r--r-- 1 zhangzk zhangzk 226 Aug 22 22:43 Chart.lock
-rw-r--r-- 1 zhangzk zhangzk 845 Aug 22 22:43 Chart.yaml
-rw-r--r-- 1 zhangzk zhangzk 60180 Aug 22 22:43 README.md
drwxrwxr-x 3 zhangzk zhangzk 4096 Aug 25 10:18 charts/
drwxrwxr-x 2 zhangzk zhangzk 4096 Aug 25 10:18 templates/
-rw-r--r-- 1 zhangzk zhangzk 36205 Aug 22 22:43 values.yaml
value.yaml 파일 수정
수정점 1: 영구 데이터 닫기
## Enable persistence using Persistent Volume Claims
## ref: https://kubernetes.io/docs/user-guide/persistent-volumes/
##
persistence:
## @param persistence.enabled Enable ZooKeeper data persistence using PVC. If false, use emptyDir
##
enabled: false
수정점 2: 3개로 수정
## @param replicaCount Number of ZooKeeper nodes
##
replicaCount: 3
5. Helm은 공공 서비스 네임스페이스에 Zookeeper를 설치합니다.
kubectl은 ns 공공 서비스를 생성합니다.
helm 설치 사육사 -n public-service .
zhangzk@k8smaster:~/helm/zookeeper$ kubectl create ns public-service
namespace/public-service created
zhangzk@k8smaster:~/helm/zookeeper$ helm install zookeeper -n public-service .
NAME: zookeeper
LAST DEPLOYED: Fri Aug 25 10:39:05 2023
NAMESPACE: public-service
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: zookeeper
CHART VERSION: 12.1.0
APP VERSION: 3.9.0
** Please be patient while the chart is being deployed **
ZooKeeper can be accessed via port 2181 on the following DNS name from within your cluster:
zookeeper.public-service.svc.cluster.local
To connect to your ZooKeeper server run the following commands:
export POD_NAME=$(kubectl get pods --namespace public-service -l "app.kubernetes.io/name=zookeeper,app.kubernetes.io/instance=zookeeper,app.kubernetes.io/component=zookeeper" -o jsonpath="{.items[0].metadata.name}")
kubectl exec -it $POD_NAME -- zkCli.sh
To connect to your ZooKeeper server from outside the cluster execute the following commands:
kubectl port-forward --namespace public-service svc/zookeeper 2181:2181 &
zkCli.sh 127.0.0.1:2181
6. Pod 상태 확인
kubectl get po -n 공공 서비스
zhangzk@k8smaster:~/helm/zookeeper$ kubectl get po -n public-service
NAME READY STATUS RESTARTS AGE
zookeeper-0 1/1 Running 0 102m
zookeeper-1 1/1 Running 0 102m
zookeeper-2 1/1 Running 0 102m
7. 노드 상태 확인
kubectl exec Zookeeper-0 -n 공공 서비스 /opt/bitnami/zookeeper/bin/zkServer.sh 상태
zhangzk@k8smaster:~/helm/zookeeper$ kubectl exec zookeeper-0 -n public-service /opt/bitnami/zookeeper/bin/zkServer.sh status
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
/opt/bitnami/java/bin/java
ZooKeeper JMX enabled by default
Using config: /opt/bitnami/zookeeper/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Mode: follower
8. 업그레이드 버전 업그레이드
Values.yaml 파일의 ReplicaCount를 1로 수정하고 저장합니다.
## @param replicaCount Number of ZooKeeper nodes
##
replicaCount: 1
그런 다음 helm 업그레이드 -n public-service Zookeeper 명령을 실행합니다.
zhangzk@k8smaster:~/helm/zookeeper$ helm upgrade -n public-service zookeeper .
Release "zookeeper" has been upgraded. Happy Helming!
NAME: zookeeper
LAST DEPLOYED: Fri Aug 25 14:40:05 2023
NAMESPACE: public-service
STATUS: deployed
REVISION: 2
TEST SUITE: None
NOTES:
CHART NAME: zookeeper
CHART VERSION: 12.1.0
APP VERSION: 3.9.0
** Please be patient while the chart is being deployed **
ZooKeeper can be accessed via port 2181 on the following DNS name from within your cluster:
zookeeper.public-service.svc.cluster.local
To connect to your ZooKeeper server run the following commands:
export POD_NAME=$(kubectl get pods --namespace public-service -l "app.kubernetes.io/name=zookeeper,app.kubernetes.io/instance=zookeeper,app.kubernetes.io/component=zookeeper" -o jsonpath="{.items[0].metadata.name}")
kubectl exec -it $POD_NAME -- zkCli.sh
To connect to your ZooKeeper server from outside the cluster execute the following commands:
kubectl port-forward --namespace public-service svc/zookeeper 2181:2181 &
zkCli.sh 127.0.0.1:2181
포드를 다시 확인하고 포드가 하나만 있는지 확인합니다. kubectl get po -n public-service
zhangzk@k8smaster:~/helm/zookeeper$ kubectl get po -n public-service
NAME READY STATUS RESTARTS AGE
zookeeper-0 1/1 Running 0 20s
9. 롤백 버전
1) 릴리스 기록 보기: helm History Zookeeper -n public-service
zhangzk@k8smaster:~/helm/zookeeper$ helm history zookeeper -n public-service
REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION
1 Fri Aug 25 12:40:59 2023 superseded zookeeper-12.1.0 3.9.0 Install complete
2 Fri Aug 25 14:40:05 2023 deployed zookeeper-12.1.0 3.9.0 Upgrade complete
2) 버전 1로 롤백: helm 롤백 Zookeeper 1 -n public-service
hangzk@k8smaster:~/helm/zookeeper$ helm rollback zookeeper 1 -n public-service
Rollback was a success! Happy Helming!
3) 포드를 다시 확인하고 3개의 포드로 변경되었는지 확인합니다. kubectl get po -n public-service
zhangzk@k8smaster:~/helm/zookeeper$ kubectl get po -n public-service
NAME READY STATUS RESTARTS AGE
zookeeper-0 1/1 Running 0 30m
zookeeper-1 1/1 Running 0 31m
zookeeper-2 1/1 Running 0 31m
10. 릴리스 제거
helm 제거 사육사 -n 공공 서비스
zhangzk@k8smaster:~/helm/zookeeper$ helm uninstall zookeeper -n public-service
release "zookeeper" uninstalled