forked from jenkinsci/kubernetes-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kind.sh
33 lines (29 loc) · 1.05 KB
/
kind.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
set -euxo pipefail
export PATH=$WSTMP:$PATH
if [ \! -f $WSTMP/kind ]
then
curl -Lo $WSTMP/kind https://github.com/kubernetes-sigs/kind/releases/download/v0.7.0/kind-$(uname | tr '[:upper:]' '[:lower:]')-amd64
chmod +x $WSTMP/kind
fi
if [ \! -f $WSTMP/kubectl ]
then
curl -Lo $WSTMP/kubectl https://storage.googleapis.com/kubernetes-release/release/v1.17.0/bin/$(uname | tr '[:upper:]' '[:lower:]')/amd64/kubectl
chmod +x $WSTMP/kubectl
fi
export cluster=ci$RANDOM
export KUBECONFIG=$WSTMP/kubeconfig-$cluster
kind create cluster --name $cluster --wait 5m --config kind.yaml
function cleanup() {
kind export logs --name $cluster $WSTMP/kindlogs || :
kind delete cluster --name $cluster || :
rm $KUBECONFIG
}
trap cleanup EXIT
kubectl cluster-info
DOCKER_IMAGE=$(grep -e image: test-in-k8s.yaml | cut -d ':' -f 2- | xargs)
docker pull $DOCKER_IMAGE
kind load docker-image $DOCKER_IMAGE --name $cluster
bash test-in-k8s.sh
rm -rf $WSTMP/surefire-reports
kubectl cp jenkins:/checkout/target/surefire-reports $WSTMP/surefire-reports