git clone https://github.com/pssudo/kubernetes-fastapi.git
cd kubernetes-fastapi
helm install products ./products_helm
kubectl apply -f products_k8s_manifest.yaml
minikube service fastapi-svc
minikube addons enable metrics-server
minikube service fastapi-svc
will expose the service running inside the minikude to localhost- port details will be displayed on the terminal console
- The REST endpoint will be accessible in the browser
- Go to ENDPOINT/docs to get the swagger format of the rest API
- Use the "Try it out" button to test the application
- Use POST and GET methods as per the swagger documentation
- Once new records are created using POST method run the below command to test the load
for i in {1..1000}; do curl -s http://127.0.0.1:63538/products/1234 > /dev/null; done
:::note
- Please change the port number from 63538 to the one which is running in your local
- Change the product id from 1234 to the value you have passed as p_id :::
- While the above load test is running, you can observe the scaling policy (Up & Down are configured on CPU Utilization) using
kubectl describe hpa fastapi-hpa
- Alternatively you can enable the dashboard addon and observe the events
minikube addons enable dashboard
minikube dashboard