39 lines
1.5 KiB
Bash
Executable File
39 lines
1.5 KiB
Bash
Executable File
#!/bin/sh -l
|
|
|
|
set -e # fail if any command fails
|
|
|
|
time=$(date)
|
|
echo "time=$time" >>"$GITHUB_OUTPUT"
|
|
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 - </tmp/manifests.yaml
|
|
echo "Done applying kustomized manifests at ${KUST_CONFIG}, success"
|