Add initial project structure with Dockerfile, Kubernetes manifests, and FastAPI application
This commit is contained in:
6
.dockeringore
Normal file
6
.dockeringore
Normal file
@@ -0,0 +1,6 @@
|
||||
__pycache__/
|
||||
*.pyc
|
||||
.env
|
||||
.git/
|
||||
*.md
|
||||
k8s/
|
||||
18
Dockerfile
Normal file
18
Dockerfile
Normal file
@@ -0,0 +1,18 @@
|
||||
# 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
|
||||
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"]
|
||||
14
app/main.py
Normal file
14
app/main.py
Normal file
@@ -0,0 +1,14 @@
|
||||
import os
|
||||
from fastapi import FastAPI
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
AUTOR = os.getenv("AUTOR", "nepoznat")
|
||||
|
||||
@app.get("/")
|
||||
def root():
|
||||
return {"message": "Kolokvij 2", "autor": AUTOR}
|
||||
|
||||
@app.get("/health")
|
||||
def health():
|
||||
return {"status": "ok"}
|
||||
37
k8s/deployment.yaml
Normal file
37
k8s/deployment.yaml
Normal file
@@ -0,0 +1,37 @@
|
||||
# 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-fsusak03
|
||||
spec:
|
||||
replicas: 2
|
||||
selector:
|
||||
matchLabels:
|
||||
app: k2-app
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: k2-app
|
||||
spec:
|
||||
containers:
|
||||
- name: k2-app
|
||||
image: git.fpmoz.sum.ba/fsusak03/k2-app:1.0
|
||||
ports:
|
||||
- containerPort: 8000
|
||||
env:
|
||||
- name: AUTOR
|
||||
value: "fsusak03"
|
||||
resources:
|
||||
requests:
|
||||
memory: "64Mi"
|
||||
cpu: "50m"
|
||||
limits:
|
||||
memory: "128Mi"
|
||||
cpu: "200m"
|
||||
25
k8s/ingress.yaml
Normal file
25
k8s/ingress.yaml
Normal file
@@ -0,0 +1,25 @@
|
||||
# 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-fsusak03
|
||||
spec:
|
||||
ingressClassName: traefik
|
||||
rules:
|
||||
- host: fsusak03.argocd.fpmoz.sum.ba
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: k2-svc
|
||||
port:
|
||||
number: 80
|
||||
|
||||
18
k8s/service.yaml
Normal file
18
k8s/service.yaml
Normal file
@@ -0,0 +1,18 @@
|
||||
# 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-fsusak03
|
||||
spec:
|
||||
selector:
|
||||
app: k2-app
|
||||
ports:
|
||||
- port: 80
|
||||
targetPort: 8000
|
||||
protocol: TCP
|
||||
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