From 44a237aed4c3d8257478be266ebf38b7f3f0ad80 Mon Sep 17 00:00:00 2001 From: Chris Oloff Date: Wed, 1 Jan 2025 15:23:25 +0200 Subject: [PATCH] add calling kubectl etc to apply kustomizations and then deploy by applying the manifests --- entrypoint.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/entrypoint.sh b/entrypoint.sh index ac39c74..d0fd436 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -7,3 +7,31 @@ echo "env:" env echo "github output:" cat "$GITHUB_OUTPUT" + +KUST_CONFIG=$1 + +echo "Going to apply kustomization configuration at ${KUST_CONFIG}" +echo "K3S_YAML:" +echo "$K3S_YAML" +echo "$K3S_YAML" | base64 -d >/tmp/k3s.yaml +chmod 600 /tmp/k3s.yaml +ls -lth /tmp/ +echo "K3S_YAML, deserialized:" +cat /tmp/k3s.yaml +cp -r ./kustomize /tmp/ # TODO: we expect the kustomize folder to be present in the root of the repository +find /tmp/kustomize -type f -print0 | xargs -0 sed -i "s/GIT_VERSION/${CI_COMMIT_SHA}/" +echo "try and get nodes and version... (debugging)" +kubectl --kubeconfig /tmp/k3s.yaml get all +kubectl --kubeconfig /tmp/k3s.yaml version +echo "determine kustomize version..." +KUSTOMIZE_VERSION=$(kubectl --kubeconfig /tmp/k3s.yaml version | grep Kustomize | awk '{ print $3 }') +echo "KUSTOMIZE_VERSION=${KUSTOMIZE_VERSION}" +echo "run kustomize, and print output to console" +kubectl --kubeconfig /tmp/k3s.yaml kustomize "/tmp/${KUST_CONFIG}" +echo "replace faulty kustomize version (compare https://github.com/kubernetes/kubectl/issues/1495)" +kubectl --kubeconfig /tmp/k3s.yaml kustomize "/tmp/${KUST_CONFIG}" | sed "s/kustomize-(devel)/kustomize-$KUSTOMIZE_VERSION/" >/tmp/manifests.yaml +echo "UPDATED YAML:" +cat /tmp/manifests.yaml +echo "applying..." +kubectl --kubeconfig /tmp/k3s.yaml apply -f -