(作者:陈玓玏)
- 拉取镜像:docker pull zookeeper;
- 编辑yaml:
apiVersion: v1
kind: Service
metadata:name: zookeeperlabels:app: zookeeper
spec:ports:- name: clientport: 2181protocol: TCPtargetPort: 2181selector:app: zookeeper
---
apiVersion: apps/v1
kind: Deployment
metadata:name: zookeeperlabels:app: zookeeper
spec:selector:matchLabels:app: zookeeperreplicas: 1template:metadata:labels:app: zookeeperspec:containers:- name: zookeeperimage: zookeeper:3.6.2ports:- name: clientcontainerPort: 2181
- 部署zookeeper:
kubectl apply -f zk-dp-svc.yaml
- 验证是否成功:
使用以下命令启动Zookeeper客户端:
kubectl run -i --tty zk-client --image=zookeeper:3.6.2 --restart=Never --rm=true -- /bin/bash
在客户端中,可以使用zkCli.sh命令测试Zookeeper是否正常工作:
zkCli.sh -server zookeeper:2181
出现以上图片,表示可以正常执行zookeeper。
参考文章:https://blog.csdn.net/fushan2012/article/details/129556052