This repository contains a Wiki application service (wiki-service) and a Helm chart (wiki-chart) to deploy the service on Kubernetes. The repository also includes a containerized setup for running a local k3d Kubernetes cluster.
- Repository Structure
- Prerequisites
- Local Development (wiki-service)
- Container Image for k3d + Tooling
- Deploy to Kubernetes with Helm
- Configuration
- Monitoring
- Cleanup
- Notes
kubernetes-wiki-master/
├── Dockerfile # Image that installs k3d, kubectl, and Helm
├── start.sh # Entrypoint script for the k3d environment
├── wiki-chart/ # Helm chart for deploying wiki-service
│ ├── Chart.yaml
│ ├── values.yaml
│ └── templates/
│ ├── deployment.yaml
│ ├── service.yaml
│ ├── ingress.yaml
│ ├── prometheus-deployment.yaml
│ ├── grafana-deployment.yaml
│ ├── pvc.yaml
│ ├── hpa.yaml
│ └── serviceaccount.yaml
└── wiki-service/ # FastAPI-based Wiki microservice
├── Dockerfile # Dockerfile for wiki-service
├── app/
│ ├── main.py
│ ├── database.py
│ ├── models.py
│ ├── schemas.py
│ └── metrics.py
├── pyproject.toml
├── uv.lock
├── start.sh
└── README.md
- Docker (latest version)
- Python 3.11+ (optional, for local development)
- kubectl (configured)
- Helm v3+
- k3d, kind, or minikube (for local clusters)
-
Navigate to the service directory:
cd wiki-service -
Create and activate a virtual environment:
python -m venv .venv source .venv/bin/activate -
Install dependencies:
pip install fastapi sqlalchemy aiosqlite prometheus-client pydantic uvicorn
-
Start the application:
uvicorn app.main:app --host 0.0.0.0 --port 8000
-
Access the endpoints:
- Swagger UI: http://localhost:8000/docs
- Metrics: http://localhost:8000/metrics
-
Build the Docker image using the provided Dockerfile:
docker build -t wiki-service:latest ./wiki-service
-
Run the container:
docker run --rm -p 8000:8000 wiki-service:latest
-
Test locally:
curl http://localhost:8000/ curl http://localhost:8000/metrics
Note: You do not need to use your Docker Hub username or push this image unless deploying to a remote registry. The local
wiki-service:latestimage is sufficient for testing and local clusters.
The root-level Dockerfile builds an environment with Docker-in-Docker, k3d, kubectl, and helm installed. It starts a lightweight single-node Kubernetes cluster.
To build and run it:
docker build -t wiki-k3d:latest .
docker run --privileged -it -p 8000:8000 wiki-k3d:latestThe script start.sh creates a cluster named wiki-cluster and exposes port 8000 on your host.
-
Load the locally built image into your cluster:
For k3d:
k3d image import wiki-service:latest -c wiki-cluster
For kind:
kind load docker-image wiki-service:latest
For minikube:
minikube image load wiki-service:latest
-
Update the Helm chart to use the local image:
image: repository: wiki-service tag: latest pullPolicy: IfNotPresent
-
Deploy the service using Helm:
cd wiki-chart helm install wiki-release . --namespace wiki --create-namespace
-
Check the status:
kubectl get pods,svc -n wiki
-
Access the service:
kubectl port-forward svc/wiki 8000:8000 -n wiki
Visit http://localhost:8000
Edit wiki-chart/values.yaml to customize:
- Replica count
- Image details (repository, tag, pullPolicy)
- Resource limits
- Service type (ClusterIP, NodePort, LoadBalancer)
- Ingress hostname
- Monitoring settings for Prometheus/Grafana
Apply changes:
helm upgrade wiki-release . -n wikiwiki-service exposes Prometheus metrics at /metrics.
To enable integrated monitoring (Prometheus + Grafana) in Helm:
helm upgrade wiki-release . -n wiki --set prometheus.enabled=true --set grafana.enabled=trueAccess Grafana:
kubectl port-forward svc/grafana 3000:3000 -n wikiThen open http://localhost:3000
Remove all resources:
helm uninstall wiki-release -n wiki
kubectl delete namespace wikiRemove local Docker images:
docker image rm wiki-service:latest wiki-k3d:latest- The
wiki-serviceuses SQLite by default. You can modifyapp/database.pyfor PostgreSQL or MySQL. - No Docker Hub username is required for local builds.
- The root
Dockerfileprovides a fullk3dKubernetes environment and is optional for deployment.