基础信息:
Helm v3.12.3
Kubernetes v1.28.0
Containerd.io 1.6.22
以下为练习使用helm来安装、升级、回滚、卸载zookeeper的过程,供参考。
1、helm添加BitNami仓库
helm repo add 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、查看zookeeper的chart
helm search repo zookeeper
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、拉取chart到本地
helm pull bitnami/zookeeper
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、修改values.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
修改values.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到public-service命名空间
kubectl create ns public-service
helm install zookeeper -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 public-service
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 public-service /opt/bitnami/zookeeper/bin/zkServer.sh status
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、升级版本 upgrade
修改 values.yaml文件replicaCount 为1并且保存
## @param replicaCount Number of ZooKeeper nodes
##
replicaCount: 1
再执行如下命令:helm upgrade -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
再次查看pod发现只有一个pod了: 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 rollback zookeeper 1 -n public-service
hangzk@k8smaster:~/helm/zookeeper$ helm rollback zookeeper 1 -n public-service
Rollback was a success! Happy Helming!
3)再次查看pod发现又变更为3个pod了: 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、卸载release文章来源:https://www.toymoban.com/news/detail-681380.html
helm uninstall zookeeper -n public-service文章来源地址https://www.toymoban.com/news/detail-681380.html
zhangzk@k8smaster:~/helm/zookeeper$ helm uninstall zookeeper -n public-service
release "zookeeper" uninstalled
到了这里,关于helm部署zookeeper的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!