(作者:陈玓玏)
- 拉取镜像:docker pull zookeeper;
- 编辑yaml:
apiVersion: v1
kind: Service
metadata:
name: zookeeper
labels:
app: zookeeper
spec:
ports:
- name: client
port: 2181
protocol: TCP
targetPort: 2181
selector:
app: zookeeper
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: zookeeper
labels:
app: zookeeper
spec:
selector:
matchLabels:
app: zookeeper
replicas: 1
template:
metadata:
labels:
app: zookeeper
spec:
containers:
- name: zookeeper
image: zookeeper:3.6.2
ports:
- name: client
containerPort: 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