From f429b79a05b4d1a8d853baf50ab8b77074a2d727 Mon Sep 17 00:00:00 2001 From: Muhammad Faizan Date: Mon, 15 Jan 2024 10:18:11 +0100 Subject: [PATCH] updated --- .github/workflows/e2e.yml | 21 +++++++++---------- scripts/gardener/aws/deprovision.sh | 15 +++++++++++--- scripts/gardener/aws/provision.sh | 32 ++++++++++++++++++++++++++--- 3 files changed, 51 insertions(+), 17 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index c845a70d..619f7b29 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -168,30 +168,29 @@ jobs: - name: Provision Gardener cluster env: - CLUSTER_NAME: "fzn-g2" + CLUSTER_PREFIX: "ghem-" GARDENER_PROVIDER_SECRET_NAME: "tunas-aws" GARDENER_REGION: "eu-west-1" GARDENER_ZONES: "eu-west-1a" GARDENER_PROJECT_NAME: "kymatunas" GARDENER_CLUSTER_VERSION: "1.26.9" run: | + echo "CLUSTER_NAME=${CLUSTER_PREFIX}$(openssl rand -hex 2)" >> $GITHUB_ENV export GARDENER_KUBECONFIG="${HOME}/.gardener/kubeconfig" - echo ${TEST_ENV_STEP1} - make -C hack/ci/ provision-gardener-cluster - kubectl version - kubectl cluster-info - kubectl get nodes - kubectl get ns - 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 ${CLUSTER_NAME} +# make -C hack/ci/ provision-gardener-cluster +# kubectl version +# kubectl cluster-info +# kubectl get nodes +# kubectl get ns - name: Delete Gardener cluster if: ${{ always() }} env: - CLUSTER_NAME: "fzn-g2" GARDENER_PROVIDER_SECRET_NAME: "tunas-aws" GARDENER_PROJECT_NAME: "kymatunas" WAIT_FOR_DELETE_COMPLETION: "false" run: | export GARDENER_KUBECONFIG="${HOME}/.gardener/kubeconfig" - make -C hack/ci/ deprovision-gardener-cluster + echo ${CLUSTER_NAME} +# make -C hack/ci/ deprovision-gardener-cluster diff --git a/scripts/gardener/aws/deprovision.sh b/scripts/gardener/aws/deprovision.sh index 475ba170..4a94f5b3 100755 --- a/scripts/gardener/aws/deprovision.sh +++ b/scripts/gardener/aws/deprovision.sh @@ -1,5 +1,11 @@ #!/usr/bin/env bash +#Usage: To run this script, set the following environment variables and run this script. +# CLUSTER_NAME +# GARDENER_PROJECT_NAME +# GARDENER_KUBECONFIG - Path to kubeconfig for Gardener. +# WAIT_FOR_DELETE_COMPLETION - "true" | "false" + #Permissions: In order to run this script you need to use a service account with permissions equivalent to the following GCP roles: # - Compute Admin # - Service Account User @@ -12,12 +18,16 @@ source "${PROJECT_ROOT}/scripts/utils/utils.sh" gardener::validate_and_default() { requiredVars=( + CLUSTER_NAME GARDENER_KUBECONFIG GARDENER_PROJECT_NAME - CLUSTER_NAME - WAIT_FOR_DELETE_COMPLETION # "true" | "false" ) utils::check_required_vars "${requiredVars[@]}" + + # set default values + if [ -z "$WAIT_FOR_DELETE_COMPLETION" ]; then + export WAIT_FOR_DELETE_COMPLETION="false" + fi } # gardener::deprovision_cluster removes a Gardener cluster @@ -38,7 +48,6 @@ function gardener::deprovision_cluster() { -n "${namespace}" } - ## MAIN Logic gardener::validate_and_default diff --git a/scripts/gardener/aws/provision.sh b/scripts/gardener/aws/provision.sh index 577781e7..82987744 100755 --- a/scripts/gardener/aws/provision.sh +++ b/scripts/gardener/aws/provision.sh @@ -1,5 +1,18 @@ #!/usr/bin/env bash +#Usage: To run this script, set the following environment variables and run this script. +# CLUSTER_NAME +# GARDENER_REGION +# GARDENER_ZONES +# GARDENER_PROJECT_NAME +# GARDENER_PROVIDER_SECRET_NAME +# GARDENER_CLUSTER_VERSION +# GARDENER_KUBECONFIG - Path to kubeconfig for Gardener. +# MACHINE_TYPE - default: "m5.xlarge" +# SCALER_MIN - default: 1 +# SCALER_MAX - default: 2 +# RETRY_ATTEMPTS - default: 1 + #Permissions: In order to run this script you need to use a service account with permissions equivalent to the following GCP roles: # - Compute Admin # - Service Account User @@ -12,6 +25,7 @@ source "${PROJECT_ROOT}/scripts/utils/utils.sh" gardener::validate_and_default() { requiredVars=( + CLUSTER_NAME GARDENER_REGION GARDENER_ZONES GARDENER_KUBECONFIG @@ -25,6 +39,18 @@ gardener::validate_and_default() { if [ -z "$MACHINE_TYPE" ]; then export MACHINE_TYPE="m5.xlarge" fi + + if [ -z "$SCALER_MIN" ]; then + export SCALER_MIN=1 + fi + + if [ -z "$SCALER_MAX" ]; then + export SCALER_MAX=2 + fi + + if [ -z "$RETRY_ATTEMPTS" ]; then + export RETRY_ATTEMPTS=1 + fi } gardener::provision_cluster() { @@ -43,10 +69,10 @@ gardener::provision_cluster() { --region "${GARDENER_REGION}" \ --zones "${GARDENER_ZONES}" \ --type "${MACHINE_TYPE}" \ - --scaler-max 4 \ - --scaler-min 2 \ + --scaler-max ${SCALER_MIN} \ + --scaler-min ${SCALER_MAX} \ --kube-version="${GARDENER_CLUSTER_VERSION}" \ - --attempts 1 \ + --attempts ${RETRY_ATTEMPTS} \ --verbose \ --hibernation-start "" }