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

[WIP] Add e2e ci for kubernetes with kind. #403

Closed
wants to merge 14 commits into from
17 changes: 17 additions & 0 deletions .github/scripts/kind.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail


wget -q https://github.com/kubernetes-sigs/kind/releases/download/v0.22.0/kind-linux-amd64
chmod +x kind-linux-amd64 && mv kind-linux-amd64 /usr/local/bin/kind

K8SVERSION=${K8SVERSION:-"v1.25.3"}
WORKSPACE=$PWD

sed -i 's/K8SVERSION/'$K8SVERSION'/g' $WORKSPACE/.github/scripts/kind.yaml
sed -i 's#WORKSPACE#'$WORKSPACE'#g' $WORKSPACE/.github/scripts/kind.yaml
kind create cluster --config $WORKSPACE/.github/scripts/kind.yaml
kubectl wait node --all --for condition=ready
17 changes: 17 additions & 0 deletions .github/scripts/kind.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
image: kindest/node:K8SVERSION
extraMounts:
- hostPath: /xline/kind
containerPath: /var/log
- hostPath: WORKSPACE/.github/scripts/xline.yaml
containerPath: /etc/kubernetes/manifests/xline.yaml
kubeadmConfigPatches:
- |
kind: ClusterConfiguration
etcd:
external:
endpoints:
- http://172.18.0.2:2379
20 changes: 20 additions & 0 deletions .github/scripts/xline.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
name: xline
namespace: kube-system
spec:
containers:
- name: xline
image: ghcr.io/liangyuanpeng/xline:ffa824f
imagePullPolicy: IfNotPresent
env:
- name: RUST_LOG
value: debug
command:
- /bin/sh
- -c
- xline --name node1 --members node1=172.18.0.2:2379 --data-dir /tmp/xline --storage-engine rocksdb --client-listen-urls=http://172.18.0.2:2379 --peer-listen-urls=http://172.18.0.2:2380,http://172.18.0.2:2381 --client-advertise-urls=http://172.18.0.2:2379 --peer-advertise-urls=http://172.18.0.2:2380,http://172.18.0.2:2381
hostNetwork: true
status: {}
46 changes: 46 additions & 0 deletions .github/workflows/kube.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: e2e

on:
# schedule:
# - cron: "00 * * * *" # run ci periodically at 3 am
pull_request:
push: #enabled after the API is stable
# workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.actor }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
kube:
name: e2e_kube
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
k8s:
- v1.25.3
- v1.26.0
- v1.27.3
- v1.28.7
- v1.29.2
steps:
- uses: actions/checkout@v4
- name: work with kubernetes
env:
K8SVERSION: ${{ matrix.k8s }}
run: |
./.github/scripts/kind.sh
- name: chmod
if: always()
run: |
sudo chmod -R 777 /xline/kind
ls /xline/kind
ls /xline/kind/pods
du -h --max-depth=1 /xline/kind
ls -allh /xline/kind/containers
- name: upload kind logs
if: always()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think uploading detailed logs when deployment failed is a better choice.

uses: actions/upload-artifact@v3
with:
name: xline_kind_log_${{ matrix.k8s }}
path: /xline/kind/
Loading