2025-06-17 18:45:28 +00:00
|
|
|
kind: pipeline
|
|
|
|
|
type: kubernetes
|
2025-06-17 18:56:52 +00:00
|
|
|
name: frontend
|
2025-06-17 18:45:28 +00:00
|
|
|
|
2026-02-15 17:24:56 +00:00
|
|
|
clone:
|
|
|
|
|
disable: true
|
|
|
|
|
|
2026-02-07 10:52:54 +00:00
|
|
|
concurrency:
|
|
|
|
|
limit: 1
|
|
|
|
|
|
2026-02-07 10:51:24 +00:00
|
|
|
timeout: 20
|
|
|
|
|
|
2025-06-17 19:10:49 +00:00
|
|
|
trigger:
|
2026-02-01 19:56:00 +00:00
|
|
|
branch:
|
2026-02-01 21:53:18 +00:00
|
|
|
- master
|
|
|
|
|
event:
|
|
|
|
|
- push
|
2025-06-17 19:10:49 +00:00
|
|
|
|
2025-06-17 18:45:28 +00:00
|
|
|
steps:
|
2026-02-15 17:24:56 +00:00
|
|
|
- name: clone
|
|
|
|
|
image: alpine/git
|
|
|
|
|
commands:
|
|
|
|
|
- |
|
|
|
|
|
for i in 1 2 3 4 5; do
|
|
|
|
|
git clone --depth=50 "$DRONE_REMOTE_URL" . && exit 0
|
|
|
|
|
echo "Clone attempt $i failed, retrying in 5s..."
|
|
|
|
|
sleep 5
|
|
|
|
|
done
|
|
|
|
|
echo "Clone failed after 5 attempts"
|
|
|
|
|
exit 1
|
|
|
|
|
- git checkout "$DRONE_COMMIT"
|
|
|
|
|
|
2026-02-21 21:02:22 +00:00
|
|
|
- name: install-frontend-deps
|
|
|
|
|
image: node:24-alpine
|
|
|
|
|
depends_on:
|
|
|
|
|
- clone
|
|
|
|
|
environment:
|
|
|
|
|
NODE_OPTIONS: "--max-old-space-size=1024"
|
|
|
|
|
commands:
|
|
|
|
|
- cd frontend && npm ci
|
|
|
|
|
|
|
|
|
|
- name: test-shard-1
|
|
|
|
|
image: node:24-alpine
|
|
|
|
|
depends_on:
|
|
|
|
|
- install-frontend-deps
|
|
|
|
|
environment:
|
|
|
|
|
NODE_OPTIONS: "--max-old-space-size=1024"
|
|
|
|
|
commands:
|
|
|
|
|
- cd frontend && npx vitest run --reporter=verbose --shard=1/4
|
|
|
|
|
|
|
|
|
|
- name: test-shard-2
|
|
|
|
|
image: node:24-alpine
|
|
|
|
|
depends_on:
|
|
|
|
|
- install-frontend-deps
|
|
|
|
|
environment:
|
|
|
|
|
NODE_OPTIONS: "--max-old-space-size=1024"
|
|
|
|
|
commands:
|
|
|
|
|
- cd frontend && npx vitest run --reporter=verbose --shard=2/4
|
|
|
|
|
|
|
|
|
|
- name: test-shard-3
|
|
|
|
|
image: node:24-alpine
|
|
|
|
|
depends_on:
|
|
|
|
|
- install-frontend-deps
|
|
|
|
|
environment:
|
|
|
|
|
NODE_OPTIONS: "--max-old-space-size=1024"
|
|
|
|
|
commands:
|
|
|
|
|
- cd frontend && npx vitest run --reporter=verbose --shard=3/4
|
|
|
|
|
|
|
|
|
|
- name: test-shard-4
|
|
|
|
|
image: node:24-alpine
|
|
|
|
|
depends_on:
|
|
|
|
|
- install-frontend-deps
|
|
|
|
|
environment:
|
|
|
|
|
NODE_OPTIONS: "--max-old-space-size=1024"
|
|
|
|
|
commands:
|
|
|
|
|
- cd frontend && npx vitest run --reporter=verbose --shard=4/4
|
|
|
|
|
|
|
|
|
|
- name: build-frontend-image
|
2026-02-21 15:10:55 +00:00
|
|
|
image: plugins/kaniko
|
2026-02-21 21:02:22 +00:00
|
|
|
depends_on:
|
|
|
|
|
- clone
|
2026-02-17 21:46:29 +00:00
|
|
|
resources:
|
|
|
|
|
limits:
|
|
|
|
|
memory: 2048MiB
|
2026-02-21 15:10:55 +00:00
|
|
|
settings:
|
|
|
|
|
username: viktorbarzin
|
|
|
|
|
password:
|
|
|
|
|
from_secret: dockerhub-token
|
|
|
|
|
repo: viktorbarzin/immoweb
|
|
|
|
|
dockerfile: frontend/Dockerfile
|
|
|
|
|
context: frontend
|
2026-02-21 21:02:22 +00:00
|
|
|
target: production
|
2026-02-21 15:10:55 +00:00
|
|
|
enable_cache: true
|
2026-02-21 15:25:36 +00:00
|
|
|
cache_repo: viktorbarzin/immoweb-cache
|
2026-02-07 23:07:16 +00:00
|
|
|
tags:
|
2026-02-21 21:16:37 +00:00
|
|
|
- "build-${DRONE_BUILD_NUMBER}"
|
2026-02-01 21:53:18 +00:00
|
|
|
|
2026-02-21 21:16:37 +00:00
|
|
|
- name: publish-frontend-image
|
2025-06-17 18:45:28 +00:00
|
|
|
image: alpine
|
2026-02-21 21:02:22 +00:00
|
|
|
depends_on:
|
|
|
|
|
- test-shard-1
|
|
|
|
|
- test-shard-2
|
|
|
|
|
- test-shard-3
|
|
|
|
|
- test-shard-4
|
|
|
|
|
- build-frontend-image
|
2026-02-21 21:16:37 +00:00
|
|
|
environment:
|
|
|
|
|
DOCKERHUB_TOKEN:
|
|
|
|
|
from_secret: dockerhub-token
|
|
|
|
|
commands:
|
|
|
|
|
- apk add --no-cache skopeo
|
|
|
|
|
- 'skopeo copy --src-creds "viktorbarzin:$DOCKERHUB_TOKEN" --dest-creds "viktorbarzin:$DOCKERHUB_TOKEN" "docker://docker.io/viktorbarzin/immoweb:build-${DRONE_BUILD_NUMBER}" "docker://docker.io/viktorbarzin/immoweb:${DRONE_BUILD_NUMBER}"'
|
|
|
|
|
- 'skopeo copy --src-creds "viktorbarzin:$DOCKERHUB_TOKEN" --dest-creds "viktorbarzin:$DOCKERHUB_TOKEN" "docker://docker.io/viktorbarzin/immoweb:build-${DRONE_BUILD_NUMBER}" "docker://docker.io/viktorbarzin/immoweb:latest"'
|
|
|
|
|
|
|
|
|
|
- name: Update deployment
|
|
|
|
|
image: alpine
|
|
|
|
|
depends_on:
|
|
|
|
|
- publish-frontend-image
|
2025-06-17 18:45:28 +00:00
|
|
|
commands:
|
2026-02-22 19:21:56 +00:00
|
|
|
- apk add --no-cache curl jq
|
|
|
|
|
- |
|
|
|
|
|
TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
|
|
|
|
|
IMAGE="viktorbarzin/immoweb:${DRONE_BUILD_NUMBER}"
|
|
|
|
|
RESTART_AT=$(date -u +%Y-%m-%dT%H:%M:%SZ)
|
|
|
|
|
API="https://kubernetes:6443/apis/apps/v1/namespaces/realestate-crawler/deployments"
|
|
|
|
|
DEPLOY="realestate-crawler-ui"
|
|
|
|
|
|
|
|
|
|
CONTAINER=$(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..."
|
|
|
|
|
|
|
|
|
|
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}'
|
2025-06-17 18:56:52 +00:00
|
|
|
|
2026-02-09 23:21:07 +00:00
|
|
|
- name: verify-deploy
|
2026-02-08 20:28:02 +00:00
|
|
|
image: alpine
|
2026-02-21 21:02:22 +00:00
|
|
|
depends_on:
|
|
|
|
|
- Update deployment
|
2026-02-08 20:28:02 +00:00
|
|
|
commands:
|
|
|
|
|
- apk add --no-cache curl jq
|
2026-02-09 23:21:07 +00:00
|
|
|
- |
|
|
|
|
|
TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
|
|
|
|
|
EXPECTED_IMAGE="viktorbarzin/immoweb:${DRONE_BUILD_NUMBER}"
|
|
|
|
|
PODS_API="https://kubernetes:6443/api/v1/namespaces/realestate-crawler/pods?labelSelector=app%3Drealestate-crawler-ui"
|
|
|
|
|
|
|
|
|
|
for i in $(seq 1 60); do
|
2026-02-22 17:52:32 +00:00
|
|
|
RAW=$(curl -sfk "$PODS_API" \
|
2026-02-09 23:21:07 +00:00
|
|
|
-H "Authorization: Bearer $TOKEN" \
|
2026-02-22 17:52:32 +00:00
|
|
|
-H "Accept: application/json")
|
|
|
|
|
|
|
|
|
|
# Debug: show all pod images and status on first attempt
|
|
|
|
|
if [ "$i" -eq 1 ]; then
|
|
|
|
|
echo "DEBUG: All pods for realestate-crawler-ui:"
|
|
|
|
|
echo "$RAW" | jq -r '[.items[] | {name: .metadata.name, image: .spec.containers[0].image, ready: (.status.containerStatuses[]? | .ready), phase: .status.phase}] | .[] | " \(.name) image=\(.image) ready=\(.ready) phase=\(.phase)"' 2>/dev/null || echo " (no pods found)"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
RESULT=$(echo "$RAW" | \
|
2026-02-09 23:21:07 +00:00
|
|
|
jq --arg img "$EXPECTED_IMAGE" '[.items[] | select(
|
|
|
|
|
(.status.containerStatuses[]? | .ready == true) and
|
2026-02-22 17:52:32 +00:00
|
|
|
(.spec.containers[]? | .image | endswith($img))
|
|
|
|
|
) | {name: .metadata.name, image: .spec.containers[0].image, started: .status.startTime}]')
|
2026-02-09 23:21:07 +00:00
|
|
|
|
|
|
|
|
COUNT=$(echo "$RESULT" | jq 'length')
|
2026-02-22 17:52:32 +00:00
|
|
|
echo "Attempt $i/60: $COUNT pod(s) ready with image matching $EXPECTED_IMAGE"
|
2026-02-09 23:21:07 +00:00
|
|
|
|
|
|
|
|
if [ "$COUNT" -gt 0 ]; then
|
2026-02-22 17:52:32 +00:00
|
|
|
echo "$RESULT" | jq -r '.[] | " \(.name) image=\(.image) started=\(.started)"'
|
2026-02-09 23:21:07 +00:00
|
|
|
echo "New pod is live!"
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
sleep 5
|
2026-02-08 20:28:02 +00:00
|
|
|
done
|
|
|
|
|
|
2026-02-09 23:21:07 +00:00
|
|
|
echo "ERROR: No new ready pod with image $EXPECTED_IMAGE appeared within 5 minutes"
|
|
|
|
|
exit 1
|
|
|
|
|
|
2025-06-17 18:56:52 +00:00
|
|
|
---
|
|
|
|
|
kind: pipeline
|
|
|
|
|
type: kubernetes
|
|
|
|
|
name: api
|
|
|
|
|
|
2026-02-15 17:24:56 +00:00
|
|
|
clone:
|
|
|
|
|
disable: true
|
|
|
|
|
|
2026-02-07 10:52:54 +00:00
|
|
|
concurrency:
|
|
|
|
|
limit: 1
|
|
|
|
|
|
2026-02-07 10:51:24 +00:00
|
|
|
timeout: 20
|
|
|
|
|
|
2025-06-17 19:10:49 +00:00
|
|
|
trigger:
|
2026-02-01 19:56:00 +00:00
|
|
|
branch:
|
2026-02-01 21:53:18 +00:00
|
|
|
- master
|
|
|
|
|
event:
|
|
|
|
|
- push
|
2025-06-17 19:10:49 +00:00
|
|
|
|
2025-06-17 18:56:52 +00:00
|
|
|
steps:
|
2026-02-15 17:24:56 +00:00
|
|
|
- name: clone
|
|
|
|
|
image: alpine/git
|
|
|
|
|
commands:
|
|
|
|
|
- |
|
|
|
|
|
for i in 1 2 3 4 5; do
|
|
|
|
|
git clone --depth=50 "$DRONE_REMOTE_URL" . && exit 0
|
|
|
|
|
echo "Clone attempt $i failed, retrying in 5s..."
|
|
|
|
|
sleep 5
|
|
|
|
|
done
|
|
|
|
|
echo "Clone failed after 5 attempts"
|
|
|
|
|
exit 1
|
|
|
|
|
- git checkout "$DRONE_COMMIT"
|
|
|
|
|
|
2026-02-21 21:26:44 +00:00
|
|
|
- name: install-api-deps
|
|
|
|
|
image: python:3.13-slim
|
|
|
|
|
depends_on:
|
|
|
|
|
- clone
|
|
|
|
|
commands:
|
|
|
|
|
- apt-get update && apt-get install -y --no-install-recommends libglib2.0-0
|
|
|
|
|
- python -m venv .venv
|
|
|
|
|
- .venv/bin/pip install --quiet --upgrade pip
|
|
|
|
|
- >-
|
|
|
|
|
.venv/bin/pip install --quiet
|
|
|
|
|
pytest pytest-asyncio pytest-cov httpx fakeredis aioresponses
|
|
|
|
|
fastapi uvicorn sqlmodel sqlalchemy alembic pyjwt cryptography
|
|
|
|
|
celery redis click aiohttp aiohttp-socks pillow numpy pytesseract
|
|
|
|
|
opentelemetry-api opentelemetry-sdk opentelemetry-exporter-prometheus
|
|
|
|
|
opentelemetry-instrumentation-fastapi opentelemetry-instrumentation-sqlalchemy
|
|
|
|
|
python-dotenv webauthn apprise tenacity prometheus-client
|
|
|
|
|
email-validator opencv-python-headless tqdm pandas cachetools watchdog
|
|
|
|
|
|
|
|
|
|
- name: test-unit
|
|
|
|
|
image: python:3.13-slim
|
|
|
|
|
depends_on:
|
|
|
|
|
- install-api-deps
|
|
|
|
|
commands:
|
|
|
|
|
- apt-get update && apt-get install -y --no-install-recommends libglib2.0-0
|
|
|
|
|
- .venv/bin/pytest tests/unit/ -v --tb=short
|
|
|
|
|
|
|
|
|
|
- name: test-integration
|
|
|
|
|
image: python:3.13-slim
|
|
|
|
|
depends_on:
|
|
|
|
|
- install-api-deps
|
|
|
|
|
commands:
|
|
|
|
|
- apt-get update && apt-get install -y --no-install-recommends libglib2.0-0
|
|
|
|
|
- .venv/bin/pytest tests/integration/ tests/regression/ tests/e2e/ tests/test_listing_geojson.py -v --tb=short
|
|
|
|
|
|
|
|
|
|
- name: build-api-image
|
2025-06-17 18:56:52 +00:00
|
|
|
image: plugins/docker
|
2026-02-21 21:26:44 +00:00
|
|
|
depends_on:
|
|
|
|
|
- clone
|
2026-02-21 19:51:17 +00:00
|
|
|
environment:
|
|
|
|
|
DOCKER_BUILDKIT: 1
|
2025-06-17 18:56:52 +00:00
|
|
|
settings:
|
2026-02-01 21:53:18 +00:00
|
|
|
username: viktorbarzin
|
2025-06-17 18:56:52 +00:00
|
|
|
password:
|
|
|
|
|
from_secret: dockerhub-token
|
|
|
|
|
repo: viktorbarzin/realestatecrawler
|
2026-02-07 23:01:20 +00:00
|
|
|
dockerfile: Dockerfile
|
|
|
|
|
context: .
|
2026-02-21 21:26:44 +00:00
|
|
|
target: production
|
2026-02-09 21:35:42 +00:00
|
|
|
cache_from:
|
2026-02-21 15:25:36 +00:00
|
|
|
- viktorbarzin/realestatecrawler:latest
|
|
|
|
|
- viktorbarzin/realestatecrawler:builder
|
2026-02-07 23:07:16 +00:00
|
|
|
tags:
|
2026-02-21 21:26:44 +00:00
|
|
|
- "build-${DRONE_BUILD_NUMBER}"
|
|
|
|
|
|
|
|
|
|
- name: publish-api-image
|
|
|
|
|
image: alpine
|
|
|
|
|
depends_on:
|
|
|
|
|
- test-unit
|
|
|
|
|
- test-integration
|
|
|
|
|
- build-api-image
|
|
|
|
|
environment:
|
|
|
|
|
DOCKERHUB_TOKEN:
|
|
|
|
|
from_secret: dockerhub-token
|
|
|
|
|
commands:
|
|
|
|
|
- apk add --no-cache skopeo
|
|
|
|
|
- 'skopeo copy --src-creds "viktorbarzin:$DOCKERHUB_TOKEN" --dest-creds "viktorbarzin:$DOCKERHUB_TOKEN" "docker://docker.io/viktorbarzin/realestatecrawler:build-${DRONE_BUILD_NUMBER}" "docker://docker.io/viktorbarzin/realestatecrawler:${DRONE_BUILD_NUMBER}"'
|
|
|
|
|
- 'skopeo copy --src-creds "viktorbarzin:$DOCKERHUB_TOKEN" --dest-creds "viktorbarzin:$DOCKERHUB_TOKEN" "docker://docker.io/viktorbarzin/realestatecrawler:build-${DRONE_BUILD_NUMBER}" "docker://docker.io/viktorbarzin/realestatecrawler:latest"'
|
|
|
|
|
- 'skopeo copy --src-creds "viktorbarzin:$DOCKERHUB_TOKEN" --dest-creds "viktorbarzin:$DOCKERHUB_TOKEN" "docker://docker.io/viktorbarzin/realestatecrawler:build-${DRONE_BUILD_NUMBER}" "docker://docker.io/viktorbarzin/realestatecrawler:builder"'
|
2026-02-01 21:53:18 +00:00
|
|
|
|
2025-06-17 18:56:52 +00:00
|
|
|
- name: Update deployment
|
|
|
|
|
image: alpine
|
2026-02-21 21:26:44 +00:00
|
|
|
depends_on:
|
|
|
|
|
- publish-api-image
|
2025-06-17 18:56:52 +00:00
|
|
|
commands:
|
2026-02-22 19:21:56 +00:00
|
|
|
- apk add --no-cache curl jq
|
|
|
|
|
- |
|
|
|
|
|
TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
|
|
|
|
|
IMAGE="viktorbarzin/realestatecrawler:${DRONE_BUILD_NUMBER}"
|
|
|
|
|
RESTART_AT=$(date -u +%Y-%m-%dT%H:%M:%SZ)
|
|
|
|
|
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
|
2026-02-22 19:40:44 +00:00
|
|
|
# Check if deployment is paused and get container name
|
|
|
|
|
STATUS=$(curl -sfk "$API/$DEPLOY" \
|
2026-02-22 19:21:56 +00:00
|
|
|
-H "Authorization: Bearer $TOKEN" \
|
2026-02-22 19:40:44 +00:00
|
|
|
-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..."
|
2026-02-22 19:21:56 +00:00
|
|
|
|
2026-02-22 19:40:44 +00:00
|
|
|
# Strategic merge: update image, set restartedAt, ensure not paused
|
2026-02-22 19:21:56 +00:00
|
|
|
curl -sf -X PATCH "$API/$DEPLOY" \
|
|
|
|
|
-H "Authorization: Bearer $TOKEN" \
|
|
|
|
|
-H "Content-Type: application/strategic-merge-patch+json" \
|
2026-02-22 19:40:44 +00:00
|
|
|
-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"]}'
|
2026-02-22 19:21:56 +00:00
|
|
|
done
|
2026-02-08 20:28:02 +00:00
|
|
|
|
2026-02-09 23:21:07 +00:00
|
|
|
- name: verify-deploy
|
2026-02-08 20:28:02 +00:00
|
|
|
image: alpine
|
2026-02-21 21:26:44 +00:00
|
|
|
depends_on:
|
|
|
|
|
- Update deployment
|
2026-02-08 20:28:02 +00:00
|
|
|
commands:
|
|
|
|
|
- apk add --no-cache curl jq
|
2026-02-09 23:21:07 +00:00
|
|
|
- |
|
|
|
|
|
TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
|
|
|
|
|
EXPECTED_IMAGE="viktorbarzin/realestatecrawler:${DRONE_BUILD_NUMBER}"
|
|
|
|
|
BASE_API="https://kubernetes:6443/api/v1/namespaces/realestate-crawler/pods"
|
2026-02-22 18:35:20 +00:00
|
|
|
DEPLOY_API="https://kubernetes:6443/apis/apps/v1/namespaces/realestate-crawler/deployments"
|
2026-02-09 23:21:07 +00:00
|
|
|
|
2026-02-08 20:28:02 +00:00
|
|
|
for DEPLOY in realestate-crawler-api realestate-crawler-celery realestate-crawler-celery-beat; do
|
2026-02-09 23:21:07 +00:00
|
|
|
echo "Verifying $DEPLOY..."
|
2026-02-10 21:32:11 +00:00
|
|
|
PODS_API="$BASE_API?labelSelector=app%3D$DEPLOY"
|
2026-02-22 19:40:44 +00:00
|
|
|
RS_API="https://kubernetes:6443/apis/apps/v1/namespaces/realestate-crawler/replicasets?labelSelector=app%3D$DEPLOY"
|
2026-02-09 23:21:07 +00:00
|
|
|
|
2026-02-22 19:40:44 +00:00
|
|
|
# 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" \
|
2026-02-22 18:35:20 +00:00
|
|
|
-H "Authorization: Bearer $TOKEN" \
|
|
|
|
|
-H "Accept: application/json" | \
|
2026-02-22 19:40:44 +00:00
|
|
|
jq -r '.items[] | " \(.metadata.name) desired=\(.spec.replicas) ready=\(.status.readyReplicas // 0) image=\(.spec.template.spec.containers[0].image)"' 2>/dev/null || echo " (none)"
|
2026-02-22 18:35:20 +00:00
|
|
|
|
2026-02-09 23:21:07 +00:00
|
|
|
FOUND=0
|
2026-02-08 20:28:02 +00:00
|
|
|
for i in $(seq 1 60); do
|
2026-02-22 17:52:32 +00:00
|
|
|
RAW=$(curl -sfk "$PODS_API" \
|
2026-02-09 23:21:07 +00:00
|
|
|
-H "Authorization: Bearer $TOKEN" \
|
2026-02-22 17:52:32 +00:00
|
|
|
-H "Accept: application/json")
|
|
|
|
|
|
2026-02-22 18:35:20 +00:00
|
|
|
# Debug: show all pod images and status periodically
|
|
|
|
|
if [ "$i" -eq 1 ] || [ "$i" -eq 10 ] || [ "$i" -eq 30 ]; then
|
|
|
|
|
echo " DEBUG (attempt $i): All pods for $DEPLOY:"
|
|
|
|
|
echo "$RAW" | jq -r '[.items[] | {
|
|
|
|
|
name: .metadata.name,
|
|
|
|
|
image: .spec.containers[0].image,
|
|
|
|
|
ready: ([.status.containerStatuses[]? | .ready] | first // "unknown"),
|
|
|
|
|
phase: .status.phase,
|
|
|
|
|
restarts: ([.status.containerStatuses[]? | .restartCount] | first // 0),
|
|
|
|
|
reason: ([.status.containerStatuses[]? | .state | to_entries[] | .value.reason // empty] | first // "running")
|
|
|
|
|
}] | .[] | " \(.name) image=\(.image) ready=\(.ready) phase=\(.phase) restarts=\(.restarts) reason=\(.reason)"' 2>/dev/null || echo " (no pods or parse error)"
|
2026-02-22 17:52:32 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
RESULT=$(echo "$RAW" | \
|
2026-02-09 23:21:07 +00:00
|
|
|
jq --arg img "$EXPECTED_IMAGE" '[.items[] | select(
|
|
|
|
|
(.status.containerStatuses[]? | .ready == true) and
|
2026-02-22 17:52:32 +00:00
|
|
|
(.spec.containers[]? | .image | endswith($img))
|
|
|
|
|
) | {name: .metadata.name, image: .spec.containers[0].image, started: .status.startTime}]')
|
2026-02-09 23:21:07 +00:00
|
|
|
|
2026-02-10 21:32:11 +00:00
|
|
|
COUNT=$(echo "$RESULT" | jq 'length' 2>/dev/null || echo 0)
|
2026-02-22 17:52:32 +00:00
|
|
|
echo " Attempt $i/60: $COUNT pod(s) ready with image matching $EXPECTED_IMAGE"
|
2026-02-09 23:21:07 +00:00
|
|
|
|
2026-02-10 21:32:11 +00:00
|
|
|
if [ "$COUNT" -gt 0 ] 2>/dev/null; then
|
2026-02-22 17:52:32 +00:00
|
|
|
echo "$RESULT" | jq -r '.[] | " \(.name) image=\(.image) started=\(.started)"'
|
2026-02-09 23:21:07 +00:00
|
|
|
echo "$DEPLOY is live!"
|
|
|
|
|
FOUND=1
|
|
|
|
|
break
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
sleep 5
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
if [ "$FOUND" -ne 1 ]; then
|
2026-02-22 18:35:20 +00:00
|
|
|
echo " FINAL DEBUG: All pods for $DEPLOY:"
|
|
|
|
|
echo "$RAW" | jq -r '[.items[] | {
|
|
|
|
|
name: .metadata.name,
|
|
|
|
|
image: .spec.containers[0].image,
|
|
|
|
|
ready: ([.status.containerStatuses[]? | .ready] | first // "unknown"),
|
|
|
|
|
phase: .status.phase,
|
|
|
|
|
restarts: ([.status.containerStatuses[]? | .restartCount] | first // 0),
|
|
|
|
|
reason: ([.status.containerStatuses[]? | .state | to_entries[] | .value.reason // empty] | first // "running")
|
|
|
|
|
}] | .[] | " \(.name) image=\(.image) ready=\(.ready) phase=\(.phase) restarts=\(.restarts) reason=\(.reason)"' 2>/dev/null || echo " (no pods or parse error)"
|
2026-02-09 23:21:07 +00:00
|
|
|
echo "ERROR: No new ready pod for $DEPLOY with image $EXPECTED_IMAGE appeared within 5 minutes"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
2026-02-08 20:28:02 +00:00
|
|
|
done
|