---
kind: Deployment
apiVersion: apps/v1
metadata:
  name: csi-curve-plugin-provisioner
  namespace: csi-system
spec:
  replicas: 2
  selector:
    matchLabels:
      app: csi-curve-plugin-provisioner
  template:
    metadata:
      labels:
        app: csi-curve-plugin-provisioner
    spec:
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: app
                operator: In
                values:
                - csi-curve-plugin-provisioner
            topologyKey: kubernetes.io/hostname
      serviceAccount: curve-csi-provisioner
      hostNetwork: true
      hostPID: true
      dnsPolicy: ClusterFirstWithHostNet
      containers:
      - name: csi-provisioner
        image: quay.io/k8scsi/csi-provisioner:v1.3.0
        args:
        - "--csi-address=$(ADDRESS)"
        - "--v=5"
        - "--timeout=150s"
        - "--retry-interval-start=500ms"
        - "--enable-leader-election=true"
        - "--leader-election-type=leases"
        env:
        - name: ADDRESS
          value: unix:///csi/csi-provisioner.sock
        volumeMounts:
        - name: socket-dir
          mountPath: /csi
      - name: csi-attacher
        image: quay.io/k8scsi/csi-attacher:v1.2.0
        args:
        - "--v=5"
        - "--csi-address=$(ADDRESS)"
        - "--leader-election=true"
        - "--leader-election-type=leases"
        env:
        - name: ADDRESS
          value: /csi/csi-provisioner.sock
        - name: POD_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        volumeMounts:
        - name: socket-dir
          mountPath: /csi
      - name: csi-resizer
        image: quay.io/k8scsi/csi-resizer:v0.2.0
        args:
        - "--v=5"
        - "--csi-address=$(ADDRESS)"
        - "--leader-election=true"
        env:
        - name: ADDRESS
          value: /csi/csi-provisioner.sock
        - name: POD_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        volumeMounts:
        - name: socket-dir
          mountPath: /csi
      - name: csi-curveplugin
        securityContext:
          privileged: true
          capabilities:
            add: ["SYS_ADMIN"]
        image: quay.io/curvecsi/curve-csi:csi-v1.1.0-rc1
        args:
        - --endpoint=$(CSI_ENDPOINT)
        - --drivername=curve.csi.netease.com
        - --nodeid=$(NODE_ID)
        - --controller-server=true
        - --debug-port=9696
        - --logtostderr=false
        - --log_dir=/var/log/csi-curveplugin
        - -v=4
        env:
        - name: POD_IP
          valueFrom:
            fieldRef:
              fieldPath: status.podIP
        - name: POD_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        - name: NODE_ID
          valueFrom:
            fieldRef:
              fieldPath: spec.nodeName
        - name: CSI_ENDPOINT
          value: unix:///csi/csi-provisioner.sock
        volumeMounts:
        - name: socket-dir
          mountPath: /csi
        - mountPath: /etc/localtime
          name: localtime
        - mountPath: /var/log/csi-curveplugin
          name: log
      volumes:
      - name: socket-dir
        emptyDir:
          medium: Memory
      - hostPath:
          path: /etc/localtime
        name: localtime
      - hostPath:
          path: /var/log/csi-curveplugin-ctrl
        name: log
