Skip to content

Setup Gardener Test Cluster #52

Setup Gardener Test Cluster

Setup Gardener Test Cluster #52

name: "Setup Gardener Test Cluster"
on: workflow_dispatch
env:
KYMA_VERSION: "2.20.5" # Required Kyma version.
jobs:
setup-gardener-cluster:
name: Setup Gardener cluster
# Sets up the Gardener cluster with the namespace-scoped test cases for the companion blackbox test
# The steps of the job are:
# 1. Authenticate and connect with the previously created Gardener cluster
# 2. Clean up any existing resources in the Gardener cluster
# 3. Deploy Kyma on the Gardener cluster
# 4. Iteratively deploy the namespace-scoped test cases using the prepared shell script for the companion blackbox test
outputs:
KUBECONFIG: ${{ steps.create-kubeconfig.outputs.KUBECONFIG }}
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Connect to Gardener cluster - setup kubeconfig
env:
GARDENER_KYMATUNAS: ${{ secrets.GARDENER_KYMATUNAS }}
run: |
# setup Gardener kubeconfig.
mkdir -p "${HOME}/.gardener"
export GARDENER_KUBECONFIG="${HOME}/.gardener/kubeconfig"
echo ${GARDENER_KYMATUNAS} | base64 --decode > ${GARDENER_KUBECONFIG}
echo "GARDENER_KUBECONFIG=${GARDENER_KUBECONFIG}" >> $GITHUB_ENV
- name: Export Github env
run: |
# set cluster name and export it to Github env to access it later
export CLUSTER_NAME="comp-tests-0"
echo "CLUSTER_NAME=${CLUSTER_NAME}" >> $GITHUB_ENV
- name: Create kubeconfig request
env:
GARDENER_PROJECT_NAME: ${{ vars.GARDENER_PROJECT_NAME }}
run: |
# create kubeconfig request, that creates a Kubeconfig, which is valid for one day
kubectl create --kubeconfig="${GARDENER_KUBECONFIG}" \
-f <(printf '{"spec":{"expirationSeconds":86400}}') \
--raw /apis/core.gardener.cloud/v1beta1/namespaces/garden-${GARDENER_PROJECT_NAME}/shoots/${CLUSTER_NAME}/adminkubeconfig | \
jq -r ".status.kubeconfig" | \
base64 -d > ${CLUSTER_NAME}_kubeconfig.yaml
# merge with the existing kubeconfig settings
mkdir -p ~/.kube
KUBECONFIG="~/.kube/config:${CLUSTER_NAME}_kubeconfig.yaml" kubectl config view --flatten --merge > merged_kubeconfig.yaml
mv merged_kubeconfig.yaml ~/.kube/config
- name: Display cluster information
run: |
# display cluster information.
kubectl version
kubectl cluster-info
kubectl get nodes
kubectl get ns
- name: Cleanup existing resources
run: |
./scripts/shell/clean_up_cluster.sh
- name: Install Kyma CLI
id: install-kyma-cli
run: |
mkdir -p bin
curl -L "https://github.com/kyma-project/cli/releases/download/${KYMA_VERSION}/kyma_$(uname -s)_$(uname -m).tar.gz" | tar -zxvf - -C bin kyma && mv bin/kyma bin/kyma@v2
echo "::set-output name=version::$(bin/kyma@v2 version)"
continue-on-error: true
- name: Check Kyma CLI version
run: |
kyma_cli_version=$(echo "${{ steps.install-kyma-cli.outputs.version }}" | cut -d ":" -f 2 | xargs)
if [ "$kyma_cli_version" != "${KYMA_VERSION}" ]; then
echo "Kyma CLI version is not correct. Expected: ${KYMA_VERSION}, got: $kyma_cli_version"
exit 1
fi
echo "Kyma CLI version is correct: $kyma_cli_version"
- name: Install Kubernetes CLI
run: |
curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x ./kubectl
./kubectl version --client
- name: Deploy Kyma
run: |
echo "::group::Kyma - Deploy"
bin/kyma@v2 alpha deploy --ci --non-interactive
echo "::endgroup::"
- name: Verify Kyma deployment
run: |
echo "::group::Kyma - Verify Kyma deployment"
kyma_status=$(./kubectl get kyma -A -ojson | jq -r '[(.items[].status.state)] | .[0]')
echo "::debug::Kyma status: $kyma_status"
if [ "$kyma_status" != "Ready" ]; then
echo "Kyma is not Ready. Expected: Ready, got: $kyma_status"
exit 1
fi
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