Skip to content

Commit

Permalink
Replace minikube with kind
Browse files Browse the repository at this point in the history
  • Loading branch information
lebauce committed Jul 17, 2021
1 parent ae8e712 commit 843b7dd
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 34 deletions.
40 changes: 40 additions & 0 deletions jenkins/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,22 @@
cd src/github.com/skydive-project/skydive-ci
{script}
- builder:
name: bootstrap-k8s-environment
builders:
- ci-script:
script: |
case "$K8S_PROVIDER" in
minikube)
scripts/minikube.sh install
scripts/minikube.sh start
;;
*)
scripts/kind.sh install
scripts/kind.sh start
;;
esac
- parameter:
name: skydive-parameters
parameters:
Expand Down Expand Up @@ -318,3 +334,27 @@
run-if-job-successful: "{only-if-successful}"
script: |
{script}
- publisher:
name: cleanup-k8s-environment
publishers:
- post-tasks:
- matches:
- log-text: .*
operator: AND
run-if-job-successful: "{only-if-successful}"
script: |
set -v
cd src/github.com/skydive-project/skydive-ci
if [ "$KEEP_RESOURCES" != "true" ]
then
case "$K8S_PROVIDER" in
minikube)
scripts/minikube.sh stop
;;
*)
scripts/kind.sh stop
;;
esac
fi
19 changes: 8 additions & 11 deletions jenkins/skydive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,26 +114,23 @@
- skydive-default-parameters
- skydive-labels:
slave-name: baremetal
- string:
name: K8S_PROVIDER
default: "kind"
description: Provider to use to install k8s
builders:
- skydive-cleanup
- bootstrap-k8s-environment
- ci-script:
script: |
sudo systemctl restart libvirtd || true
WITH_ISTIO=true . scripts/install-minikube.sh start
. scripts/istio.sh start
- skydive-test:
test: BACKEND=elasticsearch scripts/ci/run-istio-tests.sh
test: BACKEND=elasticsearch KUBECONFIG=$HOME/.kube/config scripts/ci/run-istio-tests.sh
publishers:
- junit:
results: tests.xml
- cleanup-k8s-environment
- skydive-publishers
- skydive-post-script:
only-if-successful: true
script: |
[ "$KEEP_RESOURCES" = "true" ] || . src/github.com/skydive-project/skydive-ci/scripts/install-minikube.sh stop
- skydive-post-script:
only-if-successful: false
script: |
[ "$KEEP_RESOURCES" = "true" ] || . src/github.com/skydive-project/skydive-ci/scripts/install-minikube.sh delete

- job:
name: skydive-ovn-k8s-tests
Expand Down
2 changes: 1 addition & 1 deletion scripts/cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function docker_volume_rm() {

function cleanup() {
# cleanup minikube
"${CURDIR}/install-minikube.sh" stop
"${CURDIR}/minikube.sh" stop

# cleanup podman/runc
podman stop -a
Expand Down
File renamed without changes.
47 changes: 47 additions & 0 deletions scripts/kind.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

. $DIR/utils.sh

install() {
install_binary kind https://kind.sigs.k8s.io/dl/v0.11.1/kind-linux-amd64
}

start() {
kind create cluster
}

stop() {
kind delete cluster
}

delete() {
kind delete cluster
}

uninstall() {
uninstall_binary kind
}

case "$1" in
install)
install
;;
uninstall)
uninstall
;;
start)
start
;;
stop)
stop
;;
delete)
delete
;;
*)
echo "$0 [install|uninstall|start|stop|status]"
exit 1
;;
esac
24 changes: 2 additions & 22 deletions scripts/install-minikube.sh → scripts/minikube.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

. $DIR/utils.sh

OS=linux
ARCH=amd64
TARGET_DIR=/usr/bin
Expand All @@ -13,7 +15,6 @@ K8S_VERSION="v1.15.12"
KUBECTL_URL="https://storage.googleapis.com/kubernetes-release/release/$K8S_VERSION/bin/$OS/$ARCH/kubectl"

[ -z "$WITH_CALICO" ] && WITH_CALICO=false
[ -z "$WITH_ISTIO" ] && WITH_ISTIO=true

CALICO_VERSION="v2.6"
CALICO_URL="https://docs.projectcalico.org/$CALICO_VERSION/getting-started/kubernetes/installation/hosted/calico.yaml"
Expand All @@ -32,25 +33,6 @@ case "$MINIKUBE_DRIVER" in
;;
esac

uninstall_binary() {
local prog=$1
sudo rm -f $TARGET_DIR/$prog
}

install_binary() {
local prog=$1
local url=$2

wget --no-check-certificate -O $prog $url
if [ $? != 0 ]; then
echo "failed to download $url"
exit 1
fi

chmod a+x $prog
sudo mv $prog $TARGET_DIR/$prog
}

check_minikube() {
minikube version | grep $MINIKUBE_VERSION 2>/dev/null
if [ $? != 0 ]; then
Expand Down Expand Up @@ -127,8 +109,6 @@ start() {

$WITH_CALICO && kubectl apply -f $CALICO_URL

$WITH_ISTIO && $DIR/install-istio.sh start

kubectl get services kubernetes
kubectl get pods -n kube-system
}
Expand Down
27 changes: 27 additions & 0 deletions scripts/utils.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

export PATH=${HOME}/bin:${PATH}

download_file() {
local path=$1
local url=$2

curl -z $path -o $path -L $url
if [ $? != 0 ]; then
echo "failed to download $url"
exit 1
fi
}

uninstall_binary() {
local prog=$1
sudo rm -f $TARGET_DIR/$prog
}

install_binary() {
local prog=$1
local url=$2

download_file $HOME/bin/$prog $url
chmod a+x $HOME/bin/$prog
}

0 comments on commit 843b7dd

Please sign in to comment.