# This YAML file contains attacher & csi driver API objects that are necessary
# to run external CSI attacher for rclone

kind: StatefulSet
apiVersion: apps/v1
metadata:
  name: csi-controller-rclone
  namespace: csi-rclone
spec:
  serviceName: "csi-controller-rclone"
  replicas: 1
  selector:
    matchLabels:
      app: csi-controller-rclone
  template:
    metadata:
      labels:
        app: csi-controller-rclone
    spec:
      serviceAccountName: csi-controller-rclone
      containers:
        - name: csi-attacher
          image: ghcr.io/jmcarbo/csi-attacher:v3.1.0
          args:
            - "--v=5"
            - "--csi-address=$(ADDRESS)"
          env:
            - name: ADDRESS
              value: /csi/csi.sock
          imagePullPolicy: "Always"
          volumeMounts:
            - name: socket-dir
              mountPath: /csi
        - name: csi-cluster-driver-registrar
          image: ghcr.io/jmcarbo/csi-node-driver-registrar:v2.1.0
          args:
            - "--v=5"
            - "--pod-info-mount-version=\"v1\""
            - "--csi-address=$(ADDRESS)"
          env:
            - name: ADDRESS
              value: /csi/csi.sock
          volumeMounts:
            - name: socket-dir
              mountPath: /csi
        - name: rclone
          image: ghcr.io/jmcarbo/csi-rclone-plugin:v1.2.0
          args :
            - "--nodeid=$(NODE_ID)"
            - "--endpoint=$(CSI_ENDPOINT)"
          env:
            - name: NODE_ID
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
            - name: CSI_ENDPOINT
              value: unix://plugin/csi.sock
          imagePullPolicy: "Always"
          volumeMounts:
            - name: socket-dir
              mountPath: /plugin
      volumes:
        - name: socket-dir
          emptyDir: {}

