Sign inSign up free

109. Autoscale a Deployment on CPU

easy 10 XP ~6 minHands-on lab100% acceptance

Traffic to dispatcher in namespace orders doubles every weekday afternoon, and someone has been scaling it by hand. Let Kubernetes do it.

Task

  • Create a HorizontalPodAutoscaler named dispatcher in namespace orders that scales Deployment dispatcher.
  • It keeps between 3 and 10 replicas and targets an average CPU utilization of 60%.
  • The app container of dispatcher requests 250m CPU, so that utilization can be computed.
  • The autoscaler invoice-pdf that already exists in the namespace is not changed.

A practice cluster is running on this machine: start with kubectl get deploy,hpa -n orders.

About this machine

Ubuntu 24.04 with a private practice cluster: a real Kubernetes API server, scheduler and controllers, and three nodes (controlplane, node01, node02). Containers run in a lightweight runtime: their commands, kubectl logs, exec and run -it work, and Pods reach Services by name with wget or curl. Images never download, and port-forward isn't available. k is an alias for kubectl, with completion. The grader checks the cluster's final state, not the commands you typed.

Part of Prepare for the CKAD. Next step: Pass a Secret as Environment Variables

Teaching or writing about this? Embed this lab on your page

TerminalNot started

Your machine is ready to start

A fresh machine with its own Kubernetes cluster starts in about half a minute, with the task already set up.

No account needed: 3 of 3 free tries left. Guest machines last 30 minutes.