Service Configuration
medium

Questão de Service Configuration #019e3a4f

Enunciado da Questão
Service Configuration
#kubernetes
#autoscaling
#hpa
#pod
#resources
Médio

Which mechanism can be used to automatically adjust the amount of resources for an application?

A

Horizontal Pod Autoscaler (HPA)

Correta
B

Kubernetes Event-driven Autoscaling (KEDA)

C

Cluster Autoscaler

D

Vertical Pod Autoscaler (VPA)

Explicação Oficial / Explicações da Comunidade

The Horizontal Pod Autoscaler (HPA) is the correct mechanism for automatically adjusting the amount of resources (specifically the number of pod replicas) for an application in Kubernetes. HPA scales the number of pods in a replication controller, deployment, or replica set based on observed CPU utilization (or other custom metrics). It works by periodically querying the metrics server for resource usage and adjusting the replica count to meet the target utilization defined in the HPA configuration.

How it Works

HPA is implemented as a Kubernetes API resource and a controller. The controller manager runs a loop that checks the metrics (e.g., CPU, memory, or custom metrics) against the target value. If the current utilization deviates from the target, the controller adjusts the number of replicas accordingly. The formula used is desiredReplicas = ceil[currentReplicas * (currentMetricValue / desiredMetricValue)]. HPA requires the Metrics Server to be deployed in the cluster.

Why the Correct Value is Right

The Horizontal Pod Autoscaler (HPA) directly addresses the question by automatically scaling the number of pod replicas based on resource usage. It is the standard Kubernetes mechanism for horizontal scaling, ensuring applications have enough resources to handle load while avoiding over-provisioning.

Why the Incorrect Values are Wrong

  • Kubernetes Event-driven Autoscaling (KEDA) is an extension that allows autoscaling based on events from external sources (e.g., message queue length, custom metrics). While it can also adjust resources, it is not the primary built-in mechanism; it is an add-on that works alongside HPA. The question asks for a mechanism that can be used, and HPA is the native, built-in solution.
  • Cluster Autoscaler adjusts the number of nodes in the cluster, not the resources for an application. It scales the infrastructure layer, not the application pods themselves.
  • Vertical Pod Autoscaler (VPA) adjusts the resource requests and limits (CPU/memory) of existing pods, not the number of replicas. It changes the resource allocation per pod, whereas the question asks about adjusting the amount of resources for an application, which typically refers to horizontal scaling (number of replicas).