apiVersion: apps/v1
#kind: StatefulSet
kind: Deployment
metadata:
  name:  minio2
  namespace: edoc2
  labels:
    app: minio2
    k8s-app: minio
spec:
  selector:
    matchLabels:
      app: minio2
  #serviceName: minio2
  replicas: 1
  template:
    metadata:
      labels:
        app: minio2
        k8s-app: minio
    spec:
      hostname: minio2
      containers:
      - name: minio2
        env:
        - name: MINIO_ACCESS_KEY
          value: "admin"
        - name: MINIO_SECRET_KEY
          value: "root123456"
        #- name: MINIO_ERASURE_SET_DRIVE_COUNT
        #  value: "4"
        #- name: MINIO_ERASURE_SET_DATA_SHARDS
        #  value: "8"
        #- name: MINIO_ERASURE_SET_PARITY_SHARDS
        #  value: "4"
        #image: registry.edoc2.com:5000/library/minio:prodv3-2023
        image: registry.edoc2.com:5000/library/minio:prodv3-2023
        imagePullPolicy: IfNotPresent
        command:
          - /bin/sh
          - -c
          - minio server --console-address ":5000" http://minio{0...2}/data{1...4}
        ports:
        - name: data
          containerPort: 9000
          protocol: "TCP"
        - name: console
          containerPort: 5000
          protocol: "TCP"
        volumeMounts:
        # 容器内第一块磁盘(对应第1个drives，每个drives绑定磁盘)
        - name: minio-data1
          mountPath: /data1
        # 容器内第二块磁盘(对应第2个drives，每个drives绑定磁盘)
        - name: minio-data2
          mountPath: /data2
        # 容器内第三块磁盘(对应第3个drives，每个drives绑定磁盘)
        - name: minio-data3
          mountPath: /data3
        # 容器内第四块磁盘(对应第4个drives，每个drives绑定磁盘)
        - name: minio-data4
          mountPath: /data4
        # 加盘或去盘自行操作，自行调整 http://minio{0...2}/data{1...4} 花括号中盘位数
        - name: date-config
          mountPath: /etc/localtime
      volumes:
      - name: date-config
        hostPath:
          path: /usr/share/zoneinfo/Asia/Shanghai
      # 每个节点宿主机第一块磁盘(共4个drives，第一个drives都有)
      - name: minio-data1
        hostPath:
          path: /home/data/minio01
          #type: DirectoryOrCreate
      # 每个节点宿主机第二块磁盘(共4个drives，第二个drives都有)
      - name: minio-data2
        hostPath:
          path: /home/data/minio02
          #type: DirectoryOrCreate
      # 每个节点宿主机第三块磁盘(共4个drives，第三个drives都有)
      - name: minio-data3
        hostPath:
          path: /home/data/minio03
          #type: DirectoryOrCreate
      # 每个节点宿主机第四块磁盘(共4个drives，第四个drives都有)
      - name: minio-data4
        hostPath:
          path: /home/data/minio04
          #type: DirectoryOrCreate
      # 节点亲和反亲和默认别动!
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: app
                operator: In
                values:
                - minio2
            topologyKey: "kubernetes.io/hostname"
      nodeSelector:
        "node.drives03.nodelabels": DRMiddleware03
---
apiVersion: v1
kind: Service
metadata:
  name: minio2
  namespace: edoc2
spec:
  type: NodePort
  #type: ClusterIP
  ports:
    - name: data
      port: 9000
      #nodePort: 32900
      targetPort: 9000
      protocol: TCP
    - name: console
      port: 5000
      nodePort: 32904
      targetPort: 5000
      protocol: TCP
  selector:
    app: minio2
