From 2d17d8a388869fc7dfc9fcc4915e2e02016be2a9 Mon Sep 17 00:00:00 2001
From: Michail Alexakis <alexakis@athenarc.gr>
Date: Sat, 3 Jun 2023 17:17:30 +0300
Subject: [PATCH] Replace `subPathExpr` with kustomization replacement

---
 base/job.yml                     |  4 ++--
 compile-java/1/kustomization.yml | 17 +++++++++++++++++
 compile-java/2/kustomization.yml | 18 ++++++++++++++++++
 echo/1/kustomization.yml         | 17 +++++++++++++++++
 echo/2/kustomization.yml         | 17 +++++++++++++++++
 echo/3/kustomization.yml         | 18 ++++++++++++++++++
 echo/4/kustomization.yml         | 17 +++++++++++++++++
 psd/1/input.yml                  |  4 ++--
 psd/1/kustomization.yml          | 17 +++++++++++++++++
 9 files changed, 125 insertions(+), 4 deletions(-)

diff --git a/base/job.yml b/base/job.yml
index f27e15b..3cae119 100644
--- a/base/job.yml
+++ b/base/job.yml
@@ -105,10 +105,10 @@ spec:
           mountPath: /.cache
         - name: data
           mountPath: /streamflow/results
-          subPathExpr: $(JOB_ID)/output
+          subPath: JOB_ID/output
         - name: data
           mountPath: /streamflow/project/input
-          subPathExpr: $(JOB_ID)/input
+          subPath: JOB_ID/input
           readOnly: true
         resources:
           limits:
diff --git a/compile-java/1/kustomization.yml b/compile-java/1/kustomization.yml
index acc3053..28853b6 100644
--- a/compile-java/1/kustomization.yml
+++ b/compile-java/1/kustomization.yml
@@ -11,3 +11,20 @@ configMapGenerator:
   - streamflow.yml
   envs:
   - env
+
+replacements:
+# NOTE this is a workaround for K8s<1.17 that dont support subPathExpr
+- source:
+    kind: ConfigMap
+    name: streamflow-config
+    fieldPath: data.JOB_ID
+  targets:
+  - select:
+      kind: Job
+      name: streamflow
+    fieldPaths:
+    - 'spec.template.spec.containers.[name=streamflow].volumeMounts.[name=data].subPath'
+    options:
+      index: 0
+      delimiter: '/'
+      create: true
diff --git a/compile-java/2/kustomization.yml b/compile-java/2/kustomization.yml
index e816221..6e7096e 100644
--- a/compile-java/2/kustomization.yml
+++ b/compile-java/2/kustomization.yml
@@ -11,3 +11,21 @@ configMapGenerator:
   - streamflow.yml
   envs:
   - env
+
+replacements:
+# NOTE this is a workaround for K8s<1.17 that dont support subPathExpr
+- source:
+    kind: ConfigMap
+    name: streamflow-config
+    fieldPath: data.JOB_ID
+  targets:
+  - select:
+      kind: Job
+      name: streamflow
+    fieldPaths:
+    - 'spec.template.spec.containers.[name=streamflow].volumeMounts.[name=data].subPath'
+    options:
+      index: 0
+      delimiter: '/'
+      create: true
+
diff --git a/echo/1/kustomization.yml b/echo/1/kustomization.yml
index 814642d..a17679b 100644
--- a/echo/1/kustomization.yml
+++ b/echo/1/kustomization.yml
@@ -11,3 +11,20 @@ configMapGenerator:
   - streamflow.yml
   envs:
   - env
+
+replacements:
+# NOTE this is a workaround for K8s<1.17 that dont support subPathExpr
+- source:
+    kind: ConfigMap
+    name: streamflow-config
+    fieldPath: data.JOB_ID
+  targets:
+  - select:
+      kind: Job
+      name: streamflow
+    fieldPaths:
+    - 'spec.template.spec.containers.[name=streamflow].volumeMounts.[name=data].subPath'
+    options:
+      index: 0
+      delimiter: '/'
+      create: true
diff --git a/echo/2/kustomization.yml b/echo/2/kustomization.yml
index 5d15cfb..3a3a9b2 100644
--- a/echo/2/kustomization.yml
+++ b/echo/2/kustomization.yml
@@ -11,3 +11,20 @@ configMapGenerator:
   - streamflow.yml
   envs:
   - env
