Compare commits
13 Commits
78275ea481
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 7877298c2a | |||
| ea5f129de3 | |||
| 2bf5debbfd | |||
| 424a82aaaa | |||
| 0b630929fc | |||
| 430f0d22e4 | |||
| 30a2dc2e20 | |||
| c99dbffa5a | |||
| 260ad28e7f | |||
| 32a7369881 | |||
| 706fed5961 | |||
| 6fc589e871 | |||
| e5ed302b4d |
13
Dockerfile
Normal file
13
Dockerfile
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
FROM python:3.12-slim
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY requirements.txt .
|
||||||
|
|
||||||
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
|
COPY app/ ./app/
|
||||||
|
|
||||||
|
EXPOSE 8000
|
||||||
|
|
||||||
|
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||||
24
app/main.py
Normal file
24
app/main.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
from fastapi import FastAPI
|
||||||
|
from fastapi.responses import JSONResponse
|
||||||
|
|
||||||
|
app = FastAPI()
|
||||||
|
|
||||||
|
_healthy = True
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/")
|
||||||
|
def root():
|
||||||
|
return {"message": "Pozdrav svijete"}
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/health")
|
||||||
|
def health():
|
||||||
|
if not _healthy:
|
||||||
|
return {"status": "unhealthy"}, 503
|
||||||
|
return {"status": "ok"}
|
||||||
|
|
||||||
|
@app.post("/break")
|
||||||
|
def break_health():
|
||||||
|
global _healthy
|
||||||
|
_healthy = False
|
||||||
|
return {"message": "Servis je sada nezdrav - ocekuj restart"}
|
||||||
@@ -4,7 +4,7 @@ metadata:
|
|||||||
name: moj-servis
|
name: moj-servis
|
||||||
namespace: student-leonarda11
|
namespace: student-leonarda11
|
||||||
spec:
|
spec:
|
||||||
replicas: 1
|
replicas: 4
|
||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
app: moj-servis
|
app: moj-servis
|
||||||
@@ -15,27 +15,50 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: moj-servis
|
- name: moj-servis
|
||||||
image: git.fpmoz.sum.ba/leonarda11/moj-servis:1.0
|
image: git.fpmoz.sum.ba/leonarda11/moj-servis:1.2
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 8000
|
- containerPort: 8000
|
||||||
envFrom: # <-- NOVO
|
|
||||||
|
# ── Liveness
|
||||||
|
livenessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /health
|
||||||
|
port: 8000
|
||||||
|
initialDelaySeconds: 10
|
||||||
|
periodSeconds: 15
|
||||||
|
timeoutSeconds: 3
|
||||||
|
failureThreshold: 3
|
||||||
|
|
||||||
|
# ── Readiness
|
||||||
|
readinessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /health
|
||||||
|
port: 8000
|
||||||
|
initialDelaySeconds: 5
|
||||||
|
periodSeconds: 10
|
||||||
|
timeoutSeconds: 2
|
||||||
|
failureThreshold: 2
|
||||||
|
|
||||||
|
envFrom:
|
||||||
- configMapRef:
|
- configMapRef:
|
||||||
name: moj-servis-config # <-- ConfigMap
|
name: moj-servis-config
|
||||||
env: # <-- NOVO
|
|
||||||
|
env:
|
||||||
- name: DB_PASSWORD
|
- name: DB_PASSWORD
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: moj-servis-secret # <-- Secret
|
name: moj-servis-secret
|
||||||
key: DB_PASSWORD
|
key: DB_PASSWORD
|
||||||
- name: API_KEY
|
- name: API_KEY
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: moj-servis-secret
|
name: moj-servis-secret
|
||||||
key: API_KEY
|
key: API_KEY
|
||||||
|
|
||||||
resources:
|
resources:
|
||||||
requests:
|
requests:
|
||||||
memory: "64Mi"
|
|
||||||
cpu: "50m"
|
|
||||||
limits:
|
|
||||||
memory: "128Mi"
|
memory: "128Mi"
|
||||||
cpu: "200m"
|
cpu: "150m"
|
||||||
|
limits:
|
||||||
|
memory: "256Mi"
|
||||||
|
cpu: "500m"
|
||||||
@@ -4,16 +4,18 @@ metadata:
|
|||||||
name: moj-servis-ingress
|
name: moj-servis-ingress
|
||||||
namespace: student-leonarda11
|
namespace: student-leonarda11
|
||||||
annotations:
|
annotations:
|
||||||
traefik.ingress.kubernetes.io/router.entrypoints: web
|
traefik.ingress.kubernetes.io/router.entrypoints: web,websecure
|
||||||
|
traefik.ingress.kubernetes.io/router.tls: "true"
|
||||||
spec:
|
spec:
|
||||||
|
ingressClassName: traefik
|
||||||
rules:
|
rules:
|
||||||
- host: leonarda11.argocd.fpmoz.sum.ba
|
- host: moj-servis-leonarda11.argocd.fpmoz.sum.ba
|
||||||
http:
|
http:
|
||||||
paths:
|
paths:
|
||||||
- path: /
|
- path: /
|
||||||
pathType: Prefix
|
pathType: Prefix
|
||||||
backend:
|
backend:
|
||||||
service:
|
service:
|
||||||
name: moj-servis-svc
|
name: moj-servis-svc
|
||||||
port:
|
port:
|
||||||
number: 80
|
number: 80
|
||||||
@@ -10,4 +10,4 @@ spec:
|
|||||||
- port: 80
|
- port: 80
|
||||||
targetPort: 8000
|
targetPort: 8000
|
||||||
protocol: TCP
|
protocol: TCP
|
||||||
type: NodePort
|
type: ClusterIP
|
||||||
|
|||||||
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fastapi==0.111.0
|
||||||
|
uvicorn[standard]==0.29.0
|
||||||
Reference in New Issue
Block a user