kafka-zookeeper集群部署
zk使用官方镜像,版本为3.5
本文跳过rbac之类配置,与前文相同
# cat zk-statefulset.yaml
apiVersion: v1
kind: Service
metadata:
name: zk-svc
namespace: elk
labels:
app: zk-cluster-svc
spec:
selector:
app: zookeeper-3.5
type: ClusterIP
clusterIP: None
#publishNotReadyAddresses: true
sessionAffinity: ClientIP
ports:
- name: clientport
port: 2181
protocol: TCP
targetPort: 2181
- name: select-port
port: 3888
protocol: TCP
targetPort: 3888
- name: leader-port
port: 2888
protocol: TCP
targetPort: 2888
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: zk-statefulset
namespace: elk
spec:
podManagementPolicy: OrderedReady
replicas: 3
selector:
matchLabels:
app: zookeeper-3.5
serviceName: zk-svc
template:
metadata:
name: zk
namespace: elk
labels:
app: zookeeper-3.5
spec:
containers:
- name: kafka
image: 3.127.33.174:8443/elk/zookeeper:3.5
imagePullPolicy: IfNotPresent
resources:
limits:
memory: "1Gi"
cpu: "256m"
env:
- name: NODE_ID
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: ZOO_SERVERS
value: server.0=zk-statefulset-0.zk-svc:2888:3888;2181 server.1=zk-statefulset-1.zk-svc:2888:3888;2181 server.2=zk-statefulset-2.zk-svc:2888:3888;2181
- name: ZOO_TICK_TIME
value: "10000"
- name: ZOO_DATA_LOG_DIR
value: /data/log
args: ["/bin/sh","-c","echo 'clientPort=2181' >> /conf/zoo.cfg; echo ${HOSTNAME##*-} > /data/myid; ./bin/zkServer.sh start-foreground"]
ports:
- name: clientport
containerPort: 2181
protocol: TCP
- name: leaderport
containerPort: 2888
protocol: TCP
- name: select-leader
containerPort: 3888
protocol: TCP
volumeMounts:
- name: zk-cluster-claim
mountPath: /data
- name: timezone
mountPath: /etc/localtime
livenessProbe:
periodSeconds: 30
tcpSocket:
port: 2181
volumes:
- name: timezone
hostPath:
path: /etc/localtime
tolerations:
- key: node-role.kubernetes.io
effect: NoSchedule
operator: Equal
value: master
- effect: NoSchedule
operator: Exists
affinity:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
preference:
matchExpressions:
- key: node
operator: In
values:
- master1
- node1
volumeClaimTemplates:
- metadata:
name: zk-cluster-claim
namespace: elk
spec:
accessModes:
- ReadWriteMany
resources:
limits:
storage: 5Gi
storageClassName: zk-managed-nfs-storage
updateStrategy:
type: RollingUpdate
[root@k8s-master01 kafka-zk]# kubectl get pods -n elk | grep zk
1664434686097.jpg