---
kind: Deployment
apiVersion: apps/v1
metadata:
  name: csi-goofys-controller
  namespace: kube-system
spec:
  replicas: 1
  selector:
    matchLabels:
      app: csi-goofys-controller
  template:
    metadata:
      labels:
        app: csi-goofys-controller
    spec:
      serviceAccountName: csi-goofys-controller-sa
      nodeSelector:
        beta.kubernetes.io/os: linux
      priorityClassName: system-cluster-critical
      containers:
        - name: csi-provisioner
          image: mcr.microsoft.com/oss/kubernetes-csi/csi-provisioner:v1.4.0
          args:
            - "-v=5"
            - "--provisioner=goofys.csi.azure.com"
            - "--csi-address=$(ADDRESS)"
            - "--connection-timeout=15s"
            - "--enable-leader-election"
            - "--leader-election-type=leases"
          env:
            - name: ADDRESS
              value: /csi/csi.sock
          imagePullPolicy: Always
          volumeMounts:
            - mountPath: /csi
              name: socket-dir
          resources:
            limits:
              cpu: 200m
              memory: 200Mi
            requests:
              cpu: 10m
              memory: 20Mi
        - name: csi-attacher
          image: mcr.microsoft.com/oss/kubernetes-csi/csi-attacher:v1.2.0
          args:
            - "-v=5"
            - "-csi-address=$(ADDRESS)"
            - "-timeout=120s"
            - "-leader-election"
            - "-leader-election-type=leases"
          env:
            - name: ADDRESS
              value: /csi/csi.sock
          imagePullPolicy: Always
          volumeMounts:
            - mountPath: /csi
              name: socket-dir
          resources:
            limits:
              cpu: 200m
              memory: 200Mi
            requests:
              cpu: 10m
              memory: 20Mi
        - name: cluster-driver-registrar
          image: mcr.microsoft.com/oss/kubernetes-csi/csi-cluster-driver-registrar:v1.0.1
          args:
            - --csi-address=$(ADDRESS)
            - --driver-requires-attachment=true
            - --v=5
          env:
            - name: ADDRESS
              value: /csi/csi.sock
          volumeMounts:
            - name: socket-dir
              mountPath: /csi
          resources:
            limits:
              cpu: 200m
              memory: 200Mi
            requests:
              cpu: 10m
              memory: 20Mi
        - name: liveness-probe
          image: mcr.microsoft.com/oss/kubernetes-csi/livenessprobe:v1.1.0
          args:
            - --csi-address=/csi/csi.sock
            - --connection-timeout=3s
            - --health-port=29622
          volumeMounts:
            - name: socket-dir
              mountPath: /csi
          resources:
            limits:
              cpu: 200m
              memory: 200Mi
            requests:
              cpu: 10m
              memory: 20Mi
        - name: goofys
          image: andyzhangx/goofys-csi:latest
          args:
            - "--v=5"
            - "--endpoint=$(CSI_ENDPOINT)"
            - "--nodeid=$(KUBE_NODE_NAME)"
          ports:
            - containerPort: 29622
              name: healthz
              protocol: TCP
            - containerPort: 29624
              name: metrics
              protocol: TCP
          livenessProbe:
            failureThreshold: 5
            httpGet:
              path: /healthz
              port: healthz
            initialDelaySeconds: 30
            timeoutSeconds: 10
            periodSeconds: 30
          env:
            - name: AZURE_CREDENTIAL_FILE
              value: "/etc/kubernetes/azure.json"
            - name: CSI_ENDPOINT
              value: unix:///csi/csi.sock
          imagePullPolicy: Always
          volumeMounts:
            - mountPath: /csi
              name: socket-dir
            - mountPath: /etc/kubernetes/
              name: azure-cred
            - mountPath: /var/lib/waagent/ManagedIdentity-Settings
              readOnly: true
              name: msi
          resources:
            limits:
              cpu: 2
              memory: 2Gi
            requests:
              cpu: 10m
              memory: 20Mi
      volumes:
        - name: socket-dir
          emptyDir: {}
        - name: azure-cred
          hostPath:
            path: /etc/kubernetes/
            type: Directory
        - name: msi
          hostPath:
            path: /var/lib/waagent/ManagedIdentity-Settings
