Skip to content

Commit

Permalink
Update test
Browse files Browse the repository at this point in the history
  • Loading branch information
wzshiming committed Dec 26, 2022
1 parent b093039 commit 0f5675d
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 70 deletions.
51 changes: 12 additions & 39 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,52 +29,25 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Install conntrack
run: |
sudo apt update
sudo apt install -y conntrack
- name: Set up minikube
uses: sagikazarmark/setup-minikube-action@v0

# 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: Launch minikube cluster
run: minikube start --kubernetes-version=v1.23.15

- name: Swap off
- name: Get pods
run: |
sudo swapoff -a
sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
- name: Start Kubelet
kubectl get pods -o wide --all-namespaces
- name: Get nodes
run: |
sudo mkdir /etc/systemd/system/kubelet.service.d/
sudo cp ./test/etc/systemd/system/kubelet.service.d/10-kubeadm.conf /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
sudo sed -i "s#/usr/bin#/snap/bin#" /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
sudo cp ./test/etc/systemd/system/kubelet.service /etc/systemd/system/kubelet.service
sudo cp ./test/var/lib/kubelet/kubeadm-flags.env /var/lib/kubelet/kubeadm-flags.env
sudo cp ./test/var/lib/kubelet/config.yaml /var/lib/kubelet/config.yaml
sudo systemctl daemon-reload
sudo systemctl enable kubelet --now
sleep 2
sudo systemctl status kubelet || journalctl -xe -u kubelet || true
kubectl get nodes -o wide
- name: Initialize Kubernetes
- name: Install cri-dockerd
run: |
sudo kubeadm init || {
journalctl -xeu kubelet
exit 1
}
minikube cp install.sh /home/docker/install.sh
minikube ssh -- sudo bash -c "FORCE=y /home/docker/install.sh"
- 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
Expand Down
19 changes: 16 additions & 3 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,25 @@ function check_container_runtime_of_kubelet() {
fi
}

function download() {
local url=$1
local output=$2
echo "Downloading ${url} to ${output}"
if command -v wget > /dev/null; then
wget -O "${output}" "${url}"
elif command -v curl > /dev/null; then
curl -L -o "${output}" "${url}"
else
echo "Neither wget nor curl is installed"
exit 1
fi
}

function install_cri_dockerd() {
if [[ ! -s "${BIN_PATH}/${BIN_NAME}" ]]; then
if [[ ! -x "${BIN_PATH}/${BIN_NAME}" ]]; then
echo "Installing cri-dockerd"
if [[ ! -s "${TAR_PATH}/${TAR_NAME}" ]]; then
echo "Downloading binary of cri-dockerd"
mkdir -p "${TAR_PATH}" && wget -O "${TAR_PATH}/${TAR_NAME}" "${BIN_URL}"
mkdir -p "${TAR_PATH}" && download "${BIN_URL}" "${TAR_PATH}/${TAR_NAME}"
fi
tar -xzvf "${TAR_PATH}/${TAR_NAME}" -C "${BIN_PATH}" "${BIN_NAME}" && chmod +x "${BIN_PATH}/${BIN_NAME}"
echo "Binary of cri-dockerd is installed"
Expand Down
14 changes: 0 additions & 14 deletions test/etc/systemd/system/kubelet.service

This file was deleted.

11 changes: 0 additions & 11 deletions test/etc/systemd/system/kubelet.service.d/10-kubeadm.conf

This file was deleted.

2 changes: 0 additions & 2 deletions test/var/lib/kubelet/config.yaml

This file was deleted.

1 change: 0 additions & 1 deletion test/var/lib/kubelet/kubeadm-flags.env

This file was deleted.

0 comments on commit 0f5675d

Please sign in to comment.