+
+replacements:
+# NOTE this is a workaround for K8s<1.17 that dont support subPathExpr
+- source:
+    kind: ConfigMap
+    name: streamflow-config
+    fieldPath: data.JOB_ID
+  targets:
+  - select:
+      kind: Job
+      name: streamflow
+    fieldPaths:
+    - 'spec.template.spec.containers.[name=streamflow].volumeMounts.[name=data].subPath'
+    options:
+      index: 0
+      delimiter: '/'
+      create: true
diff --git a/echo/3/kustomization.yml b/echo/3/kustomization.yml
index 2ef0080..ef045d9 100644
--- a/echo/3/kustomization.yml
+++ b/echo/3/kustomization.yml
@@ -11,3 +11,21 @@ configMapGenerator:
   - streamflow.yml
   envs:
   - env
+
+replacements:
+# NOTE this is a workaround for K8s<1.17 that dont support subPathExpr
+- source:
+    kind: ConfigMap
+    name: streamflow-config
+    fieldPath: data.JOB_ID
+  targets:
+  - select:
+      kind: Job
+      name: streamflow
+    fieldPaths:
+    - 'spec.template.spec.containers.[name=streamflow].volumeMounts.[name=data].subPath'
+    options:
+      index: 0
+      delimiter: '/'
+      create: true
+  
diff --git a/echo/4/kustomization.yml b/echo/4/kustomization.yml
index d5825e9..9a9a374 100644
--- a/echo/4/kustomization.yml
+++ b/echo/4/kustomization.yml
@@ -11,3 +11,20 @@ configMapGenerator:
   - streamflow.yml
   envs:
   - env
+
+replacements:
+# NOTE this is a workaround for K8s<1.17 that dont support subPathExpr
+- source:
+    kind: ConfigMap
+    name: streamflow-config
+    fieldPath: data.JOB_ID
+  targets:
+  - select:
+      kind: Job
+      name: streamflow
+    fieldPaths:
+    - 'spec.template.spec.containers.[name=streamflow].volumeMounts.[name=data].subPath'
+    options:
+      index: 0
+      delimiter: '/'
+      create: true
diff --git a/psd/1/input.yml b/psd/1/input.yml
index 5f9ce0f..68d1a39 100644
--- a/psd/1/input.yml
+++ b/psd/1/input.yml
@@ -1,7 +1,7 @@
 input_file:
   class: File
-  #location: 'https://data-proxy.ebrains.eu/api/v1/permalinks/06b0b2c8-31cb-4108-b6a7-0d275e118339'
-  path: 'input/1.mat'
+  location: 'https://data-proxy.ebrains.eu/api/v1/permalinks/06b0b2c8-31cb-4108-b6a7-0d275e118339'
+  #path: 'input/1.mat'
 channels: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
 psd_output_file_name: 'psd.json'
 output_file_name: 'output.png'
diff --git a/psd/1/kustomization.yml b/psd/1/kustomization.yml
index 3f9c11d..e9cfcb9 100644
--- a/psd/1/kustomization.yml
+++ b/psd/1/kustomization.yml
@@ -15,3 +15,20 @@ configMapGenerator:
   - streamflow.yml
   envs:
   - env
+
+replacements:
+# NOTE this is a workaround for K8s<1.17 that dont support subPathExpr
+- source:
+    kind: ConfigMap
+    name: streamflow-config
+    fieldPath: data.JOB_ID
+  targets:
+  - select:
+      kind: Job
+      name: streamflow
+    fieldPaths:
+    - 'spec.template.spec.containers.[name=streamflow].volumeMounts.[name=data].subPath'
+    options:
+      index: 0
+      delimiter: '/'
+      create: true
-- 
GitLab