Kubernetes and Cloud Native Associate (KCNA)Kubernetes FundamentalsEasy

A developer needs to create a Kubernetes object that will run a containerized application, ensuring that the application scales automatically based on CPU utilization. Which Kubernetes object is most appropriate for this requirement?

  1. AReplicaSet
  2. BDeployment
  3. CPod
  4. DHorizontalPodAutoscaler
Show answer & explanation

Correct answer: D. HorizontalPodAutoscaler

A HorizontalPodAutoscaler (HPA) automatically scales the number of Pods in a Deployment or ReplicaSet based on observed CPU utilization or other custom metrics. This directly addresses the requirement for automatic scaling based on CPU.

Why the other options are wrong

  • A. A ReplicaSet ensures a specified number of Pod replicas are running at all times, but it does not perform automatic scaling based on resource metrics.
  • B. A Deployment manages stateless applications and ensures a desired number of Pods are running, but it doesn't automatically scale based on metrics.
  • C. A Pod is the smallest deployable unit in Kubernetes but does not provide automatic scaling capabilities on its own.

HorizontalPodAutoscaler (HPA)

A Kubernetes API resource that automatically scales the number of Pod replicas in a Deployment or ReplicaSet based on observed CPU utilization or other select metrics.

  • Automatically adjusts Pod count.
  • Targets Deployments or ReplicaSets.
  • Uses CPU utilization or custom metrics.

Memory trick: HPA: 'How Pods Auto-scale'

More Kubernetes Fundamentals questions