---
kind: Deployment
apiVersion: apps/v1
metadata:
  name: csi-sfs-controller
  namespace: kube-system
spec:
  selector:
    matchLabels:
      app: csi-sfs-controller
  template:
    metadata:
      labels:
        app: csi-sfs-controller
    spec:
      serviceAccountName: csi-sfs-controller-sa
      nodeSelector:
        kubernetes.io/os: linux
      priorityClassName: system-cluster-critical
      tolerations:
        - key: "node-role.kubernetes.io/master"
          operator: "Equal"
          value: "true"
          effect: "NoSchedule"
      containers:
        - name: csi-provisioner
          image: quay.io/k8scsi/csi-provisioner:v1.4.0
          args:
            - "-v=5"
            - "--csi-address=$(ADDRESS)"
            - "--enable-leader-election"
            - "--leader-election-type=leases"
          env:
            - name: ADDRESS
              value: /csi/csi.sock
          volumeMounts:
            - mountPath: /csi
              name: socket-dir
        - name: csi-attacher
          image: quay.io/k8scsi/csi-attacher:v2.0.0
          args:
            - "-v=5"
            - "--csi-address=$(ADDRESS)"
          env:
            - name: ADDRESS
              value: /csi/csi.sock
          volumeMounts:
            - mountPath: /csi
              name: socket-dir
        - name: sfs-csi-plugin
          image: docker.io/zhenguo/sfs-csi-plugin:latest
          args:
            - "--v=2"
            - "--logtostderr"
            - "--endpoint=$(CSI_ENDPOINT)"
            - "--nodeid=$(NODE_ID)"
            - "--cloud-config=$(CLOUD_CONFIG)"
          ports:
            - containerPort: 28888
              name: healthz
              protocol: TCP
          livenessProbe:
            failureThreshold: 5
            httpGet:
              path: /healthz
              port: healthz
            initialDelaySeconds: 30
            timeoutSeconds: 10
            periodSeconds: 30
          env:
            - name: NODE_ID
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
            - name: CSI_ENDPOINT
              value: unix://csi/csi.sock
            - name: CLOUD_CONFIG
              value: /etc/sfs/cloud-config
          volumeMounts:
            - mountPath: /csi
              name: socket-dir
            - mountPath: /etc/sfs/
              name: sfs-config
        - name: liveness-probe
          imagePullPolicy: Always
          image: quay.io/k8scsi/livenessprobe:v1.1.0
          args:
            - --csi-address=/csi/csi.sock
            - --connection-timeout=3s
            - --health-port=28888
            - --v=5
          volumeMounts:
            - mountPath: /csi
              name: socket-dir
      volumes:
        - name: socket-dir
          emptyDir: {}
        - name: sfs-config
          hostPath:
            path: /etc/sfs/
            type: Directory
