From eca2404def4acdbc5615cde8b2d6a78a966c0468 Mon Sep 17 00:00:00 2001
From: Serge Logvinov <serge.logvinov@sinextra.dev>
Date: Thu, 6 Apr 2023 12:38:54 +0300
Subject: [PATCH] Add pod tolerations to the helper-pod

Signed-off-by: Serge Logvinov <serge.logvinov@sinextra.dev>
---
 README.md                                                | 9 ++++++++-
 .../local-path-provisioner/templates/configmap.yaml      | 9 +++++++--
 deploy/example-config.yaml                               | 7 +++++--
 deploy/local-path-storage.yaml                           | 7 +++++--
 4 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/README.md b/README.md
index 68c7c7cc..606b549f 100644
--- a/README.md
+++ b/README.md
@@ -171,12 +171,19 @@ data:
         metadata:
           name: helper-pod
         spec:
+          priorityClassName: system-node-critical
+          tolerations:
+            - key: node.kubernetes.io/disk-pressure
+              operator: Exists
+              effect: NoSchedule
           containers:
           - name: helper-pod
             image: busybox
 
 ```
 
+The helperPod is allowed to run on nodes experiencing disk pressure conditions, despite the potential resource constraints. When it runs on such a node, it can carry out specific cleanup tasks, freeing up space in PVCs, and resolving the disk-pressure issue.
+
 #### `config.json`
 
 ##### Definition
@@ -235,7 +242,7 @@ If the reload fails, the provisioner will log the error and **continue using the
 
 To specify the type of volume you want the provisioner to create, add either of the following annotations;
 
-- PVC: 
+- PVC:
 ```yaml
 annotations:
   volumeType: <local or hostPath>
diff --git a/deploy/chart/local-path-provisioner/templates/configmap.yaml b/deploy/chart/local-path-provisioner/templates/configmap.yaml
index c9532a7d..6ad117b6 100644
--- a/deploy/chart/local-path-provisioner/templates/configmap.yaml
+++ b/deploy/chart/local-path-provisioner/templates/configmap.yaml
@@ -16,15 +16,20 @@ data:
     {{- end }}
     {{- $config | toPrettyJson | nindent 4 }}
   setup: |-
-    {{ .Values.configmap.setup | nindent 4 }}
+    {{- .Values.configmap.setup | nindent 4 }}
   teardown: |-
-    {{ .Values.configmap.teardown | nindent 4 }}
+    {{- .Values.configmap.teardown | nindent 4 }}
   helperPod.yaml: |-
     apiVersion: v1
     kind: Pod
     metadata:
       name: helper-pod
     spec:
+      priorityClassName: system-node-critical
+      tolerations:
+        - key: node.kubernetes.io/disk-pressure
+          operator: Exists
+          effect: NoSchedule
       containers:
         - name: helper-pod
           {{- if .Values.privateRegistry.registryUrl }}
diff --git a/deploy/example-config.yaml b/deploy/example-config.yaml
index bf361788..795f9df9 100644
--- a/deploy/example-config.yaml
+++ b/deploy/example-config.yaml
@@ -35,9 +35,12 @@ data:
     metadata:
       name: helper-pod
     spec:
+      priorityClassName: system-node-critical
+      tolerations:
+        - key: node.kubernetes.io/disk-pressure
+          operator: Exists
+          effect: NoSchedule
       containers:
       - name: helper-pod
         image: busybox
         imagePullPolicy: IfNotPresent
-
-
diff --git a/deploy/local-path-storage.yaml b/deploy/local-path-storage.yaml
index 2b6b68ee..ec5482bb 100644
--- a/deploy/local-path-storage.yaml
+++ b/deploy/local-path-storage.yaml
@@ -148,9 +148,12 @@ data:
     metadata:
       name: helper-pod
     spec:
+      priorityClassName: system-node-critical
+      tolerations:
+        - key: node.kubernetes.io/disk-pressure
+          operator: Exists
+          effect: NoSchedule
       containers:
       - name: helper-pod
         image: busybox
         imagePullPolicy: IfNotPresent
-
-
-- 
GitLab