Skip to content

Commit

Permalink
github: Replace minikube with kind in CI
Browse files Browse the repository at this point in the history
Signed-off-by: Evangelos Skopelitis <eskopelitis@microsoft.com>
  • Loading branch information
skoeva committed Jun 26, 2024
1 parent 5539fec commit 4bdb6c4
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions .github/workflows/build-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ jobs:
with:
node-version: 20.x
- name: Start cluster
uses: nolar/setup-k3d-k3s@v1
uses: helm/kind-action@v1
with:
k3d-args: --wait --port 8080:80@loadbalancer --agents 2
cluster_name: test
# now you can run kubectl to see the pods in the cluster
- name: Try the cluster!
run: kubectl get pods -A
Expand Down Expand Up @@ -75,11 +75,11 @@ jobs:
DOCKER_IMAGE_VERSION=latest DOCKER_PLUGINS_IMAGE_NAME=headlamp-plugins-test make build-plugins-container
echo -n "verifying images:"
docker images
- name: Import images to k3d
- name: Import images to kind
run: |
export SHELL=/bin/bash
k3d image import ghcr.io/headlamp-k8s/headlamp-plugins-test:latest -c k3s-default
k3d image import ghcr.io/headlamp-k8s/headlamp:latest -c k3s-default
kind load docker-image ghcr.io/headlamp-k8s/headlamp-plugins-test:latest --name test
kind load docker-image ghcr.io/headlamp-k8s/headlamp:latest --name test
- name: Test .plugins folder
if: steps.cache-image-restore.outputs.cache-hit != 'true'
run: |
Expand Down Expand Up @@ -112,33 +112,38 @@ jobs:
run: kubectl apply -f e2e-tests/kubernetes-headlamp-ci.yaml
- name: Run e2e tests
run: |
echo "------------------sleeping 3...------------------"
echo "------------------------------------sleeping 3...------------------------------------"
sleep 6
kubectl get services --all-namespaces
kubectl get deployments -n kube-system
kubectl describe deployment headlamp -n kube-system
kubectl logs -l app=headlamp -n kube-system
echo "------------------waiting for headlamp deployment to be available...------------------"
echo "------------------Waiting for headlamp deployment to be available...------------------"
kubectl wait deployment -n kube-system headlamp --for condition=Available=True --timeout=30s
echo "------------------opening the service------------------"
echo "----------------------------------Opening the service----------------------------------"
IP_ADDRESS=$(kubectl get nodes -o=jsonpath='{.items[0].status.addresses[?(@.type=="InternalIP")].address}')
SERVICE_PORT=$(kubectl get services headlamp -n kube-system -o=jsonpath='{.spec.ports[0].nodePort}')
export SERVICE_URL="http://${IP_ADDRESS}:${SERVICE_PORT}"
echo $SERVICE_URL
curl -L $SERVICE_URL | grep -q "Headlamp: Kubernetes Web UI"
echo "------------------Getting HEADLAMP_TOKEN------------------"
echo "--------------------------------Getting HEADLAMP_TOKEN--------------------------------"
kubectl create serviceaccount headlamp-admin --namespace kube-system
kubectl create clusterrolebinding headlamp-admin --serviceaccount=kube-system:headlamp-admin --clusterrole=cluster-admin
export HEADLAMP_TOKEN=$(kubectl create token headlamp-admin --duration 24h -n kube-system)
echo "------------------Modifying certificate handling------------------"
export KUBECONFIG=$(k3d kubeconfig write k3s-default)
echo "---------------------------------Certificate handling---------------------------------"
export KUBECONFIG=$HOME/.kube/config
ca_data=$(yq e '.clusters[0].cluster."certificate-authority-data"' $KUBECONFIG | base64 --decode)
echo "$ca_data" > ca.crt
kubectl config set-cluster k3d-k3s-default --certificate-authority=$(pwd)/ca.crt
kubectl config unset clusters.k3d-k3s-default.certificate-authority-data
kubectl config set-cluster kind-test --certificate-authority=$(pwd)/ca.crt --server=https://${IP_ADDRESS}:${SERVICE_PORT}
kubectl config unset clusters.kind-test.certificate-authority-data
cc_data=$(yq e '.users[0].user."client-certificate-data"' $KUBECONFIG | base64 --decode)
echo "$cc_data" > client.crt
ck_data=$(yq e '.users[0].user."client-key-data"' $KUBECONFIG | base64 --decode)
echo "$ck_data" > client.key
kubectl config set-credentials admin@kind-test --client-certificate=$(pwd)/client.crt --client-key=$(pwd)/client.key
kubectl config unset users.admin@kind-test.client-certificate-data
kubectl config unset users.admin@kind-test.client-key-data
echo "Modified kubeconfig:"
cat $KUBECONFIG
echo "------------------Running playwright e2e tests------------------"
echo "-----------------------------Running playwright e2e tests-----------------------------"
cd e2e-tests
npm ci
npx playwright install --with-deps
Expand All @@ -150,11 +155,6 @@ jobs:
else
echo "Playwright tests passed successfully"
fi
- name: Check info on failure
if: failure()
run: |
kubectl cluster-info
kubectl get nodes -o wide
- name: Save Docker Images to Tar files in image-cache Folder
if: steps.cache-image-restore.outputs.cache-hit != 'true'
run: |
Expand Down

0 comments on commit 4bdb6c4

Please sign in to comment.