From 122fce020e7ea3562e425990651072e7bf31d969 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= <valtri@civ.zcu.cz>
Date: Mon, 22 Apr 2024 15:53:41 +0000
Subject: [PATCH] Local path provisioner in Kubernetes to implement ephemeral
 volumes

---
 cesnet-central/playbooks/k8s.yaml | 39 +++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/cesnet-central/playbooks/k8s.yaml b/cesnet-central/playbooks/k8s.yaml
index 72f1dda..d0e9cb8 100644
--- a/cesnet-central/playbooks/k8s.yaml
+++ b/cesnet-central/playbooks/k8s.yaml
@@ -25,6 +25,7 @@
           - atop
           - cron-apt
           - fail2ban
+          - git
           - mc
           - vim
           - postfix
@@ -262,6 +263,44 @@
         KUBECONFIG: /etc/kubernetes/admin.conf
         PATH: /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
       when: true
+    - name: Git clone local-path-provisioner
+      git:
+        repo: https://github.com/rancher/local-path-provisioner.git
+        dest: "/root/git-local-path-provisioner"
+        clone: yes
+        update: no
+        version: v0.0.26
+    - name: Local path provisioner configuration
+      copy:
+        dest: /tmp/local-path-provisioner.yaml
+        mode: 0644
+        content: |
+          storageClass:
+            defaultClass: false
+            defaultVolumeType: hostPath
+            name: local-path
+          nodePathMap:
+            - node: DEFAULT_PATH_FOR_NON_LISTED_NODES
+              paths:
+                - /scratch
+    - name: Local path provisioner deployment
+      vars:
+        config: >-
+          --namespace local-path-storage
+          -f /tmp/local-path-provisioner.yaml
+          local-path-storage
+          /root/git-local-path-provisioner/deploy/chart/local-path-provisioner/
+      shell: |-
+        helm status --namespace local-path-storage local-path-storage
+        if [ $? -ne 0 ]; then
+            helm install {{ config }}
+        else
+            helm upgrade {{ config }}
+        fi
+      environment:
+        KUBECONFIG: /etc/kubernetes/admin.conf
+        PATH: /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
+      when: true
     - name: Helm repo add ingress-nginx
       shell: |-
         helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
-- 
GitLab