Skip to main content

More Info:

Ensure that node pool autoscaling is enabled

Risk Level

Medium

Address

Operational Excellence, Performance Efficiency, Reliability, Security

Compliance Standards

  • Cloudanix Best Practice

Triage and Remediation

Remediation

Using Console

To remediate the Kubernetes Node Pool Autoscaling misconfiguration for GCP using GCP console, follow these steps:
  1. Open the Google Cloud Console and navigate to the Kubernetes Engine page.
  2. Select the cluster that you want to remediate.
  3. Click on the “Node pools” tab.
  4. Select the node pool that you want to enable autoscaling for.
  5. Click on the “Edit” button at the top of the page.
  6. Scroll down to the “Autoscaling” section and click on the toggle button to enable autoscaling.
  7. Set the minimum and maximum number of nodes that you want to use for the node pool.
  8. Click on the “Save” button to apply the changes.
After following these steps, the Kubernetes Node Pool Autoscaling will be enabled for the selected node pool in GCP.

To remediate the misconfiguration “Kubernetes Node Pool Autoscaling Should Be Enabled” for GCP, you can follow these step-by-step instructions using GCP CLI:
  1. Open the Cloud Shell in your GCP console.
  2. Run the following command to get a list of all the node pools in your GKE cluster:
Replace [CLUSTER_NAME] and [ZONE] with your GKE cluster name and zone.
  1. Choose the node pool that you want to enable autoscaling for.
  2. Run the following command to enable autoscaling for the chosen node pool:
Replace [NODE_POOL_NAME], [CLUSTER_NAME], and [ZONE] with the appropriate values.
  1. Set the minimum and maximum number of nodes for the autoscaler using the following command:
Replace [MIN_NODES] and [MAX_NODES] with the desired minimum and maximum number of nodes.
  1. Verify that autoscaling is enabled for the node pool by running the following command:
This command should return “autoscaling: enabled”.With these steps, you have successfully remediated the misconfiguration “Kubernetes Node Pool Autoscaling Should Be Enabled” for GCP using GCP CLI.
To remediate the misconfiguration “Kubernetes Node Pool Autoscaling Should Be Enabled” for GCP using Python, you can use the following steps:
  1. Import the necessary libraries:
  1. Set up the credentials:
  1. Define the project ID and cluster ID:
  1. Get the current node pool configuration:
  1. Check if autoscaling is enabled:
  1. Update the node pool configuration:
This will enable autoscaling for the node pool in your GCP Kubernetes cluster.
Notes:
  • If you change remove_default_node_pool from false to true on an existing google_container_cluster, Terraform will need to replace the cluster, which is an outage-causing operation. Plan this change carefully.
  • Adjust CLUSTER_MIN_VCPUS, CLUSTER_MAX_VCPUS, CLUSTER_MIN_GB_MEM, CLUSTER_MAX_GB_MEM, NODE_POOL_MIN_NODES, and NODE_POOL_MAX_NODES to match any required thresholds for your environment.
Verification:
  • terraform plan should show an in-place update to google_container_node_pool.PRIMARY_AUTOSCALED_POOL adding the autoscaling block (and enabling cluster_autoscaling on google_container_cluster.PRIMARY_CLUSTER if it was previously disabled), with no unexpected resource replacements other than any intentional change to remove_default_node_pool.

Additional Reading: