-
Notifications
You must be signed in to change notification settings - Fork 2
/
to.sh
executable file
·87 lines (74 loc) · 3.41 KB
/
to.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
i() { echo "i: $@"; }
c() { echo "# $@"; }
x() { echo "\$ $@" ; eval "$@" ; }
die() { echo "err: $@" ; exit 1; }
_oc() { echo "$ oc $@" ; oc $@ ; }
qoc() { oc $@ > /dev/null 2>&1; }
SA=openshift-descheduler
NS=openshift-kube-descheduler-operator
tainter() {
x "oc delete -n $NS configmap desched-taint || :"
x "oc delete -n $NS -f manifests/50-desched-taint.yaml || :"
x "oc adm policy remove-cluster-role-from-user system:controller:node-controller -z $SA -n $NS || :"
if [[ "$1" != "del" ]]; then
x "oc create -n $NS configmap desched-taint --from-file contrib/desched-taint.sh"
x "oc apply -n $NS -f manifests/50-desched-taint.yaml"
x "oc adm policy add-cluster-role-to-user system:controller:node-controller -z $SA -n $NS" # for tainter
fi
}
apply_mc() {
c "Reconfigure node-exporter to export PSI"
_oc apply -f manifests/10-mc-psi-controlplane.yaml
_oc apply -f manifests/11-mc-psi-worker.yaml
_oc apply -f manifests/12-mc-schedstats-worker.yaml
}
apply_operators() {
c "Deploy operators"
_oc apply -f manifests/20-namespaces.yaml
_oc apply -f manifests/30-operatorgroup.yaml
_oc apply -f manifests/31-subscriptions.yaml
x "until qoc get crd hyperconvergeds.hco.kubevirt.io kubedeschedulers.operator.openshift.io ; do echo -n . ; sleep 6 ; done"
x "until _oc apply -f manifests/40-cnv-operator-cr.yaml ; do echo -n . sleep 6 ; done"
x "until _oc apply -f manifests/41-descheduler-operator-cr.yaml ; do echo -n . sleep 6 ; done"
}
apply_node_tainter() {
tainter
}
apply() {
apply_mc
apply_operators
apply_node_tainter
}
deploy() {
apply
wait_for_mcp
qoc get sa -n $NS $SA || die "Did not find descheduler ServiceAccount '$SA' in namespace '$NS'. Is it installed?"
_oc adm policy add-cluster-role-to-user cluster-monitoring-view -z $SA -n $NS # for desched metrics
}
monitor() {
echo -n "$(oc get console cluster -o=jsonpath='{@.status.consoleURL}')"
echo '/monitoring/query-browser?query0=sum+by+%28instance%29+%28rate%28node_pressure_cpu_waiting_seconds_total%5B1m%5D%29+*+on%28instance%29+group_left%28node%29+label_replace%28kube_node_role%7Brole%3D%22worker%22%7D%2C+%27instance%27%2C+%22%241%22%2C+%27node%27%2C+%27%28.%2B%29%27%29%29&query1=stddev%28sum+by+%28instance%29+%28rate%28node_pressure_cpu_waiting_seconds_total%5B1m%5D%29+*+on%28instance%29+group_left%28node%29+label_replace%28kube_node_role%7Brole%3D%22worker%22%7D%2C+%27instance%27%2C+%22%241%22%2C+%27node%27%2C+%27%28.%2B%29%27%29%29%29&query2=count+by+%28node%29+%28kubevirt_vmi_info%7Bname%3D%7E%22.*cpu.*%22%2C+phase%3D%22running%22%7D%29'
echo "$ oc logs -n openshift-kube-descheduler-operator -l app=desched-taint -f"
}
destroy() {
c "Delete the operators"
_oc delete -f manifests/50-desched-taint.yaml
_oc delete -f manifests/41-descheduler-operator-cr.yaml
_oc delete -f manifests/40-cnv-operator-cr.yaml
_oc delete -f manifests/31-subscriptions.yaml
_oc delete -f manifests/30-operatorgroup.yaml
_oc delete -f manifests/20-namespaces.yaml
tainter del
# _oc delete -f manifests/11-mc-psi-worker.yaml
# _oc delete -f manifests/10-mc-psi-controlplane.yaml
}
wait_for_mcp() {
x "oc wait mcp worker --for condition=Updated=False --timeout=10s"
x "oc wait mcp master --for condition=Updated=False --timeout=10s"
x "oc wait mcp worker --for condition=Updated=True --timeout=15m"
x "oc wait mcp master --for condition=Updated=True --timeout=15m"
}
usage() {
grep -E -o "^.*\(\)" $0
}
eval "${@:-usage}"