From b82d61cfef1ea486d11eed15558a42cb1e51a7db Mon Sep 17 00:00:00 2001 From: Shiming Zhang Date: Mon, 26 Dec 2022 16:21:26 +0800 Subject: [PATCH] Add test --- .github/workflows/test.yaml | 82 +++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..24bf3d7 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,82 @@ +name: Test + +on: + push: + branches: + - main + pull_request: + branches: + - main + + workflow_dispatch: + +jobs: + test: + # https://docs.github.com/en/actions/using-jobs/using-concurrency + concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}-${{ matrix.kube-version }} + cancel-in-progress: true + + # https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs + strategy: + fail-fast: false + matrix: + kube-release: + - 1.23 + + continue-on-error: false + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Install conntrack + run: | + sudo apt update + sudo apt install -y conntrack + + # Install Kubernetes use apt source with specified version + - name: Install Kubernetes + run: | + sudo snap install kubelet --channel=${{ matrix.kube-release }}/stable --classic + sudo snap install kubectl --channel=${{ matrix.kube-release }}/stable --classic + sudo snap install kubeadm --channel=${{ matrix.kube-release }}/stable --classic + wget -O crictl-linux-amd64.tar.gz https://github.com/kubernetes-sigs/cri-tools/releases/download/v${{ matrix.kube-release }}.0/crictl-v${{ matrix.kube-release }}.0-linux-amd64.tar.gz && \ + sudo tar zxvf crictl-linux-amd64.tar.gz -C /usr/local/bin && \ + rm -f crictl-linux-amd64.tar.gz + + - name: Swap off + run: | + sudo swapoff -a + sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab + + - name: Start Kubelet + run: | + sudo wget -O /etc/systemd/system/kubelet.service https://github.com/kubernetes/release/raw/master/cmd/kubepkg/templates/latest/deb/kubelet/lib/systemd/system/kubelet.service + sudo mkdir /etc/systemd/system/kubelet.service.d/ + sudo wget -O /etc/systemd/system/kubelet.service.d/10-kubeadm.conf https://github.com/kubernetes/release/raw/master/cmd/kubepkg/templates/latest/deb/kubeadm/10-kubeadm.conf + sudo echo 'KUBELET_KUBEADM_ARGS=""' > /var/lib/kubelet/kubeadm-flags.env + sudo systemctl daemon-reload + sudo systemctl restart kubelet + sudo journalctl -u kubelet + sudo systemctl status kubelet + + - name: Initialize Kubernetes + run: | + sudo kubeadm init || { + journalctl -xeu kubelet + exit 1 + } + + - name: Setup kubeconfig + run: | + mkdir -p $HOME/.kube + sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config + sudo chown $(id -u):$(id -g) $HOME/.kube/config + + - name: Get pods + run: | + kubectl get pods -o wide --all-namespaces + + - name: Get nodes + run: | + kubectl get nodes -o wide