5.2 Calculating Pod resources

View in the book. Buy the book.

Adding resource requests and limits.

Deploy this

kubectl apply -f Chapter05/5.2_ResourceUsageTest/deploy.yaml
kubectl create -f Chapter03/3.2_DeployingToKubernetes/service.yaml

Get the external IP

kubectl get svc
EXTERNAL_IP=203.0.113.16

Install Apache

sudo apt-get update
sudo apt-get install apache2 -y

Cloud Shell will warn you that the session is ephemeral. That’s OK, it just means you have to repeat this anytime you want to run ab in a new session.

With Apache installed, you can now run the load test

ab -n 10000 -c 20 http://$EXTERNAL_IP/

In another tab, view the usage data:

$ kubectl top pod
NAME                         CPU(cores)   MEMORY(bytes)   
timeserver-dd88988f5-nll5l   1m           11Mi            

The values can be used as a baseline to understand what resources your container needs while under load.