Skip to content

netpod container image #77

netpod container image

netpod container image #77

Workflow file for this run

# SPDX-License-Identifier: MIT
# Copyright (c) 2021 The Authors.
# Authors: Phu Tran <@phudtran>
name: mizar-ci
on:
push:
branches:
- dev-next
- 'CentaurusInfra/mizar'
pull_request:
branches:
- dev-next
- 'CentaurusInfra/mizar'
workflow_dispatch:
jobs:
build:
runs-on: [self-hosted, mizar-ci]
strategy:
matrix:
python-version: ['3.8.0']
steps:
- name: Permissions
run: sudo chown -R $USER:$USER /home/
- uses: actions/checkout@v2
- name: Update apt-get
run: sudo apt-get update
- name: Install packages
# Remove docker.io if running on github actions hosted.
run: sudo apt-get install -y build-essential clang-7 llvm-7 libelf-dev python3.8 python3-pip libcmocka-dev lcov python3.8-dev python3-apt pkg-config docker.io
- name: Python3.6
run: sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1
- name: Python3.8
run: sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 2
- name: Python3.8 default
run: sudo update-alternatives --set python3 /usr/bin/python3.8
- name: Python3.8 symlink fix
run: sudo ln -snf /usr/lib/python3/dist-packages/apt_pkg.cpython-36m-x86_64-linux-gnu.so /usr/lib/python3/dist-packages/apt_pkg.so
- name: Update pip
run: python3 -m pip install --upgrade pip
- name: Install python packages
run: sudo pip3 install setuptools netaddr docker grpcio grpcio-tools kubernetes
# TODO: Update mizar to work with latest k8s version (and consequently latest kind versions)
#- name: install kind
# run: |
# ver=$(curl -s https://api.github.com/repos/kubernetes-sigs/kind/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')
# curl -Lo kind "https://github.com/kubernetes-sigs/kind/releases/download/$ver/kind-$(uname)-amd64"
# chmod +x ./kind
# sudo mv ./kind /usr/local/bin
- name: install kind v0.11.0
run: |
curl -Lo kind "https://github.com/kubernetes-sigs/kind/releases/download/v0.11.0/kind-$(uname)-amd64"
chmod +x ./kind
sudo mv ./kind /usr/local/bin
- name: Install kubectl
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
sudo mv ./kubectl /usr/local/bin/kubectl
git submodule update --init --recursive
# - name: Update Kernel and Linux Headers
# run: printf 'y\nn\n' | sudo ./kernelupdate.sh
- name: Compile mizar
run: sudo make clean && make
- name: Make unittest
run: sudo make unittest
- name: Run cli unit tests
run: ./build/tests/test_cli
- name: Run daemon unit tests
run: ./build/tests/test_dmn
- name: Run go unit tests
run: |
sudo /usr/local/go/bin/go test ./...
- name: Create kind cluster
run: sudo ./kind-setup.sh dev 2
- name: Kubeconfig chown
if: always()
run: |
mkdir -p ${HOME}/.kube
sudo chown $(id -u):$(id -g) $HOME/.kube/config
sudo chown -R $(id -u):$(id -g) $HOME/.kube/
- name: Cluster deployment failure, Dump Operator and daemon Logs
if: ${{ failure() }}
run: sudo kubectl get pods | grep mizar-operator | awk '{print $1}' | xargs -i kubectl logs {} && kubectl get pods | grep mizar-daemon | awk '{print $1}' | xargs -i kubectl logs {}
# - name: Setup tmate ssh session
# if: always()
# uses: mxschmitt/action-tmate@v3
# timeout-minutes: 15
- name: Run kind e2e test
run: sudo make e2efunctest
- name: Test failure, Dump Operator and daemon Logs
if: ${{ failure() }}
run: sudo kubectl get pods | grep mizar-operator | awk '{print $1}' | xargs -i kubectl logs {} && kubectl get pods | grep mizar-daemon | awk '{print $1}' | xargs -i kubectl logs {}
# - name: Setup tmate ssh session
# if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3
# timeout-minutes: 15
- name: Cleanup Kind
if: ${{ always() }}
run: sudo kind delete cluster
# Kubeadm tests
- name: Start kubeadm
run: sudo kubeadm init --pod-network-cidr 20.0.0.0/16
- name: kubeconfig
run: |
mkdir -p $HOME/.kube
yes | sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
- name: Join workers
run: |
ssh ciw1 "sudo $(sudo kubeadm token create --print-join-command)"
ssh ciw2 "sudo $(sudo kubeadm token create --print-join-command)"
- name: build container images
run: |
sudo docker build -t mizar:ci -f etc/docker/mizar.Dockerfile .
sudo docker build -t dropletd:ci -f etc/docker/daemon.Dockerfile .
sudo docker build -t endpointopr:ci -f etc/docker/operator.Dockerfile .
sudo docker save mizar:ci -o build/bin/mizar.tar
sudo docker save dropletd:ci -o build/bin/dropletd.tar
sudo docker save endpointopr:ci -o build/bin/endpointopr.tar
sudo chmod +r build/bin/mizar.tar
sudo chmod +r build/bin/dropletd.tar
sudo chmod +r build/bin/endpointopr.tar
ssh ciw1 "sudo rm -rf ~/mizar"
ssh ciw2 "sudo rm -rf ~/mizar"
scp -r ~/actions-runner/_work/mizar/mizar ciw1:
scp -r ~/actions-runner/_work/mizar/mizar ciw2:
ssh ciw1 "sudo docker load -i ~/mizar/build/bin/mizar.tar"
ssh ciw1 "sudo docker load -i ~/mizar/build/bin/dropletd.tar"
ssh ciw1 "sudo docker load -i ~/mizar/build/bin/endpointopr.tar"
ssh ciw2 "sudo docker load -i ~/mizar/build/bin/mizar.tar"
ssh ciw2 "sudo docker load -i ~/mizar/build/bin/dropletd.tar"
ssh ciw2 "sudo docker load -i ~/mizar/build/bin/endpointopr.tar"
- name: deploy mizar
run: kubectl create -f etc/deploy/deploy.mizar.ci.yaml
- name: check ready
run: source install/common.sh && check_all_ready
- name: run tests
run: sudo make e2efunctest
- name: Test failure, Dump Operator and daemon Logs
if: ${{ failure() }}
run: sudo kubectl get pods | grep mizar-operator | awk '{print $1}' | xargs -i kubectl logs {} && kubectl get pods | grep mizar-daemon | awk '{print $1}' | xargs -i kubectl logs {}
# Always pass cleanup stage
- name: cleanup kubeadm
if: ${{ always() }}
continue-on-error: true
run: |
yes | sudo kubeadm reset
ssh ciw1 "yes | sudo kubeadm reset"
ssh ciw2 "yes | sudo kubeadm reset"
- name: cleanup interfaces
if: ${{ always() }}
continue-on-error: true
run: |
sudo ip l delete $(ip l | grep -Po "(br-\w+)(?=:)")
for name in $(ip l | grep -Po '(veth-\w+)(?=@)'); do sudo ip l delete $name; done
ssh ciw1 "ip l | grep -Po '(veth-\w+)(?=@)' | awk '{print $1}' | xargs -i sudo ip l delete {}"
ssh ciw2 "ip l | grep -Po '(veth-\w+)(?=@)' | awk '{print $1}' | xargs -i sudo ip l delete {}"
- name: cleanup net namespaces
if: ${{ always() }}
continue-on-error: true
run: |
sudo ip -all netns delete
ssh ciw1 "sudo ip -all netns delete"
ssh ciw2 "sudo ip -all netns delete"
- name: cleanup docker containers and images
if: ${{ always() }}
continue-on-error: true
run: |
sudo docker stop $(docker ps -aq) && docker system prune -f
sudo docker rmi -f $(docker images -a -q)
sudo docker volume rm $(docker volume ls -qf dangling=true)
ssh ciw1 "sudo docker stop $(docker ps -aq) && docker system prune -f"
ssh ciw1 "sudo docker rmi -f $(docker images -a -q)"
ssh ciw1 "sudo docker volume rm $(docker volume ls -qf dangling=true)"
ssh ciw2 "sudo docker stop $(docker ps -aq) && docker system prune -f"
ssh ciw2 "sudo docker rmi -f $(docker images -a -q)"
ssh ciw2 "sudo docker volume rm $(docker volume ls -qf dangling=true)"