Over the past few weeks, I’ve been diving deep into Kubernetes, exploring how to deploy and manage containerized applications. To really understand the mechanics, I decided to create a small but complete full-stack project: a FastAPI backend with a React frontend running on a local Kubernetes cluster using Kind (Kubernetes in Docker).
Why I Started Experimenting
Kubernetes is powerful but complex, and reading documentation can only take you so far. I wanted to:
- See how Deployments and Services interact in real-time
- Understand how frontend and backend communicate inside a cluster
- Experiment with replicas, scaling, and networking without affecting production
This project became my sandbox for testing Kubernetes concepts and workflows hands-on
How I Set Up the Project
I structured the project into three main areas:
- Backend (FastAPI)
- Runs on Python 3.11, serving API requests on port 80
- Exposed internally with a ClusterIP service
- I’ve experimented with creating endpoints and testing them using pytest
2.Frontend (React + Nginx)
- React app is built statically and served by Nginx
- Exposed externally with a LoadBalancer service
- Configured SPA routing and CORS headers to communicate seamlessly with the backend
- Kubernetes Manifests
- Separate YAML files for backend and frontend
- Each deployment has 2 replicas
- Services use Kubernetes DNS for internal pod communication
My Hands-On Experiments
Here’s what I’ve been tinkering with:
- Creating a Kind Cluster: Spinning up a lightweight Kubernetes environment locally
- Loading Docker Images: Pre-loading backend and frontend images into the cluster with kind load docker-image
- Deploying and Updating: Iteratively modifying endpoints, rebuilding images, and redeploying -Service Discovery: Using Kubernetes DNS for frontend-backend communication instead of hardcoded IPs -Debugging: Inspecting logs, port-forwarding services, and fixing issues like ImagePullBackOff and misconfigured CORS
Through this, I’ve gained a deeper understanding of:
- Replicas and pod distribution
- ClusterIP vs LoadBalancer services
- Internal pod networking
- How environment variables manage API connections
Testing & Local Development
Backend
- Tested with pytest and FastAPI TestClient
- GET / returns a 200 status code with JSON
- Tests run locally with make test
Frontend
- Points to backend API via REACT_APP_API_URL
- Can be tested locally before deploying to Kubernetes
Experimenting with Kubernetes is all about deploying, breaking, fixing, and iterating. Creating a small project like this is the fastest way to understand how everything fits together.
Check out the repo:https://github.com/Copubah/simple-k8s-project
Top comments (0)