Skip to main content

More Info:

Running the GKE Metadata Server prevents workloads from accessing sensitive instance metadata and facilitates Workload Identity

Risk Level

Low

Address

Operational Excellence, Performance Efficiency, Reliability, Security

Compliance Standards

  • CIS GKE

Triage and Remediation

Remediation

Using Console

To remediate the misconfiguration “Ensure The GKE Metadata Server Is Enabled” for GCP using GCP console, follow the below steps:
  1. Go to the Google Kubernetes Engine (GKE) cluster in the GCP console.
  2. Click on “Edit” button at the top of the page.
  3. Scroll down to the “Security” section.
  4. Ensure that “Enable metadata concealment” is unchecked.
  5. Click on “Save” button at the bottom of the page.
By following these steps, you will remediate the misconfiguration “Ensure The GKE Metadata Server Is Enabled” for GCP using GCP console.

To remediate the misconfiguration “Ensure The GKE Metadata Server Is Enabled” for GCP using GCP CLI, you can follow the below steps:
  1. Open the Cloud Shell in the GCP Console.
  2. Run the following command to enable the GKE Metadata Server:
Replace CLUSTER_NAME with the name of your GKE cluster.
  1. Verify that the GKE Metadata Server is enabled by running the following command:
If the output shows a valid cluster certificate, then the GKE Metadata Server is enabled.
  1. Repeat the above steps for all the GKE clusters in your GCP project.
By following the above steps, you can successfully remediate the misconfiguration “Ensure The GKE Metadata Server Is Enabled” for GCP using GCP CLI.
To remediate the misconfiguration “Ensure The GKE Metadata Server Is Enabled” for GCP using Python, follow these steps:
  1. Install the required Python libraries:
  1. Authenticate with GCP:
  1. Get the cluster:
  1. Check if the GKE Metadata Server is enabled:
  1. Enable the GKE Metadata Server:
Note: Make sure to replace <path-to-service-account-key.json>, <your-project-id>, <your-zone>, and <your-cluster-id> with the appropriate values.
Changing workload_metadata_config.mode on an existing node pool forces replacement of that node pool’s VMs (they will be recreated with the new metadata mode), but it does not recreate the cluster itself.To verify, terraform plan should show an update to each google_container_node_pool adding or changing workload_metadata_config.mode from GCE_METADATA (or unset) to GKE_METADATA, with the node instances being replaced.

Additional Reading: