A lightweight, production-ready REST API built with Go, containerised with Docker, and orchestrated via Kubernetes.
This project demonstrates the transition from traditional heavy runtime environments (like Python/Java) to efficient, statically linked infrastructure suitable for high-performance platform engineering.
- Concurrency: Utilises the
net/httpstandard library andchirouter for low-latency request handling. - Static Linking: The app compiles to a single binary, eliminating the need for a heavy OS runtime in production.
- Type Safety: Uses interfaces (
products.Service) to decouple the handler from the business logic, making the system testable and modular.
I utilised a Multi-Stage Build in the Dockerfile.
- Stage 1 (Builder): Compiles the code using the full Golang toolchain.
- Stage 2 (Runtime): Copies only the binary into a
gcr.io/distroless/staticimage. - Result: The final image is ~10MB (vs ~800MB for a standard Python image), massively reducing security risks and deployment time.
The k8s/deployment.yaml configuration ensures:
- High Availability:
replicas: 3ensures the service can handle node failures without downtime. - Self-Healing: A
livenessProbechecks the/health endpoint; if the app hangs, Kubernetes automatically restarts the pod. - Resource Quotas: CPU/Memory limits prevent resource issues on the cluster.
- Docker
- Minikube (Kubernetes)
docker build -t go-ecommerce:latest .# Apply the Deployment and Service
kubectl apply -f k8s/deployment.yaml
kubectl apply -f k8s/service.yaml
# Verify the Pods are running
kubectl get podsForward the port to your local machine to test:
kubectl port-forward svc/go-ecommerce-svc 8080:80Visit http://localhost:8080/products to see the JSON response.
cmd/: Entry points for the application.internal/: Private application code (Handlers, Services).kubernetes/: Infrastructure as Code (IaC) manifests.