From 3b466628077b5f763da2534ae0910189cee065d3 Mon Sep 17 00:00:00 2001 From: Marijanela Date: Thu, 30 Apr 2026 17:34:02 +0200 Subject: [PATCH] new version 1.1 --- k8s/deployment.yaml | 2 +- main.py | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/k8s/deployment.yaml b/k8s/deployment.yaml index 6f1a233..5739c2e 100644 --- a/k8s/deployment.yaml +++ b/k8s/deployment.yaml @@ -18,7 +18,7 @@ spec: - name: gitea-creds containers: - name: helloo-cicdd - image: git.fpmoz.sum.ba/Marijanela218/helloo-cicdd:latest + image: git.fpmoz.sum.ba/Marijanela218/helloo-cicdd:1.1 ports: - containerPort: 8000 # ── Liveness: je li proces živ? ───────────────── diff --git a/main.py b/main.py index 22c44f4..1bbde20 100644 --- a/main.py +++ b/main.py @@ -3,16 +3,17 @@ from fastapi import FastAPI import os, datetime app = FastAPI() +_healthy = True @app.get("/health") def health(): - return { - "status": "ok", - "version": os.getenv("APP_VERSION", "dev"), - "timestamp": datetime.datetime.utcnow().isoformat() - } - -@app.get("/") -def root(): - return {"poruka": "Zdravo s k3s!", "host": os.uname().nodename} - + if not _healthy: + return {"status": "unhealthy"}, 503 + return {"status": "ok"} + +@app.post("/break") +def break_health(): + """Simulira pad servisa za testiranje liveness probe-a""" + global _healthy + _healthy = False + return {"message": "Servis je sada nezdrav — ocekuj restart"}