Unpause deployments and add ReplicaSet/status debug output

Add spec.paused: null to the strategic merge patch to clear any
paused state that might be blocking rollouts. Also add detailed
deployment status debug output (conditions, replica counts,
paused state) and list ReplicaSets to diagnose why new pods
aren't being created despite spec changes.
This commit is contained in:
Viktor Barzin 2026-02-22 19:40:44 +00:00
parent 0a2b207bee
commit 692d68c270
No known key found for this signature in database
GPG key ID: 0EB088298288D958

View file

@ -293,16 +293,20 @@ steps:
API="https://kubernetes:6443/apis/apps/v1/namespaces/realestate-crawler/deployments"
for DEPLOY in realestate-crawler-api realestate-crawler-celery realestate-crawler-celery-beat; do
CONTAINER=$(curl -sfk "$API/$DEPLOY" \
# Check if deployment is paused and get container name
STATUS=$(curl -sfk "$API/$DEPLOY" \
-H "Authorization: Bearer $TOKEN" \
-H "Accept: application/json" | jq -r '.spec.template.spec.containers[0].name')
echo "Patching $DEPLOY (container=$CONTAINER) to image $IMAGE with restartedAt=$RESTART_AT..."
-H "Accept: application/json")
CONTAINER=$(echo "$STATUS" | jq -r '.spec.template.spec.containers[0].name')
PAUSED=$(echo "$STATUS" | jq -r '.spec.paused // false')
echo "Patching $DEPLOY (container=$CONTAINER, paused=$PAUSED) to image $IMAGE..."
# Strategic merge: update image, set restartedAt, ensure not paused
curl -sf -X PATCH "$API/$DEPLOY" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/strategic-merge-patch+json" \
-k -d "{\"spec\":{\"template\":{\"metadata\":{\"annotations\":{\"kubectl.kubernetes.io/restartedAt\":\"$RESTART_AT\"}},\"spec\":{\"containers\":[{\"name\":\"$CONTAINER\",\"image\":\"$IMAGE\"}]}}}}" \
| jq '{name: .metadata.name, generation: .metadata.generation, image: .spec.template.spec.containers[0].image}'
-k -d "{\"spec\":{\"paused\":null,\"template\":{\"metadata\":{\"annotations\":{\"kubectl.kubernetes.io/restartedAt\":\"$RESTART_AT\"}},\"spec\":{\"containers\":[{\"name\":\"$CONTAINER\",\"image\":\"$IMAGE\"}]}}}}" \
| jq '{name: .metadata.name, generation: .metadata.generation, image: .spec.template.spec.containers[0].image, paused: .spec.paused, restartedAt: .spec.template.metadata.annotations["kubectl.kubernetes.io/restartedAt"]}'
done
- name: verify-deploy
@ -320,13 +324,24 @@ steps:
for DEPLOY in realestate-crawler-api realestate-crawler-celery realestate-crawler-celery-beat; do
echo "Verifying $DEPLOY..."
PODS_API="$BASE_API?labelSelector=app%3D$DEPLOY"
RS_API="https://kubernetes:6443/apis/apps/v1/namespaces/realestate-crawler/replicasets?labelSelector=app%3D$DEPLOY"
# Check deployment spec to confirm patch took effect
DEPLOY_IMAGE=$(curl -sfk "$DEPLOY_API/$DEPLOY" \
# Check deployment status (spec, conditions, paused, replicas)
DEPLOY_STATUS=$(curl -sfk "$DEPLOY_API/$DEPLOY" \
-H "Authorization: Bearer $TOKEN" \
-H "Accept: application/json")
echo " Deployment spec image: $(echo "$DEPLOY_STATUS" | jq -r '.spec.template.spec.containers[0].image')"
echo " Deployment paused: $(echo "$DEPLOY_STATUS" | jq -r '.spec.paused // false')"
echo " Deployment status: replicas=$(echo "$DEPLOY_STATUS" | jq -r '.status.replicas // 0') updated=$(echo "$DEPLOY_STATUS" | jq -r '.status.updatedReplicas // 0') ready=$(echo "$DEPLOY_STATUS" | jq -r '.status.readyReplicas // 0') unavailable=$(echo "$DEPLOY_STATUS" | jq -r '.status.unavailableReplicas // 0')"
echo " Conditions:"
echo "$DEPLOY_STATUS" | jq -r '.status.conditions[]? | " \(.type): \(.status) (\(.reason // "unknown"))"' 2>/dev/null || echo " (none)"
# Check ReplicaSets
echo " ReplicaSets:"
curl -sfk "$RS_API" \
-H "Authorization: Bearer $TOKEN" \
-H "Accept: application/json" | \
jq -r '.spec.template.spec.containers[0].image' 2>/dev/null)
echo " Deployment spec image: $DEPLOY_IMAGE"
jq -r '.items[] | " \(.metadata.name) desired=\(.spec.replicas) ready=\(.status.readyReplicas // 0) image=\(.spec.template.spec.containers[0].image)"' 2>/dev/null || echo " (none)"
FOUND=0
for i in $(seq 1 60); do