Google Kubernetes Engine: Automatically Scaling Nodes based on CPU Load

Automatically Scaling Nodes based on CPU Load

Question

You want your Google Kubernetes Engine cluster to automatically add or remove nodes based on CPU load.

What should you do?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

A.

The correct answer is A. Configure a HorizontalPodAutoscaler with a target CPU usage. Enable the Cluster Autoscaler from the GCP Console.

Google Kubernetes Engine (GKE) is a managed Kubernetes service that simplifies the deployment and operation of containerized applications. GKE provides features to automatically add or remove nodes to a cluster based on CPU usage.

To achieve this, you need to perform the following steps:

  1. Configure a HorizontalPodAutoscaler (HPA): This is a Kubernetes API object that automatically scales the number of pods in a deployment, replica set, or stateful set based on observed CPU utilization. You can set the CPU utilization target for the HPA to a specific percentage. For example, you can set the target CPU utilization to 80%. If the observed CPU utilization exceeds 80%, the HPA will add more pods to the deployment.

  2. Enable the Cluster Autoscaler: The Cluster Autoscaler is a Kubernetes add-on that automatically resizes a GKE cluster by adding or removing nodes based on the resource utilization of the nodes in the cluster. The Cluster Autoscaler can be enabled from the GCP Console.

Here are the reasons why the other answers are incorrect:

B. Configure a HorizontalPodAutoscaler with a target CPU usage. Enable autoscaling on the managed instance group for the cluster using the gcloud command.

This answer is incorrect because it suggests enabling autoscaling on the managed instance group for the cluster, which is not the correct approach. The correct approach is to enable the Cluster Autoscaler for the GKE cluster.

C. Create a deployment and set the maxUnavailable and maxSurge properties. Enable the Cluster Autoscaler using the gcloud command.

This answer is incorrect because it suggests creating a deployment and setting the maxUnavailable and maxSurge properties. While this is a valid approach to manage the availability of a deployment, it does not address the issue of automatically adding or removing nodes based on CPU usage.

D. Create a deployment and set the maxUnavailable and maxSurge properties. Enable autoscaling on the cluster managed instance group from the GCP Console.

This answer is incorrect for the same reason as answer C. Setting the maxUnavailable and maxSurge properties can help manage the availability of a deployment, but it does not address the issue of automatically adding or removing nodes based on CPU usage.