Compare commits
11 Commits
6fc589e871
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 7877298c2a | |||
| ea5f129de3 | |||
| 2bf5debbfd | |||
| 424a82aaaa | |||
| 0b630929fc | |||
| 430f0d22e4 | |||
| 30a2dc2e20 | |||
| c99dbffa5a | |||
| 260ad28e7f | |||
| 32a7369881 | |||
| 706fed5961 |
15
app/main.py
15
app/main.py
@@ -1,11 +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():
|
||||
return {"status": "ok"}
|
||||
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
|
||||
namespace: student-leonarda11
|
||||
spec:
|
||||
replicas: 1
|
||||
replicas: 4
|
||||
selector:
|
||||
matchLabels:
|
||||
app: moj-servis
|
||||
@@ -15,27 +15,50 @@ spec:
|
||||
spec:
|
||||
containers:
|
||||
- name: moj-servis
|
||||
image: git.fpmoz.sum.ba/leonarda11/moj-servis:1.0
|
||||
image: git.fpmoz.sum.ba/leonarda11/moj-servis:1.2
|
||||
ports:
|
||||
- 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:
|
||||
name: moj-servis-config # <-- ConfigMap
|
||||
env: # <-- NOVO
|
||||
name: moj-servis-config
|
||||
|
||||
env:
|
||||
- name: DB_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: moj-servis-secret # <-- Secret
|
||||
name: moj-servis-secret
|
||||
key: DB_PASSWORD
|
||||
- name: API_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: moj-servis-secret
|
||||
key: API_KEY
|
||||
|
||||
resources:
|
||||
requests:
|
||||
memory: "64Mi"
|
||||
cpu: "50m"
|
||||
limits:
|
||||
memory: "128Mi"
|
||||
cpu: "200m"
|
||||
cpu: "150m"
|
||||
limits:
|
||||
memory: "256Mi"
|
||||
cpu: "500m"
|
||||
@@ -4,16 +4,18 @@ metadata:
|
||||
name: moj-servis-ingress
|
||||
namespace: student-leonarda11
|
||||
annotations:
|
||||
traefik.ingress.kubernetes.io/router.entrypoints: web
|
||||
traefik.ingress.kubernetes.io/router.entrypoints: web,websecure
|
||||
traefik.ingress.kubernetes.io/router.tls: "true"
|
||||
spec:
|
||||
ingressClassName: traefik
|
||||
rules:
|
||||
- host: leonarda11.argocd.fpmoz.sum.ba
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: moj-servis-svc
|
||||
port:
|
||||
number: 80
|
||||
- host: moj-servis-leonarda11.argocd.fpmoz.sum.ba
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: moj-servis-svc
|
||||
port:
|
||||
number: 80
|
||||
@@ -10,4 +10,4 @@ spec:
|
||||
- port: 80
|
||||
targetPort: 8000
|
||||
protocol: TCP
|
||||
type: NodePort
|
||||
type: ClusterIP
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: moj-servis-config
|
||||
namespace: student-leonarda11
|
||||
data:
|
||||
SERVICE_NAME: "moj-servis"
|
||||
LOG_LEVEL: "info"
|
||||
WELCOME_MSG: "Pozdrav iz FPMOZ k3s clustera!"
|
||||
@@ -1,64 +0,0 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: moj-servis
|
||||
namespace: student-leonarda11
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: moj-servis
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: moj-servis
|
||||
spec:
|
||||
containers:
|
||||
- name: moj-servis
|
||||
image: git.fpmoz.sum.ba/leonarda11/moj-servis:1.0
|
||||
ports:
|
||||
- containerPort: 8000
|
||||
|
||||
# ── 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:
|
||||
name: moj-servis-config
|
||||
|
||||
env:
|
||||
- name: DB_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: moj-servis-secret
|
||||
key: DB_PASSWORD
|
||||
- name: API_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: moj-servis-secret
|
||||
key: API_KEY
|
||||
|
||||
resources:
|
||||
requests:
|
||||
memory: "64Mi"
|
||||
cpu: "50m"
|
||||
limits:
|
||||
memory: "128Mi"
|
||||
cpu: "200m"
|
||||
@@ -1,19 +0,0 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: moj-servis-ingress
|
||||
namespace: student-leonarda11
|
||||
annotations:
|
||||
traefik.ingress.kubernetes.io/router.entrypoints: web
|
||||
spec:
|
||||
rules:
|
||||
- host: leonarda11.argocd.fpmoz.sum.ba
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: moj-servis-svc
|
||||
port:
|
||||
number: 80
|
||||
@@ -1,13 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: moj-servis-svc
|
||||
namespace: student-leonarda11
|
||||
spec:
|
||||
selector:
|
||||
app: moj-servis
|
||||
ports:
|
||||
- port: 80
|
||||
targetPort: 8000
|
||||
protocol: TCP
|
||||
type: NodePort
|
||||
Reference in New Issue
Block a user