From 0a18ff4d30804715a003c7fbf7683dfe0ba31b21 Mon Sep 17 00:00:00 2001
From: amonhuang <amonhuang@synology.com>
Date: Fri, 2 Sep 2022 12:27:33 +0800
Subject: [PATCH] deploy attacher to node of provisioner runs

---
 deploy/helm/templates/attacher.yaml    | 7 +++++++
 deploy/helm/templates/provisioner.yaml | 6 +++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/deploy/helm/templates/attacher.yaml b/deploy/helm/templates/attacher.yaml
index c825406..ccf6502 100644
--- a/deploy/helm/templates/attacher.yaml
+++ b/deploy/helm/templates/attacher.yaml
@@ -79,6 +79,13 @@ spec:
       tolerations:
       - key: node-role.kubernetes.io/master
         operator: "Exists"
+      affinity:
+        podAffinity:
+          requiredDuringSchedulingIgnoredDuringExecution:
+          - labelSelector:
+              matchLabels:
+                  app: csi-provisioner-s3
+            topologyKey: kubernetes.io/hostname
       containers:
         - name: csi-attacher
           image: {{ .Values.images.attacher }}
diff --git a/deploy/helm/templates/provisioner.yaml b/deploy/helm/templates/provisioner.yaml
index 46d0bb8..13b2986 100644
--- a/deploy/helm/templates/provisioner.yaml
+++ b/deploy/helm/templates/provisioner.yaml
@@ -56,6 +56,8 @@ kind: StatefulSet
 apiVersion: apps/v1
 metadata:
   name: csi-provisioner-s3
+  labels:
+    app: csi-provisioner-s3
   namespace: {{ .Release.Namespace }}
 spec:
   serviceName: "csi-provisioner-s3"
@@ -112,4 +114,6 @@ spec:
               mountPath: /var/lib/kubelet/plugins/ru.yandex.s3.csi
       volumes:
         - name: socket-dir
-          emptyDir: {}
+          hostPath:
+            path: /var/lib/kubelet/plugins/ru.yandex.s3.csi
+            type: DirectoryOrCreate