Fix github actions #21
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2024 Google LLC | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# https://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
name: e2e | |
on: | |
push: | |
branches: | |
- 'main' | |
tags: | |
- 'v*' | |
pull_request: | |
branches: [ main ] | |
workflow_dispatch: | |
env: | |
GO_VERSION: "1.23" | |
K8S_VERSION: "v1.31.2" | |
KIND_VERSION: "v0.25.0" | |
IMAGE_NAME: ghcr.io/google/dranet | |
KIND_CLUSTER_NAME: kind | |
permissions: write-all | |
jobs: | |
build: | |
name: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
id: go | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: Build | |
run: | | |
docker build -t ghcr.io/google/dranet:test -f Dockerfile . | |
mkdir _output | |
docker save ghcr.io/google/dranet:test > _output/dranet-image.tar | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: test-image | |
path: _output/dranet-image.tar | |
e2e: | |
name: e2e | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 100 | |
needs: | |
- build | |
strategy: | |
fail-fast: false | |
matrix: | |
ipFamily: ["ipv4", "ipv6"] | |
env: | |
JOB_NAME: "dranet-${{ matrix.ipFamily }}-${{ matrix.proxyMode }}" | |
IP_FAMILY: ${{ matrix.ipFamily }} | |
KUBEPROXY_MODE: ${{ matrix.proxyMode }} | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: Enable ipv4 and ipv6 forwarding | |
run: | | |
sudo sysctl -w net.ipv6.conf.all.forwarding=1 | |
sudo sysctl -w net.ipv4.ip_forward=1 | |
- name: Set up environment (download dependencies) | |
run: | | |
TMP_DIR=$(mktemp -d) | |
# Test binaries | |
curl -L https://dl.k8s.io/${{ env.K8S_VERSION }}/kubernetes-test-linux-amd64.tar.gz -o ${TMP_DIR}/kubernetes-test-linux-amd64.tar.gz | |
tar xvzf ${TMP_DIR}/kubernetes-test-linux-amd64.tar.gz \ | |
--directory ${TMP_DIR} \ | |
--strip-components=3 kubernetes/test/bin/ginkgo kubernetes/test/bin/e2e.test | |
# kubectl | |
curl -L https://dl.k8s.io/${{ env.K8S_VERSION }}/bin/linux/amd64/kubectl -o ${TMP_DIR}/kubectl | |
# kind | |
curl -Lo ${TMP_DIR}/kind https://kind.sigs.k8s.io/dl/${{ env.KIND_VERSION }}/kind-linux-amd64 | |
# Install | |
sudo cp ${TMP_DIR}/ginkgo /usr/local/bin/ginkgo | |
sudo cp ${TMP_DIR}/e2e.test /usr/local/bin/e2e.test | |
sudo cp ${TMP_DIR}/kubectl /usr/local/bin/kubectl | |
sudo cp ${TMP_DIR}/kind /usr/local/bin/kind | |
sudo chmod +x /usr/local/bin/* | |
# Clean | |
sudo rm -rf ${TMP_DIR} | |
- name: Create multi node cluster | |
run: | | |
# output_dir | |
mkdir -p _artifacts | |
# create cluster | |
kind create cluster --name ${{ env.KIND_CLUSTER_NAME}} --image kindest/node:${{ env.K8S_VERSION }} --config kind.yaml | |
# dump the kubeconfig for later | |
/usr/local/bin/kind get kubeconfig --name ${{ env.KIND_CLUSTER_NAME}} > _artifacts/kubeconfig.conf | |
- uses: actions/download-artifact@v4 | |
with: | |
name: test-image | |
- name: Install dranet | |
run: | | |
# preload dranet image | |
docker load --input dranet-image.tar | |
/usr/local/bin/kind load docker-image ghcr.io/google/dranet:test --name ${{ env.KIND_CLUSTER_NAME}} | |
sed -i s#ghcr.io/google/dranet.*#ghcr.io/google/dranet:test# install.yaml | |
/usr/local/bin/kubectl apply -f ./install.yaml | |
- name: Get Cluster status | |
run: | | |
# wait network is ready | |
sleep 5 | |
/usr/local/bin/kubectl get nodes -o wide | |
/usr/local/bin/kubectl get pods -A | |
/usr/local/bin/kubectl wait --timeout=1m --for=condition=ready pods --namespace=kube-system -l k8s-app=kube-dns | |
/usr/local/bin/kubectl wait --timeout=1m --for=condition=ready pods --namespace=kube-system -l app=dranet | |
- name: Run smoke test | |
run: | | |
cat examples/add_dummy_iface.sh | docker exec -i kind-worker bash | |
/usr/local/bin/kubectl apply -f examples/deviceclass.yaml | |
/usr/local/bin/kubectl apply -f examples/resourceclaim.yaml | |
/usr/local/bin/kubectl wait --timeout=2m --for=condition=ready pods -l app=pod | |
/usr/local/bin/kubectl exec -it pod1 -- ip link show dummy0 | |
- name: Upload Junit Reports | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: kind-junit-${{ env.JOB_NAME }}-${{ github.run_id }} | |
path: './_artifacts/*.xml' | |
- name: Export logs | |
if: always() | |
run: | | |
/usr/local/bin/kind export logs --name ${KIND_CLUSTER_NAME} --loglevel=debug ./_artifacts/logs | |
- name: Upload logs | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: kind-logs-${{ env.JOB_NAME }}-${{ github.run_id }} | |
path: ./_artifacts/logs |