forked from mtusi2026/mtusi2026lab6
feat: add bounded observability and verified SLO incident alerts
This commit is contained in:
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
# Restart this lab's API, worker and persistent stores without removing PVCs.
|
||||
set -eu
|
||||
: "${KUBE_CONTEXT:=dev}" "${NAMESPACE:=highload-applications}"
|
||||
if kubectl --context "$KUBE_CONTEXT" -n "$NAMESPACE" get hpa api >/dev/null 2>&1; then
|
||||
echo 'Disable autoscaling in the lab release before this restart test, then restore it.' >&2
|
||||
exit 1
|
||||
fi
|
||||
replicas=$(kubectl --context "$KUBE_CONTEXT" -n "$NAMESPACE" get deployment api -o jsonpath='{.spec.replicas}')
|
||||
worker_replicas=$(kubectl --context "$KUBE_CONTEXT" -n "$NAMESPACE" get deployment worker -o jsonpath='{.spec.replicas}')
|
||||
restore() {
|
||||
kubectl --context "$KUBE_CONTEXT" -n "$NAMESPACE" scale deployment/api --replicas="$replicas" >/dev/null
|
||||
kubectl --context "$KUBE_CONTEXT" -n "$NAMESPACE" scale deployment/worker --replicas="$worker_replicas" >/dev/null
|
||||
}
|
||||
trap restore EXIT
|
||||
mkdir -p evidence
|
||||
kubectl --context "$KUBE_CONTEXT" -n "$NAMESPACE" get pods -l 'app in (api,worker,postgres,valkey,s3,broker)' -o custom-columns=NAME:.metadata.name,UID:.metadata.uid > evidence/restart-before.txt
|
||||
kubectl --context "$KUBE_CONTEXT" -n "$NAMESPACE" scale deployment/api deployment/worker --replicas=0
|
||||
kubectl --context "$KUBE_CONTEXT" -n "$NAMESPACE" wait --for=delete pod -l 'app in (api,worker)' --timeout=60s
|
||||
kubectl --context "$KUBE_CONTEXT" -n "$NAMESPACE" rollout restart statefulset/postgres statefulset/valkey statefulset/s3 statefulset/broker
|
||||
for name in postgres valkey s3 broker; do
|
||||
kubectl --context "$KUBE_CONTEXT" -n "$NAMESPACE" rollout status "statefulset/$name" --timeout=120s
|
||||
done
|
||||
restore
|
||||
kubectl --context "$KUBE_CONTEXT" -n "$NAMESPACE" rollout status deployment/api --timeout=120s
|
||||
kubectl --context "$KUBE_CONTEXT" -n "$NAMESPACE" rollout status deployment/worker --timeout=120s
|
||||
kubectl --context "$KUBE_CONTEXT" -n "$NAMESPACE" get pods -l 'app in (api,worker,postgres,valkey,s3,broker)' -o custom-columns=NAME:.metadata.name,UID:.metadata.uid > evidence/restart-after.txt
|
||||
Reference in New Issue
Block a user