Skip to content

Commit

Permalink
using k3s action
Browse files Browse the repository at this point in the history
Signed-off-by: PrimalPimmy <[email protected]>
  • Loading branch information
PrimalPimmy committed Aug 18, 2023
1 parent 1edcf62 commit ae61066
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 36 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/ci-test-ginkgo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ jobs:
with:
go-version: "v1.20"

- name: Create k3s cluster
run: ./.github/workflows/scripts/install_k3s.sh
- uses: debianmaster/actions-k3s@master
id: k3s
with:
version: 'latest'

- name: Test connectivity
run: kubectl get pods -A
Expand Down
36 changes: 4 additions & 32 deletions .github/workflows/scripts/install_k3s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,14 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2021 Authors of KubeArmor

if [ "$RUNTIME" == "" ]; then
if [ -S /var/run/docker.sock ]; then
RUNTIME="docker"
elif [ -S /var/run/crio/crio.sock ]; then
RUNTIME="crio"
else # default
RUNTIME="containerd"
fi
fi
RUNTIME="containerd"


# create a single-node K3s cluster
if [ "$RUNTIME" == "docker" ]; then # docker
CGROUP_SYSTEMD=$(docker info 2> /dev/null | grep -i cgroup | grep systemd | wc -l)
if [ $CGROUP_SYSTEMD == 1 ]; then
curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION="v1.23.9+k3s1" K3S_KUBECONFIG_MODE="644" INSTALL_K3S_EXEC="--disable=traefik --docker --kubelet-arg cgroup-driver=systemd" sh -
[[ $? != 0 ]] && echo "Failed to install k3s" && exit 1
else # cgroupfs
curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION="v1.23.9+k3s1" K3S_KUBECONFIG_MODE="644" INSTALL_K3S_EXEC="--disable=traefik --docker" sh -
[[ $? != 0 ]] && echo "Failed to install k3s" && exit 1
fi
elif [ "$RUNTIME" == "crio" ]; then # cri-o
curl -sfL https://get.k3s.io | K3S_KUBECONFIG_MODE="644" INSTALL_K3S_EXEC="--disable=traefik --container-runtime-endpoint unix:///var/run/crio/crio.sock --kubelet-arg cgroup-driver=systemd" sh -
[[ $? != 0 ]] && echo "Failed to install k3s" && exit 1
else # use containerd by default
curl -sfL https://get.k3s.io | K3S_KUBECONFIG_MODE="644" INSTALL_K3S_EXEC="--disable=traefik" sh -
[[ $? != 0 ]] && echo "Failed to install k3s" && exit 1
fi

if [[ $(hostname) = kubearmor-dev* ]]; then
mkdir -p /home/vagrant/.kube
sudo cp /etc/rancher/k3s/k3s.yaml /home/vagrant/.kube/config
sudo chown -R vagrant:vagrant /home/vagrant/.kube
echo "export KUBECONFIG=/home/vagrant/.kube/config" | tee -a /home/vagrant/.bashrc
PATH=$PATH:/bin:/usr/bin:/usr/local/bin
else


KUBEDIR=$HOME/.kube
KUBECONFIG=$KUBEDIR/config
[[ ! -d $KUBEDIR ]] && mkdir $KUBEDIR
Expand All @@ -47,7 +20,6 @@ else
sudo cp /etc/rancher/k3s/k3s.yaml $KUBECONFIG
sudo chown $USER:$USER $KUBECONFIG
echo "export KUBECONFIG=$KUBECONFIG" | tee -a ~/.bashrc
fi

echo "wait for initialization"
sleep 15
Expand Down
4 changes: 2 additions & 2 deletions tests/tests_suite_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package test
package k8tlstest

import (
"testing"
Expand All @@ -9,5 +9,5 @@ import (

func TestTests(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Tests Suite")
RunSpecs(t, "K8tls Tests Suite")
}

0 comments on commit ae61066

Please sign in to comment.