Challenge your understanding of Kubernetes autoscaling with this focused quiz on Horizontal Pod Autoscaler (HPA), Vertical Pod Autoscaler (VPA), and Cluster Autoscaler concepts, best practices, and scenarios for optimized resource management in cloud-native environments.
Which Kubernetes resource is responsible for automatically scaling the number of pod replicas based on observed CPU utilization, such as increasing deployment size during traffic spikes?
Explanation: The Horizontal Pod Autoscaler automatically adjusts the number of pod replicas in response to metrics like CPU or memory utilization, making it ideal for handling fluctuating workloads. The Vertical Pod Autoscaler adjusts pod resource requests and limits but does not change replica counts. PodDisruptionBudget controls pod evictions, not scaling. ReplicaSet ensures a specified number of pod replicas but does not scale them automatically based on metrics.
When using Vertical Pod Autoscaler in Kubernetes, which aspect of a pod's configuration can VPA automatically modify to optimize resource utilization?
Explanation: Vertical Pod Autoscaler is designed to automatically adjust the CPU and memory requests and limits for containers to match the application's real resource consumption. Service account tokens are managed by the control plane, and are not optimized by VPA. Pod labels are used for selection and organization, not for resource allocation. Persistent volume claims manage storage, not compute resources.
In a scenario where pending pods cannot be scheduled due to insufficient node resources, which autoscaling mechanism is responsible for dynamically increasing the number of nodes in a Kubernetes cluster?
Explanation: Cluster Autoscaler automatically adjusts the number of nodes in a cluster, adding nodes when pods cannot be scheduled due to lack of resources. The Endpoint Controller manages endpoints for services and is not related to scaling nodes. Horizontal Pod Autoscaler deals with adjusting pod replica counts, not cluster size. The Volume Expansion Controller manages storage resizing, unrelated to node scaling.
Which of the following metrics can be used by the Horizontal Pod Autoscaler to determine when to scale pods, assuming proper configuration?
Explanation: Horizontal Pod Autoscaler supports scaling based on standard resource metrics like CPU and memory and can use custom metrics exposed via the metrics API, such as request rates or application-specific signals. Pod affinity rules influence scheduling, not scaling. Node selector annotations help place pods on specific nodes but do not impact scaling decisions. Network policies manage connectivity and have no effect on autoscaling behavior.
If both HPA and VPA are enabled for the same deployment, what is the recommended approach to avoid unpredictable resource allocation behaviors?
Explanation: Running HPA on resource utilization while setting VPA to 'Off' or 'Recommendation' mode prevents overlapping resource changes and avoids conflicts, as both would otherwise try to adjust requests independently. Allowing both to modify resources can lead to erratic scaling. Disabling monitoring is not recommended, as it removes visibility into system health. The ReplicaSet controller manages replica consistency, not dynamic resource scaling.