From 435b2f9fcc46314038f14c38d7da2afe50251b88 Mon Sep 17 00:00:00 2001 From: Andreas Neue Date: Wed, 20 Sep 2023 14:11:20 +0200 Subject: [PATCH] second take on kubectl apply with multi file manifests --- k8s.mk | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/k8s.mk b/k8s.mk index c965a5d..bc962fb 100644 --- a/k8s.mk +++ b/k8s.mk @@ -4,28 +4,30 @@ MANDATORY-k8s = K8S_CONTEXT -k8s_fetch_manifest = \ - if [ $(1) == "http*" ]; then \ - curl -o $(2) $(1) \ - else \ - cp $(1) $(2) \ - fi - +start-k8s: SHELL:=/bin/bash start-k8s: - @- echo "\n### starting deployment with k8s" - @- echo "\n### setting kubernetes context to $(K8S_CONTEXT)" - @ kubectl config use-context $(K8S_CONTEXT) + @- echo "### starting deployment with k8s" + @- echo "### setting kubernetes context to $(K8S_CONTEXT)" + #@ kubectl config use-context $(K8S_CONTEXT) - @- echo "\n### run kubectl apply -f kubernetes.yaml and secrets.yaml" + @- echo "### run kubectl apply -f kubernetes.yaml and secrets.yaml" @- cat kubernetes.yaml secrets.yaml >_manifest.yaml ifdef K8S_MANIFESTS - @- $(foreach file,$(K8S_MANIFESTS), \ - $(call k8s_fetch_manifest($(file),"_tmpfile.yaml")); \ + @- echo "\n%%%DEBUG1" + @- echo $(K8S_MANIFESTS) + @- for file in $(K8S_MANIFESTS); do \ + if [[ $$file == http* ]] ; \ + then \ + curl -o _tmpfile.yaml $$file; \ + else \ + cp $$file _tmpfile.yaml; \ + fi; \ cat _tmpfile.yaml >>_manifest.yaml; \ rm _tmpfile.yaml; \ - ) + done endif + @- echo "\n%%%DEBUG22" @ cat _manifest.yaml | envsubst | kubectl apply -f - @- rm _manifest.yaml