From 209fd5c5bd2e7a3b4be5fb8fe51ab363d7514466 Mon Sep 17 00:00:00 2001 From: marcobebway Date: Mon, 9 Sep 2024 08:37:33 +0200 Subject: [PATCH] Experimental --- .github/workflows/setup-test-cluster.yaml | 11 ++++--- scripts/shell/clean_up_cluster.sh | 40 ++++++++++++++++++++++- scripts/shell/deploy_kyma_modules.sh | 36 ++++++++++++++++++++ 3 files changed, 82 insertions(+), 5 deletions(-) create mode 100755 scripts/shell/deploy_kyma_modules.sh diff --git a/.github/workflows/setup-test-cluster.yaml b/.github/workflows/setup-test-cluster.yaml index 1284ba47..d86d183a 100644 --- a/.github/workflows/setup-test-cluster.yaml +++ b/.github/workflows/setup-test-cluster.yaml @@ -107,11 +107,14 @@ jobs: echo "Kyma is Ready" echo "::endgroup::" + - name: Deploy Kyma modules + run: | + echo "::group::Kyma - Deploy Kyma modules" + chmod +x ./scripts/shell/deploy_kyma_modules.sh + ./scripts/shell/deploy_kyma_modules.sh + echo "::endgroup::" + - name: Deploy all single-namespace test-cases run: | chmod +x ./scripts/shell/deploy_test_scenarios.sh ./scripts/shell/deploy_test_scenarios.sh - if [ $? -ne 0 ]; then - echo "Failed to deploy all single-namespace test-cases" - exit 1 - fi \ No newline at end of file diff --git a/scripts/shell/clean_up_cluster.sh b/scripts/shell/clean_up_cluster.sh index 1028e7eb..bd45e70e 100755 --- a/scripts/shell/clean_up_cluster.sh +++ b/scripts/shell/clean_up_cluster.sh @@ -11,6 +11,41 @@ set -o errexit # exit immediately when a command fails. set -E # needs to be set if we want the ERR trap set -o pipefail # prevents errors in a pipeline from being masked +delete_kyma_modules() { + echo "## Delete Subscriptions ##" + kubectl delete --timeout=120s --wait=false -A subscriptions.eventing.kyma-project.io --all || true + + echo "## Delete API Rules ##" + kubectl delete --timeout=120s --wait=false -A apirules.gateway.kyma-project.io --all || true + + echo "## Delete Functions ##" + kubectl delete --timeout=120s --wait=false -A functions.serverless.kyma-project.io --all || true + + echo "## Delete Eventing ##" + kubectl delete --timeout=120s --ignore-not-found -f https://github.com/kyma-project/eventing-manager/releases/latest/download/eventing-default-cr.yaml || true + kubectl delete --timeout=120s --wait=false --ignore-not-found -f https://github.com/kyma-project/eventing-manager/releases/latest/download/eventing-manager.yaml || true + + echo "## Delete NATS ##" + kubectl delete --timeout=120s --ignore-not-found -f https://github.com/kyma-project/nats-manager/releases/latest/download/nats-default-cr.yaml || true + kubectl delete --timeout=120s --wait=false --ignore-not-found -f https://github.com/kyma-project/nats-manager/releases/latest/download/nats-manager.yaml || true + + echo "## Delete Serverless ##" + kubectl delete --timeout=120s --ignore-not-found -f https://github.com/kyma-project/serverless-manager/releases/latest/download/default-serverless-cr.yaml -n kyma-system || true + kubectl delete --timeout=120s --wait=false --ignore-not-found -f https://github.com/kyma-project/serverless-manager/releases/latest/download/serverless-operator.yaml || true + + echo "## Delete API Gateway ##" + kubectl patch apigateways.operator.kyma-project.io default -p '{"metadata":{"finalizers":null}}' --type=merge || true + kubectl delete --timeout=120s --ignore-not-found -f https://github.com/kyma-project/api-gateway/releases/latest/download/apigateway-default-cr.yaml || true + kubectl delete --timeout=120s --wait=false --ignore-not-found -f https://github.com/kyma-project/api-gateway/releases/latest/download/api-gateway-manager.yaml || true + + echo "## Delete Istio ##" + kubectl patch istios.operator.kyma-project.io -n kyma-system default -p '{"metadata":{"finalizers":null}}' --type=merge || true + kubectl delete --timeout=120s --wait=false --ignore-not-found peerauthentications.security.istio.io --all -A --force=true || true + kubectl delete --timeout=120s --ignore-not-found -f https://github.com/kyma-project/istio/releases/latest/download/istio-default-cr.yaml || true + kubectl delete --timeout=120s --wait=false --ignore-not-found -f https://github.com/kyma-project/istio/releases/latest/download/istio-manager.yaml || true + kubectl label namespace kyma-system istio-injection- || true +} + # Define namespaces to exclude from deletion EXCLUDED_NAMESPACES=("default" "kube-system" "kube-public" "kube-node-lease") @@ -59,6 +94,9 @@ delete_custom_resource_definitions() { ## Main script starts here ## +echo "### Deleting Kyma modules. ###" +delete_kyma_modules + # Remove Custom Resource Definitions (CRDs) that contain 'kyma-project' echo "### Removing CRDs related to 'kyma-project'. ###" @@ -107,4 +145,4 @@ done echo "### Deleting all non-critical namespaces. ###" kubectl get namespaces --no-headers | awk -v excl="$EXCLUDED_REGEX" '$1 !~ excl {print $1}' | xargs -r kubectl delete namespace -echo "### Cleanup completed! ###" \ No newline at end of file +echo "### Cleanup completed! ###" diff --git a/scripts/shell/deploy_kyma_modules.sh b/scripts/shell/deploy_kyma_modules.sh new file mode 100755 index 00000000..be3c7576 --- /dev/null +++ b/scripts/shell/deploy_kyma_modules.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +############################################################################## +# NOTE: This script is used in the GitHub Actions workflow. +# Make sure any changes are compatible with the existing workflows. +############################################################################## + +# standard bash error handling +set -o nounset # treat unset variables as an error and exit immediately. +set -o errexit # exit immediately when a command fails. +set -E # needs to be set if we want the ERR trap +set -o pipefail # prevents errors in a pipeline from being masked + +#echo "### Create kyma-system namespace ###" +#kubectl create namespace kyma-system --dry-run=client -o yaml | kubectl apply -f - + +echo "### Deploy Istio ###" +kubectl label namespace kyma-system istio-injection=enabled --overwrite +kubectl apply -f https://github.com/kyma-project/istio/releases/latest/download/istio-manager.yaml +kubectl apply -f https://github.com/kyma-project/istio/releases/latest/download/istio-default-cr.yaml + +echo "### Deploy API Gateway ###" +kubectl apply -f https://github.com/kyma-project/api-gateway/releases/latest/download/api-gateway-manager.yaml +kubectl apply -f https://github.com/kyma-project/api-gateway/releases/latest/download/apigateway-default-cr.yaml + +echo "### Deploy Serverless ###" +kubectl apply -f https://github.com/kyma-project/serverless-manager/releases/latest/download/serverless-operator.yaml +kubectl apply -f https://github.com/kyma-project/serverless-manager/releases/latest/download/default-serverless-cr.yaml -n kyma-system + +echo "### Deploy NATS ###" +kubectl apply -f https://github.com/kyma-project/nats-manager/releases/latest/download/nats-manager.yaml +kubectl apply -f https://github.com/kyma-project/nats-manager/releases/latest/download/nats-default-cr.yaml + +echo "### Deploy Eventing ###" +kubectl apply -f https://github.com/kyma-project/eventing-manager/releases/latest/download/eventing-manager.yaml +kubectl apply -f https://github.com/kyma-project/eventing-manager/releases/latest/download/eventing-default-cr.yaml