Skip to content

Commit

Permalink
add cri-ci
Browse files Browse the repository at this point in the history
Signed-off-by: luomengY <[email protected]>
  • Loading branch information
luomengY committed Dec 15, 2023
1 parent e315d27 commit 1c54001
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 3 deletions.
87 changes: 86 additions & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ on:
env:
CONTAINER_RUN_OPTIONS: " "
GINKGO_VERSION: "v2.9.5"
CONTAINERD_VERSION: "1.1.7"
CRIO_VERSION: "1.28.2"

jobs:
lint:
Expand Down Expand Up @@ -226,7 +228,7 @@ jobs:
- run: |
export PROTOCOL=${{ matrix.cases.protocol }}
export KIND_IMAGE=kindest/node:${{ matrix.cases.version }}
export CONTAINER_RUNTIME="remote"
export CONTAINER_RUNTIME=${{ matrix.container-runtime }}
make e2e
- uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -349,3 +351,86 @@ jobs:
run: |
export DOCKER_BUILD_AND_SYSTEM_PRUNE="true"
make image
container_runtime_test:
runs-on: ubuntu-22.04
strategy:
matrix:
container-runtime: [ 'containerd', 'cri-o', 'docker' ]
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install and configure container runtime
run: |
if [ "${{ matrix.container-runtime }}" == "docker" ]; then
sudo apt-get update
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo \
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -y docker
git clone https://github.com/Mirantis/cri-dockerd.git
cd cri-dockerd
make cri-dockerd
sudo install -o root -g root -m 0755 cri-dockerd /usr/local/bin/cri-dockerd
sudo install packaging/systemd/* /etc/systemd/system
sudo sed -i -e 's,/usr/bin/cri-dockerd,/usr/local/bin/cri-dockerd,' /etc/systemd/system/cri-docker.service
sudo systemctl daemon-reload
sudo systemctl enable --now cri-docker.socket
sudo systemctl restart cri-docker
cd .. && rm -rf sudo cri-dockerd
elif [ "${{ matrix.container-runtime }}" == "cri-o" ]; then
sudo wget https://storage.googleapis.com/cri-o/artifacts/cri-o.amd64.v${{ env.CRIO_VERSION }}.tar.gz
sudo tar -zxvf cri-o.amd64.v${{ env.CRIO_VERSION }}.tar.gz
sudo ./cri-o/install
sudo systemctl daemon-reload
sudo systemctl enable --now crio
sudo systemctl restart crio
rm -rf cri-o.amd64.v${{ env.CRIO_VERSION }}.tar.gz
rm -rf cri-o
elif [ "${{ matrix.container-runtime }}" == "containerd" ]; then
sudo wget https://github.com/containerd/containerd/releases/download/v${{ env.CONTAINERD_VERSION }}/containerd-${{ env.CONTAINERD_VERSION }}-linux-amd64.tar.gz
sudo tar -zxvf containerd-${{ env.CONTAINERD_VERSION }}-linux-amd64.tar.gz -C /usr/local
# sudo cat << EOF > /usr/lib/systemd/system/containerd.service
# [Unit]
# Description=containerd container runtime
# Documentation=https://containerd.io
# After=network.target local-fs.target
#
# [Service]
# ExecStartPre=-/sbin/modprobe overlay
# ExecStart=/usr/bin/containerd
#
# Type=notify
# Delegate=yes
# KillMode=process
# Restart=always
# RestartSec=5
# # Having non-zero Limit*s causes performance problems due to accounting overhead
# # in the kernel. We recommend using cgroups to do container-local accounting.
# LimitNPROC=infinity
# LimitCORE=infinity
# LimitNOFILE=infinity
# # Comment TasksMax if your systemd version does not supports it.
# # Only systemd 226 and above support this version.
# TasksMax=infinity
# OOMScoreAdjust=-999
# [Install]
# WantedBy=multi-user.target
# EOF
sudo chmod +x /usr/lib/systemd/system/containerd.service && systemctl daemon-reload
containerd config default | sudo tee /etc/containerd/config.toml && sudo systemctl restart containerd.service
fi
- name: Run tests
run: make test
env:
CONTAINER_RUNTIME: ${{ matrix.container-runtime }}
17 changes: 17 additions & 0 deletions hack/lib/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,23 @@ verify_docker_installed() {
}
}

verify_cridockerd_installed() {
# verify the cri-dockerd installed
command -v cri-dockerd >/dev/null || {
echo "must install the cri-dockerd first"
exit 1
}
}

verify_crio_installed() {
# verify the cri-o installed
command -v crio > /dev/null || {
echo "must install the cri-o first"
exit 1
}
}


# install CNI plugins
function install_cni_plugins() {
CNI_DOWNLOAD_ADDR=${CNI_DOWNLOAD_ADDR:-"https://github.com/containernetworking/plugins/releases/download/v1.1.1/cni-plugins-linux-amd64-v1.1.1.tgz"}
Expand Down
23 changes: 21 additions & 2 deletions hack/local-up-kubeedge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ function check_prerequisites {
if [[ "${CONTAINER_RUNTIME}" = "docker" ]]; then
# if we will use docker as edgecore container runtime, we need to verify whether docker already installed
verify_docker_installed
verify_cridockerd_installed
elif [[ "${CONTAINER_RUNTIME}" = "cri-o" ]]; then
# function to verify if cri-o is installed
verify_crio_installed
elif [[ "${CONTAINER_RUNTIME}" = "containerd" ]]; then
# function to verify if containerd is installed
verify_containerd_installed
elif [[ "${CONTAINER_RUNTIME}" = "remote" ]]; then
# we will use containerd as cri runtime, so need to verify whether containerd already installed
verify_containerd_installed
Expand Down Expand Up @@ -168,8 +175,20 @@ function start_edgecore {
# we need to change edgecore container runtime from default containerd to docker
if [[ "${CONTAINER_RUNTIME}" = "docker" ]]; then
sed -i 's|containerRuntime: .*|containerRuntime: docker|' ${EDGE_CONFIGFILE}
sed -i 's|remoteImageEndpoint: .*|remoteImageEndpoint: unix:///var/run/dockershim.sock|' ${EDGE_CONFIGFILE}
sed -i 's|remoteRuntimeEndpoint: .*|remoteRuntimeEndpoint: unix:///var/run/dockershim.sock|' ${EDGE_CONFIGFILE}
sed -i 's|remoteImageEndpoint: .*|remoteImageEndpoint: unix:///var/run/cri-dockerd.sock|' ${EDGE_CONFIGFILE}
sed -i 's|remoteRuntimeEndpoint: .*|remoteRuntimeEndpoint: unix:///var/run/cri-dockerd.sock|' ${EDGE_CONFIGFILE}
fi

if [[ "${CONTAINER_RUNTIME}" = "cri-o" ]]; then
sed -i 's|containerRuntime: .*|containerRuntime: cri-o|' ${EDGE_CONFIGFILE}
sed -i 's|remoteImageEndpoint: .*|remoteImageEndpoint: unix:///var/run/crio/crio.sock|' ${EDGE_CONFIGFILE}
sed -i 's|remoteRuntimeEndpoint: .*|remoteRuntimeEndpoint: unix:///var/run/crio/crio.sock|' ${EDGE_CONFIGFILE}
fi

if [[ "${CONTAINER_RUNTIME}" = "containerd" ]]; then
sed -i 's|containerRuntime: .*|containerRuntime: containerd|' ${EDGE_CONFIGFILE}
sed -i 's|remoteImageEndpoint: .*|remoteImageEndpoint: unix:///run/containerd/containerd.sock|' ${EDGE_CONFIGFILE}
sed -i 's|remoteRuntimeEndpoint: .*|remoteRuntimeEndpoint: unix:///run/containerd/containerd.sock|' ${EDGE_CONFIGFILE}
fi

token=`kubectl get secret -nkubeedge tokensecret -o=jsonpath='{.data.tokendata}' | base64 -d`
Expand Down

0 comments on commit 1c54001

Please sign in to comment.