kind: StatefulSet
apiVersion: apps/v1
metadata:
  name: csi-linode-controller
  namespace: kube-system
  labels:
    app: csi-linode-controller
spec:
  serviceName: "csi-linode"
  replicas: 1
  selector:
    matchLabels:
      app: csi-linode-controller
  template:
    metadata:
      labels:
        app: csi-linode-controller
        role: csi-linode
    spec:
      serviceAccount: csi-controller-sa
      initContainers:
        - name: init
          image: bitnami/kubectl:1.16.3-debian-10-r36
          command:
            - /scripts/get-linode-id.sh
          env:
            - name: NODE_NAME
              valueFrom:
                fieldRef:
                  apiVersion: v1
                  fieldPath: spec.nodeName
          volumeMounts:
          - name: linode-info
            mountPath: /linode-info
          - name: get-linode-id
            mountPath: /scripts
      containers:
        - name: csi-provisioner
          image: k8s.gcr.io/sig-storage/csi-provisioner:v3.0.0
          imagePullPolicy: IfNotPresent
          args:
            - "--default-fstype=ext4"
            - "--volume-name-prefix=pvc"
            - "--volume-name-uuid-length=16"
            - "--csi-address=$(ADDRESS)"
            - "--v=2"
          env:
            - name: ADDRESS
              value: /var/lib/csi/sockets/pluginproxy/csi.sock
          volumeMounts:
            - name: socket-dir
              mountPath: /var/lib/csi/sockets/pluginproxy/
        - name: csi-attacher
          image: k8s.gcr.io/sig-storage/csi-attacher:v3.3.0
          imagePullPolicy: IfNotPresent
          args:
            - "--v=2"
            - "--csi-address=$(ADDRESS)"
          env:
            - name: ADDRESS
              value: /var/lib/csi/sockets/pluginproxy/csi.sock
          volumeMounts:
            - name: socket-dir
              mountPath: /var/lib/csi/sockets/pluginproxy/
        - name: csi-resizer
          image: k8s.gcr.io/sig-storage/csi-resizer:v1.3.0
          imagePullPolicy: IfNotPresent
          args:
          - "--v=2"
          - "--csi-address=$(ADDRESS)"
          env:
          - name: ADDRESS
            value: /var/lib/csi/sockets/pluginproxy/csi.sock
          volumeMounts:
          - name: socket-dir
            mountPath: /var/lib/csi/sockets/pluginproxy/
        - name: linode-csi-plugin
          image: linode/linode-blockstorage-csi-driver:latest
          args:
            - "--endpoint=$(CSI_ENDPOINT)"
            - "--token=$(LINODE_TOKEN)"
            - "--url=$(LINODE_API_URL)"
            - "--node=$(NODE_NAME)"
            - "--bs-prefix=$(LINODE_BS_PREFIX)"
            - "--v=2"
          env:
            - name: CSI_ENDPOINT
              value: unix:///var/lib/csi/sockets/pluginproxy/csi.sock
            - name: LINODE_API_URL
              value: https://api.linode.com/v4
            - name: LINODE_BS_PREFIX
            - name: NODE_NAME
              valueFrom:
                fieldRef:
                  apiVersion: v1
                  fieldPath: spec.nodeName
            - name: LINODE_TOKEN
              valueFrom:
                secretKeyRef:
                  name: linode
                  key: token
          volumeMounts:
            - name: linode-info
              mountPath: /linode-info
            - name: get-linode-id
              mountPath: /scripts
            - name: socket-dir
              mountPath: /var/lib/csi/sockets/pluginproxy/
      tolerations:
      - effect: NoSchedule
        operator: Exists
      - key: CriticalAddonsOnly
        operator: Exists
      - effect: NoExecute
        operator: Exists
      volumes:
        - name: socket-dir
          emptyDir: {}
        - name: linode-info
          emptyDir: {}
        - name: get-linode-id
          configMap:
            name: get-linode-id
            # octal mode 755
            defaultMode: 493
