apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: synology-csi-attacher
  namespace: synology-csi
spec:
  replicas: 1
  selector:
    matchLabels:
      app: synology-csi-attacher
  template:
    metadata:
      labels:
        app: synology-csi-attacher
    spec:
      serviceAccountName: synology-csi-attacher
      hostNetwork: true
      containers:
        - name: csi-attacher
          image: k8s.gcr.io/sig-storage/csi-attacher:v3.3.0
          args:
            - --csi-address=$(ADDRESS)
          env:
            - name: ADDRESS
              value: /var/lib/csi/sockets/pluginproxy/csi.sock
          volumeMounts:
            - name: socket-dir
              mountPath: /var/lib/csi/sockets/pluginproxy/
          imagePullPolicy: Always
          securityContext:
            allowPrivilegeEscalation: true
            capabilities:
              add: ["SYS_ADMIN"]
            privileged: true
        - name: csi-plugin
          image: ghcr.io/ressu/synology-csi:v1
          args:
            - --nodeid
            - NotUsed
            - --endpoint=$(CSI_ENDPOINT)
            - --synology-config
            - /etc/synology/syno-config.yml
            - --logtostderr
          env:
            - name: CSI_ENDPOINT
              value: unix:///var/lib/csi/sockets/pluginproxy/csi.sock
            - name: DEVICE_ID
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
          volumeMounts:
            - name: socket-dir
              mountPath: /var/lib/csi/sockets/pluginproxy/
            - name: synology-config
              readOnly: true
              mountPath: /etc/synology
          imagePullPolicy: Always
          securityContext:
            allowPrivilegeEscalation: true
            capabilities:
              add: ["SYS_ADMIN"]
            privileged: true
      volumes:
        - name: socket-dir
          emptyDir: {}
        - name: synology-config
          secret:
            secretName: synology-config
  serviceName: "synology-csi-attacher"
