-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers
executable file
·67 lines (60 loc) · 1.95 KB
/
helpers
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
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
argo_version="v3.5.5"
image_k3s="rancher/k3s:v1.27.5-k3s1"
check_ready() {
ready="0"
status="0"
while true; do
kube_resource=$(kubectl --kubeconfig .kubeconfig get -n $1 $2 | $3 | awk '{print $1}') && \
status=$(kubectl --kubeconfig .kubeconfig get $2 -n $1 $kube_resource -o $5="$6")
echo "$kube_resource : status == $status"
echo "$status" | grep -qi "$4" && echo "$7" && ready="1"
if [ "$ready" == "1" ]; then
break
fi
sleep 2
done
}
create_cluster() {
k3d cluster create \
--k3s-arg "--disable=traefik@server:0" \
--volume $(pwd)/install.yaml:/var/lib/rancher/k3s/server/manifests/install.yaml \
--image $image_k3s \
mycluster && \
k3d kubeconfig get mycluster > .kubeconfig && \
check_ready "kube-system"\
"pod" \
"grep coredns" \
"true" \
"jsonpath" \
"{.status.containerStatuses.*.ready}" \
"COREDNS READY" && \
check_ready "argo" \
"pod" \
"grep argo-server" \
"true" \
"jsonpath" \
"{.status.containerStatuses.*.ready}" \
"ARGO WORKFLOWS READY"
}
check_workflow () {
check_ready "default" \
"workflow" \
"tail -n 1" \
"Succeeded" \
"go-template" \
'{{ index .metadata.labels "workflows.argoproj.io/phase" }}' \
"DONE"
}
drop_cluster() {
k3d cluster delete mycluster
}
setup_forward() {
kube_pod=$(kubectl --kubeconfig .kubeconfig get -n argo pods | grep argo-server | awk '{print $1}')
kubectl --kubeconfig .kubeconfig -n argo port-forward pods/$kube_pod 9000:2746
}
update() {
curl -Lo ./base/install.yaml \
https://github.com/argoproj/argo-workflows/releases/download/$argo_version/install.yaml && \
kustomize build overlays/rbac/ > install.yaml
}