docs: record final contract verification and restart scope

This commit is contained in:
Vladislav Agapov
2026-10-29 18:01:40 +03:00
parent 607d328d6d
commit 557f46f626
4 changed files with 37 additions and 12 deletions
+18 -12
View File
@@ -1,21 +1,27 @@
#!/bin/sh
# Restart only this lab's API and persistent stores, retaining every PVC.
# Restart this lab's API, worker and persistent stores without removing PVCs.
set -eu
: "${KUBE_CONTEXT:=dev}" "${NAMESPACE:=highload-applications}"
# HPA must be disabled explicitly for this destructive test window.
if kubectl --context "$KUBE_CONTEXT" -n "$NAMESPACE" get hpa api >/dev/null 2>&1; then
echo 'Disable autoscaling in the lab release before the restart test, then restore it.' >&2
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,postgres,valkey,s3)' -o custom-columns=NAME:.metadata.name,UID:.metadata.uid > evidence/restart-before.txt
kubectl --context "$KUBE_CONTEXT" -n "$NAMESPACE" scale deployment/api --replicas=0
kubectl --context "$KUBE_CONTEXT" -n "$NAMESPACE" wait --for=delete pod -l app=api --timeout=60s
kubectl --context "$KUBE_CONTEXT" -n "$NAMESPACE" rollout restart statefulset/postgres statefulset/valkey statefulset/s3
kubectl --context "$KUBE_CONTEXT" -n "$NAMESPACE" rollout status statefulset/postgres --timeout=120s
kubectl --context "$KUBE_CONTEXT" -n "$NAMESPACE" rollout status statefulset/valkey --timeout=120s
kubectl --context "$KUBE_CONTEXT" -n "$NAMESPACE" rollout status statefulset/s3 --timeout=120s
kubectl --context "$KUBE_CONTEXT" -n "$NAMESPACE" scale deployment/api --replicas="$replicas"
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" get pods -l 'app in (api,postgres,valkey,s3)' -o custom-columns=NAME:.metadata.name,UID:.metadata.uid > evidence/restart-after.txt
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