This project is designed as a playground for learning and building cloud projects using Kubernetes and microservices. It provides the code for basic APIs written in Python, with Docker images hosted on Dockerhub. The project includes Horizontal Pod Autoscaling, which can be tested using stress tests written with Locust. The deployment can be done on local environments like Minikube or cloud platforms like Azure AKS or GCP GKE, AWS EKS, etc.
- Docker
- Kubernetes (Minikube or a cloud provider like Azure Kubernetes Service)
- kubectl
- Locust (for stress testing)
The Docker images for the services are available on Dockerhub:
-
Start Minikube:
minikube start
-
Deploy MySQL:
kubectl apply -f manifests/mysql-storageclass.yaml kubectl apply -f manifests/mysql-pv.yaml kubectl apply -f manifests/mysql-pvc.yaml kubectl apply -f manifests/mysql-deployment.yaml kubectl apply -f manifests/mysql-service.yaml
-
Deploy Barcode Service:
kubectl apply -f manifests/barcode-deployment.yaml
-
Deploy Catalog Service:
kubectl apply -f manifests/catalog-deployment.yaml
-
Deploy CDN Service:
kubectl apply -f manifests/cdn-deployment.yaml kubectl apply -f manifests/cdn-service.yaml
-
Access Services: Use
minikube service <service-name>
to access the services. Example:minikube service cdn-service
-
Create an AKS cluster:
az aks create -g <resource-group> -n <cluster-name> --node-count 1 --enable-addons monitoring --generate-ssh-keys
-
Get AKS credentials:
az aks get-credentials -g <resource-group> -n <cluster-name>
-
Deploy MySQL:
kubectl apply -f manifests/mysql-storageclass.yaml kubectl apply -f manifests/mysql-pv.yaml kubectl apply -f manifests/mysql-pvc.yaml kubectl apply -f manifests/mysql-deployment.yaml kubectl apply -f manifests/mysql-service.yaml
-
Deploy Barcode, Catalog, and CDN Services:
kubectl apply -f manifests/barcode-deployment.yaml kubectl apply -f manifests/catalog-deployment.yaml kubectl apply -f manifests/cdn-deployment.yaml kubectl apply -f manifests/cdn-service.yaml
-
Access Services: Use
kubectl get services
to get the external IP addresses for the services.
-
Enable HPA: Ensure that your cluster has the metrics server installed. You can use the following command to deploy the metrics server on Minikube:
minikube addons enable metrics-server
-
Apply HPA configuration:
kubectl apply -f manifests/traffic-generator.yaml
-
Stress Test using Locust:
- Install Locust:
pip install locust
- Run Locust tests:
locust -f catalog/stress_test.py
- Install Locust:
There's plenty of room for production level improvementls (I originally made this for a Uni project), contributions in any form are welcome.