#!/bin/bash if [ "$IMAGE_TAG" == "" ]; then echo "Make sure IMAGE_TAG is set" exit 1 fi IMAGE_NAME=gitea.hottis.de/deployments/exim-forwarder NAMESPACE=forwarder DEPLOYMENT_DIR=$PWD/deployment TOOLS_DIR=$PWD/tools pushd $DEPLOYMENT_DIR > /dev/null kubectl create namespace $NAMESPACE \ --dry-run=client \ -o yaml | \ kubectl -f - apply echo "Applying certificate..." kubectl apply -f $DEPLOYMENT_DIR/certificate.yml -n $NAMESPACE echo "Waiting for certificate secret to be created..." kubectl wait --for=condition=Ready certificate/exim-forwarder-cert -n $NAMESPACE --timeout=300s if [ $? -ne 0 ]; then echo "Certificate secret creation failed or timed out" exit 1 fi echo "Certificate ready, applying deployment..." cat $DEPLOYMENT_DIR/deploy-yml.tmpl | \ sed -e 's,%IMAGE%,'$IMAGE_NAME':'$IMAGE_TAG','g | \ kubectl apply -f - -n $NAMESPACE popd > /dev/null pushd $TOOLS_DIR > /dev/null ./update-addresses.sh popd > /dev/null