apiVersion: apps/v1
kind: Deployment
metadata:
  name: pod-single-zk
  namespace: devopsroot

spec:
  selector:
    matchLabels:
      app: pod-single-zk
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: pod-single-zk
    spec:
      containers:
        - image: zookeeper:3.7.0
          imagePullPolicy: IfNotPresent
          name: pod-single-zk
          env:
            - name: TZ
              value: Asia/Shanghai
            - name: LANG
              value: en_US.UTF-8
          ports:
            - name: svc-zk-1m0s
              containerPort: 2181
          livenessProbe:
            tcpSocket:
              port: 2181
          readinessProbe:
            tcpSocket:
              port: 2181
          resources:
            limits:
              cpu: "1"
              memory: "1G"
            requests:
              cpu: "1"
              memory: "512Mi"
          volumeMounts:
            - name: vod-pv-single-zk-data
              mountPath: /data # 容器内部文件系统的挂载点，它定义了容器内部将外部存储卷（如 PersistentVolume、ConfigMap、Secret 等）挂载到哪个路径下。通过 mountPath，容器可以访问这些挂载的数据或配置
            - name: vod-pv-single-zk-datalog
              mountPath: /datalog
      volumes:
        - name: timezone
          hostPath:
            path: /usr/share/zoneinfo/Asia/Shanghai
        - name: vod-pv-single-zk-data
          hostPath:
            path: /mnt/data/pod-single-zk-data
            type: DirectoryOrCreate
        - name: vod-pv-single-zk-datalog
          hostPath:
            path: /mnt/data/pod-single-zk-datalog
            type: DirectoryOrCreate
---
apiVersion: v1
kind: Service
metadata:
  name: svc-zk-1m0s # 不能超过15个字符
  namespace: devops
  labels:
    app: pod-single-zk
spec:
  type: NodePort
  ports:
    - port: 2181
      targetPort: 2181
      nodePort: 30007 # 范围 30000-32767
  selector:
    app: pod-single-zk
