This repository has been archived by the owner on Oct 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 62
/
remove-deployment-updater-readiness.sh
55 lines (45 loc) · 1.81 KB
/
remove-deployment-updater-readiness.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
#!/bin/bash
set -o errexit -o nounset -o pipefail -o xtrace
# Remove the cc-deployment-updater readiness probes; they are incorrectly
# constructed for an active/passive job, and cause the scheduler to show as
# unready, and therefore blocking upgrades. See
# https://github.com/cloudfoundry-incubator/kubecf/issues/1589 for details.
# Patch the StatefulSet so that any new instances we create will not have the
# probe.
patch='
---
spec:
template:
spec:
containers:
- name: cc-deployment-updater-cc-deployment-updater
readinessProbe: ~
'
scheduler_list=$(kubectl get statefulsets \
--namespace "${NAMESPACE}" \
--selector quarks.cloudfoundry.org/instance-group-name=scheduler \
--no-headers=true \
--output custom-columns=:metadata.name
)
if [ "${scheduler_list}" == "" ]; then
echo "No scheduler statefulset found."
exit 0
fi
query='{.spec.template.spec.containers[*].name}'
for scheduler in ${scheduler_list}; do
probe="$(kubectl get statefulsets --namespace="${NAMESPACE}" "${scheduler}" --output=jsonpath="${query}")"
if [[ "${probe}" =~ "cc-deployment-updater-cc-deployment-updater" ]]; then
kubectl patch statefulset --namespace "$NAMESPACE" "${scheduler}" --patch "$patch"
fi
done
# Delete all existing scheduler pods; we can't just patch them as changing
# existing readiness probes is not allowed.
mapfile -t pods < <(kubectl get pods --namespace="${NAMESPACE}" --output=name \
--selector "quarks.cloudfoundry.org/instance-group-name=scheduler")
query='{.spec.containers[?(.name == "cc-deployment-updater-cc-deployment-updater")].readinessProbe.exec.command}'
for pod in "${pods[@]}"; do
probe="$(kubectl get --namespace="${NAMESPACE}" "${pod}" --output=jsonpath="${query}")"
if [[ -n "${probe}" ]]; then
kubectl delete --namespace="${NAMESPACE}" "${pod}"
fi
done