# Controller Service
kind: Deployment
apiVersion: apps/v1
metadata:
  name: webdav-csi-controller
  namespace: kube-system
spec:
  replicas: 2
  selector:
    matchLabels:
      app: webdav-csi-controller
  template:
    metadata:
      labels:
        app: webdav-csi-controller
    spec:
      serviceAccount: webdav-csi-controller-sa
      priorityClassName: system-cluster-critical
      tolerations:
        - key: CriticalAddonsOnly
          operator: Exists
      containers:
        - name: webdav-plugin
          image: scodeman/webdav-csi-driver:latest
          args :
            - --endpoint=$(CSI_ENDPOINT)
            - --nodeid=$(NODE_ID)
            - --secretpath=$(SECRET_VOLUME_PATH)
            - --logtostderr
            - --v=5
          env:
            - name: CSI_ENDPOINT
              value: unix:///var/lib/csi/sockets/pluginproxy/csi.sock
            - name: SECRET_VOLUME_PATH
              value: /secrets
            - name: NODE_ID
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
          volumeMounts:
            - name: plugin-dir
              mountPath: /var/lib/csi/sockets/pluginproxy
            - name: secret-volume
              mountPath: /secrets
        - name: csi-provisioner
          image: quay.io/k8scsi/csi-provisioner:v1.6.0
          args:
            - --timeout=5m
            - --csi-address=$(ADDRESS)
            - --v=5
            - --enable-leader-election
            - --leader-election-type=leases
          env:
            - name: ADDRESS
              value: /var/lib/csi/sockets/pluginproxy/csi.sock
          volumeMounts:
            - name: plugin-dir
              mountPath: /var/lib/csi/sockets/pluginproxy
      volumes:
        - name: plugin-dir
          emptyDir: {}
        - name: secret-volume
          secret:
            secretName: sodeman-csi-driver-global-secret
      nodeSelector:
        kubernetes.io/os: linux
        kubernetes.io/arch: amd64
