k8s安装zookeeper集群
作者:互联网
参考:https://blog.csdn.net/ljx1528/article/details/103166620
https://blog.csdn.net/miss1181248983/article/details/106588166/
二、部署
1. 拉取镜像
docker pull mirrorgooglecontainers/kubernetes-zookeeper:1.0-3.4.10
2. yaml文件
apiVersion: v1 kind: Service metadata: name: zk-hs namespace: indoorpositioning-dev labels: app: zk spec: selector: app: zk ports: - port: 2888 name: server - port: 3888 name: leader-election clusterIP: None --- apiVersion: v1 kind: Service metadata: name: zk-cs namespace: indoorpositioning-dev labels: app: zk spec: selector: app: zk ports: - port: 2181 name: client --- apiVersion: v1 kind: ConfigMap metadata: name: zk-config namespace: indoorpositioning-dev data: ensemble: "zk-0;zk-1;zk-2" replicas: "3" jvm.heap: "512M" tick: "2000" init: "10" sync: "5" client.cnxns: "60" snap.retain: "3" purge.interval: "1" --- apiVersion: policy/v1beta1 kind: PodDisruptionBudget metadata: name: zk-pdb namespace: indoorpositioning-dev spec: selector: matchLabels: app: zk minAvailable: 2 --- apiVersion: apps/v1 kind: StatefulSet metadata: name: zk namespace: indoorpositioning-dev spec: selector: matchLabels: app: zk serviceName: zk-hs replicas: 3 updateStrategy: type: RollingUpdate podManagementPolicy: OrderedReady template: metadata: labels: app: zk spec: affinity: podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchExpressions: - key: "app" operator: In values: - zk topologyKey: "kubernetes.io/hostname" containers: - name: zk image: mirrorgooglecontainers/kubernetes-zookeeper:1.0-3.4.10 imagePullPolicy: IfNotPresent ports: - containerPort: 2181 name: client - containerPort: 2888 name: server - containerPort: 3888 name: leader-election resources: requests: cpu: "500m" memory: "512Mi" env: - name : ZK_ENSEMBLE valueFrom: configMapKeyRef: name: zk-config key: ensemble - name : ZK_REPLICAS valueFrom: configMapKeyRef: name: zk-config key: replicas - name : ZK_HEAP_SIZE valueFrom: configMapKeyRef: name: zk-config key: jvm.heap - name : ZK_TICK_TIME valueFrom: configMapKeyRef: name: zk-config key: tick - name : ZK_INIT_LIMIT valueFrom: configMapKeyRef: name: zk-config key: init - name : ZK_SYNC_LIMIT valueFrom: configMapKeyRef: name: zk-config key: tick - name : ZK_MAX_CLIENT_CNXNS valueFrom: configMapKeyRef: name: zk-config key: client.cnxns - name: ZK_SNAP_RETAIN_COUNT valueFrom: configMapKeyRef: name: zk-config key: snap.retain - name: ZK_PURGE_INTERVAL valueFrom: configMapKeyRef: name: zk-config key: purge.interval - name: ZK_CLIENT_PORT value: "2181" - name: ZK_SERVER_PORT value: "2888" - name: ZK_ELECTION_PORT value: "3888" command: - sh - -c - zkGenConfig.sh && zkServer.sh start-foreground readinessProbe: exec: command: - "zkOk.sh" initialDelaySeconds: 15 timeoutSeconds: 5 livenessProbe: exec: command: - "zkOk.sh" initialDelaySeconds: 15 timeoutSeconds: 5 volumeMounts: - name: data mountPath: /var/lib/zookeeper volumes: - name: data emptyDir: {} securityContext: runAsUser: 1000 fsGroup: 1000
标签:name,ZK,config,valueFrom,zookeeper,集群,key,k8s,zk 来源: https://www.cnblogs.com/duaner92/p/14859756.html