commit 68be13b2e6749b6e9b022499c50458f9b689bf46 Author: GalicIvan Date: Thu Jun 25 02:27:52 2026 +0200 init k2 app diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..5ffe568 Binary files /dev/null and b/.DS_Store differ diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..dd3b7cc --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +__pycache__/ +*.pyc +.env +.git/ +*.md +k8s/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3f98e6f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ +# TODO: napiši Dockerfile +# Base image: python:3.12-slim +# Working dir: /app +# Kopiraj requirements.txt, pip install, zatim kopiraj app/ +# EXPOSE 8000 +# CMD uvicorn app.main:app --host 0.0.0.0 --port 8000 diff --git a/app/main.py b/app/main.py new file mode 100644 index 0000000..ec91e58 --- /dev/null +++ b/app/main.py @@ -0,0 +1,14 @@ +import os +from fastapi import FastAPI + +app = FastAPI() + +AUTOR = os.getenv("AUTOR", "GalicIvan") + +@app.get("/") +def root(): + return {"message": "Kolokvij 2", "autor": AUTOR} + +@app.get("/health") +def health(): + return {"status": "ok"} diff --git a/k8s/deployment.yaml b/k8s/deployment.yaml new file mode 100644 index 0000000..6e8343e --- /dev/null +++ b/k8s/deployment.yaml @@ -0,0 +1,35 @@ +# TODO: napiši Deployment +# Ime: k2-app | Namespace: kolokvij2-IME-PREZIME +# Replicas: 2 | Image: git.fpmoz.sum.ba/IME-PREZIME/k2-app:1.0 +# containerPort: 8000 | env AUTOR=IME-PREZIME + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: k2-app + namespace: kolokvij2-ivan-galic +spec: + replicas: 2 + selector: + matchLabels: + app: k2-app + template: + metadata: + labels: + app: 2-appk + spec: + containers: + - name: k2-app + image: git.fpmoz.sum.ba/galicivan/k2-app:1.0 + ports: + - containerPort: 8000 + env: + - name: AUTOR + value: "galicivan" + resources: + requests: + memory: "64Mi" + cpu: "50m" + limits: + memory: "128Mi" + cpu: "200m" \ No newline at end of file diff --git a/k8s/ingress.yaml b/k8s/ingress.yaml new file mode 100644 index 0000000..9237253 --- /dev/null +++ b/k8s/ingress.yaml @@ -0,0 +1,23 @@ +# TODO: napiši Ingress +# Ime: k2-ingress | Namespace: kolokvij2-IME-PREZIME +# ingressClassName: traefik +# Host: IME-PREZIME.argocd.fpmoz.sum.ba -> k2-svc:80 + +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: k2-ingress + namespace: kolokvij2-ivan-galic +spec: + ingressClassName: traefik + rules: + - host: galicivan.argocd.fpmoz.sum.ba + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: k2-svc # mora odgovarati service.yaml + port: + number: 80 # port Servicea (ne containera!) \ No newline at end of file diff --git a/k8s/service.yaml b/k8s/service.yaml new file mode 100644 index 0000000..5d2f0c5 --- /dev/null +++ b/k8s/service.yaml @@ -0,0 +1,17 @@ +# TODO: napiši Service +# Ime: k2-svc | Namespace: kolokvij2-IME-PREZIME +# Tip: ClusterIP | port: 80 -> targetPort: 8000 + +apiVersion: v1 +kind: Service +metadata: + name: k2-svc + namespace: kolokvij2-ivan-galic +spec: + selector: + app: k2-app # spaja Service s Podovima koji imaju ovaj label + ports: + - port: 80 # port koji Service eksponira (Ingress ce slati ovdje) + targetPort: 8000 # port containera (uvicorn slusa na 8000) + protocol: TCP + type: ClusterIP # samo unutar K8s clustera — Ingress rjesava vanjski pristup \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..c83aa69 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +fastapi==0.111.0 +uvicorn[standard]==0.29.0