-
-
Notifications
You must be signed in to change notification settings - Fork 66
/
.drone.yml
41 lines (36 loc) · 2.19 KB
/
.drone.yml
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
34
35
36
37
38
39
40
41
---
kind: pipeline
type: docker
name: main
platform:
os: linux
arch: amd64
steps:
- name: test
image: bitnami/kubectl:1.22.2
user: root # the bitnami/kubectl image has a non-root user set by default, which does not work with the shared docker volume which is owned by root
commands:
- export KUBECONFIG=kubeconfig-$${DRONE_BUILD_STARTED}.yaml
- until test -f $${KUBECONFIG}; do sleep 1s; done # wait for k3d service to write the kubeconfig to the workspace
- kubectl config view
- kubectl get pods --all-namespaces
- kubectl create namespace ci # create new namespace for test deployments
- kubectl -n ci run test-pod --image alpine -- tail -f /dev/null # create dummy pod that just hangs around
- until kubectl -n ci get pod test-pod -o go-template='{{.status.phase}}' | grep 'Running'; do sleep 1s; done # wait for pod to be running
- kubectl -n ci get pods
- kubectl -n ci exec test-pod -- echo "Hello World!" # do something inside that pod -> here you could exec tests
- printf "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@@@@@@@@@@ The End @@@@@@@@@@\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"
- echo "You can also run some integration tests, etc. by hitting API endpoints or something like that.."
- echo "For example, combine this with Helm post-install hooks that wait for testing jobs to finish before marking a release as success."
services:
- name: k3dsvc
image: rancher/k3d:5.0.0-rc.4-dind
privileged: true
commands:
- nohup dockerd-entrypoint.sh & # start docker in the background
- until docker ps 2>&1 > /dev/null; do sleep 1s; done # wait for docker to be ready before proceeding
- k3d cluster create --config ci/k3d-drone.yaml --api-port k3dsvc:6445 # create k3d cluster from config file
- until kubectl get deployment coredns -n kube-system -o go-template='{{.status.availableReplicas}}' | grep -v -e '<no value>'; do sleep 1s; done # wait for coredns to be up and running
- k3d kubeconfig get drone > kubeconfig-$${DRONE_BUILD_STARTED}.yaml
- printf "@@@@@@@@@@@@@@@@@@@@@@@\n@@@@ k3d is ready! @@@@\n@@@@@@@@@@@@@@@@@@@@@@@\n"
- tail -f /dev/null # chill around while the steps do their work