-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcm-test.sh
executable file
·54 lines (44 loc) · 1.46 KB
/
cm-test.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env bash
set -euxo pipefail
# appends a command to a trap
#
# - 1st arg: code to add
# - remaining args: names of traps to modify
#
trap_add() {
trap_add_cmd=$1; shift || fatal "${FUNCNAME} usage error"
for trap_add_name in "$@"; do
trap -- "$(
# helper fn to get existing trap command from output
# of trap -p
extract_trap_cmd() { printf '%s\n' "${3:-}"; }
# print existing trap command with newline
eval "extract_trap_cmd $(trap -p "${trap_add_name}")"
# print the new trap command
printf '%s\n' "${trap_add_cmd}"
)" "${trap_add_name}" \
|| fatal "unable to add to trap ${trap_add_name}"
done
}
# create a cluster
kind create cluster --wait 5m
function cleanup_kind {
kind delete cluster
}
trap_add cleanup_kind EXIT
# remove the existing controller manager
docker exec kind-control-plane rm /etc/kubernetes/manifests/kube-controller-manager.yaml
# start our controller-manager
cargo run --release --features serve -- controller-manager &
pid=$!
function cleanup_cargo {
kill $pid
}
trap_add cleanup_cargo EXIT
# create a resource
kubectl create deployment --image nginx:alpine nginx --replicas 1
# wait for it to finish deploying
kubectl rollout status deployment/nginx --watch
# TODO: scale the deployment down, change the image and wait again
kubectl scale deployment/nginx --replicas 2
kubectl rollout status deployment/nginx --watch