Posts

Showing posts from July 3, 2025

Simple FastAPI App with Docker and Minikube

 Let's start with the simplest one. Which we can develop and test in our local system or laptop, or Mac. ✅ Simple FastAPI App with Docker and Minikube (Kubernetes) 📁 Folder Structure fastapi-k8s-demo/ ├── app/ │ └── main.py ├── Dockerfile ├── requirements.txt ├── k8s/ │ ├── deployment.yaml │ └── service.yaml 📄 app/main.py from fastapi import FastAPI app = FastAPI() @app.get("/") def read_root(): return {"message": "Hello from FastAPI on Kubernetes!"} 📄 requirements.txt fastapi uvicorn 📄 Dockerfile FROM python:3.11-slim WORKDIR /app COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY app/ . CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"] 📄 k8s/deployment.yaml apiVersion: apps/v1 kind: Deployment metadata: name: fastapi-deployment spec: replicas: 1 selector: matchLabels: app: fastapi template: metadata: ...