Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Install busola on k3d and run tests against it #3499

Merged
merged 7 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/scripts/deploy_busola.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

# This script install busola on k8s

# 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

trap print_k8s_resources EXIT

print_k8s_resources()
{
kubectl get all
kubectl get deployment -oyaml
}

ENV=${ENV?"env is not set"}
IMG_TAG=$1
IMG_DIR=${IMG_DIR:-"dev"}

kubectl delete configmap environment --ignore-not-found=true
kubectl create configmap environment --from-literal=ENVIRONMENT="${ENV}"
echo "### Deploying busola from: ${IMG_DIR}/${IMG_TAG}"

cd resources
(cd base && kustomize edit set image busola=europe-docker.pkg.dev/kyma-project/"${IMG_DIR}"/busola:"${IMG_TAG}")
kustomize build base/ | kubectl apply -f-

kubectl apply -f ingress/ingress.yaml

# wait for busola to be deployed
kubectl wait --for=condition=Available deployment/busola

# return ip address busola and save it to output
kubectl wait --for=jsonpath='{.status.loadBalancer.ingress}' ingress/busola
IP=$(kubectl get ingress busola -ojson | jq .status.loadBalancer.ingress[].ip | tr -d '/"')
echo "IP address: ${IP}"

if [[ -n "${GITHUB_OUTPUT:-}" ]]; then
echo "IP=${IP}" >> "${GITHUB_OUTPUT}"
echo "IP saved"
fi;
12 changes: 12 additions & 0 deletions .github/scripts/prepare_kubeconfig.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

# 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

k3d kubeconfig get kyma > tests/integration/fixtures/kubeconfig.yaml

#To access kubernetes cluster inside the same cluster change the api server address to url available inside the cluster.
yq --inplace '.clusters[].cluster.server = "https://kubernetes.default.svc:443"' tests/integration/fixtures/kubeconfig.yaml
2 changes: 1 addition & 1 deletion .github/workflows/pull-integration-cluster-k3d.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
shell: bash
run: |
.github/scripts/setup_local_busola.sh
- name: run_tests
- name: Run tests
shell: bash
run: |
k3d kubeconfig get k3dCluster > tests/integration/fixtures/kubeconfig.yaml
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/pull-kyma-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,20 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup Busola
- name: Deploy Busola
id: deploy_busola
shell: bash
run: |
.github/scripts/setup-busola.sh | tee busola-build.log
env:
ENV: dev
run: |
.github/scripts/deploy_busola.sh PR-${{ github.event.number }} | tee busola-deploy.log
- name: Prepare kubeconfig
run: |
.github/scripts/prepare_kubeconfig.sh
- name: Run tests
shell: bash
run: |
k3d kubeconfig get kyma > tests/integration/fixtures/kubeconfig.yaml
export CYPRESS_DOMAIN=http://localhost:3001

export CYPRESS_DOMAIN=http://${{ steps.deploy_busola.outputs.IP }}
cd tests/integration
npm ci && npm run "test:kyma-e2e"
- name: Uploads artifacts
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pull-smoke-test-stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 20
- name: setup_busola
- name: Setup Busola
shell: bash
run: |
./.github/scripts/setup-busola.sh | tee busola-build.log
env:
ENV: stage
- name: run_tests
- name: Run tests
shell: bash
run: |
k3d kubeconfig get kyma > tests/integration/fixtures/kubeconfig.yaml
Expand Down
1 change: 1 addition & 0 deletions backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ if (gzipEnabled)
);

if (process.env.NODE_ENV === 'development') {
console.log('Use development settings of cors');
app.use(cors({ origin: '*' }));
}

Expand Down
4 changes: 4 additions & 0 deletions resources/base/busola/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ spec:
memory: 21Mi
ports:
- containerPort: 3001
startupProbe:
httpGet:
port: 3001
path: /
volumes:
- name: config
configMap:
Expand Down
Loading