---
kind: Deployment
apiVersion: apps/v1
metadata:
  name: fsx-csi-controller
spec:
  replicas: 2
  selector:
    matchLabels:
      app: fsx-csi-controller
  template:
    metadata:
      labels:
        app: fsx-csi-controller
    spec:
      nodeSelector:
        kubernetes.io/os: linux
        kubernetes.io/arch: amd64
      serviceAccount: fsx-csi-controller-sa
      tolerations:
        - key: CriticalAddonsOnly
          operator: Exists
      containers:
        - name: fsx-plugin
          image: amazon/aws-fsx-csi-driver:latest
          args :
            - --endpoint=$(CSI_ENDPOINT)
            - --logtostderr
            - --v=5
          env:
            - name: CSI_ENDPOINT
              value: unix:///var/lib/csi/sockets/pluginproxy/csi.sock
            - name: AWS_ACCESS_KEY_ID
              valueFrom:
                secretKeyRef:
                  name: aws-secret
                  key: AWS_ACCESS_KEY_ID
                  optional: true
            - name: AWS_SECRET_ACCESS_KEY
              valueFrom:
                secretKeyRef:
                  name: aws-secret
                  key: AWS_SECRET_ACCESS_KEY
                  optional: true
          volumeMounts:
            - name: socket-dir
              mountPath: /var/lib/csi/sockets/pluginproxy/
        - name: csi-provisioner
          image: quay.io/k8scsi/csi-provisioner:v1.3.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: socket-dir
              mountPath: /var/lib/csi/sockets/pluginproxy/
      volumes:
        - name: socket-dir
          emptyDir: {}
