Use the Conformity Knowledge Base AI to help improve your Cloud Posture

Enable VPC-Native Traffic Routing

Trend Cloud One™ – Conformity is a continuous assurance tool that provides peace of mind for your cloud infrastructure, delivering over 1000 automated best practice checks.

Risk Level: Medium (should be achieved)

Ensure that VPC-native traffic routing is enabled for your Google Kubernetes Engine (GKE) clusters. This feature enhances integration with Google Cloud's VPC, improving network performance, scalability, and security through the use of alias IP address ranges.

Security

VPC-native GKE clusters, which utilize Alias IPs, provide several advantages including pre-reserved pod IPs to prevent conflicts with other compute resources, enhanced security through network-level anti-spoofing checks on egress traffic, granular firewall controls applicable directly to pods independent of their nodes, and direct access to hosted services for pods without requiring a NAT gateway.


Audit

To determine if VPC-native traffic routing is enabled for your Google Kubernetes Engine (GKE) clusters, perform the following operations:

Using GCP Console

01 Sign in to the Google Cloud Management Console.

02 Select the Google Cloud Platform (GCP) project that you want to examine from the console top navigation bar.

03 Navigate to Kubernetes Engine console available at https://console.cloud.google.com/kubernetes.

04 In the left navigation panel, under Resource Management, choose Clusters and select the OVERVIEW tab to access the list of GKE clusters provisioned for the selected GCP project.

05 Click on the name (link) of the GKE cluster that you want to examine.

06 Select the DETAILS tab to view the configuration information available for the selected cluster.

07 In the Cluster Networking section, check the VPC-native traffic routing attribute value to determine if your cluster is a VPC-native cluster. If VPC-native traffic routing is set to Disabled, VPC-native traffic routing is not enabled for the selected Google Kubernetes Engine (GKE) cluster.

08 Repeat steps no. 5 – 7 for each GKE cluster provisioned within the selected GCP project.

09 Repeat steps no. 2 – 8 for each GCP project deployed in your Google Cloud account.

Using GCP CLI

01 Run projects list command (Windows/macOS/Linux) with custom output filters to list the ID of each GCP project available in your Google Cloud account:

gcloud projects list
	--format="table(projectId)"

02 The command output should return the requested GCP project IDS:

PROJECT_ID
cc-web-project-123123
cc-dev-project-112233

03 Run container clusters list command (Windows/macOS/Linux) with the ID of the GCP project that you want to examine as the identifier parameter and custom output filters to describe the name and the region of each GKE cluster provisioned for the selected project:

gcloud container clusters list
	--project cc-web-project-123123
	--format="table(NAME,ZONE)"

04 The command output should return the requested cluster names and their regions:

NAME: cc-gke-backend-cluster
ZONE: us-central1

NAME: cc-gke-frontend-cluster
ZONE: us-central1

05 Run container clusters describe command (Windows/macOS/Linux) with the name of the GKE cluster that you want to examine as the identifier parameter and custom output filters to determine if VPC-native traffic routing is enabled for the selected cluster:

gcloud container clusters describe cc-gke-backend-cluster
	--region=us-central1
	--format="json(ipAllocationPolicy.useIpAliases)"

06 The command output should return **true** if the cluster is a VPC-native cluster:

null

If the container clusters describe command output returns null, as shown in the example above, VPC-native traffic routing is not enabled for the selected Google Kubernetes Engine (GKE) cluster.

07 Repeat steps no. 5 and 6 for each GKE cluster provisioned for the selected GCP project.

08 Repeat steps no. 3 – 7 for each GCP project deployed in your Google Cloud account.

Remediation / Resolution

To enable VPC-native traffic routing for your Google Kubernetes Engine (GKE) clusters, you must re-create your clusters with alias IPs by performing the following operations:

Using GCP Console

01 Sign in to the Google Cloud Management Console.

02 Select the Google Cloud Platform (GCP) project that you want to access from the console top navigation bar.

03 Navigate to Kubernetes Engine console available at https://console.cloud.google.com/kubernetes.

04 In the left navigation panel, under Resource Management, choose Clusters and select the OVERVIEW tab to access the list of GKE clusters deployed for the selected GCP project.

05 Click on the name (link) of the GKE cluster that you want to re-create.

06 Select DUPLICATE from the console top menu to initiate the setup process using the same configuration settings as the source cluster and perform the following changes:

  1. For Cluster basics, provide a unique name for the new GKE cluster in the Name box.
  2. For Networking, perform the following actions:
    1. Check the Enable VPC-native traffic routing (uses alias IP) setting checkbox, available under Advanced networking options, to enable VPC-native traffic routing for the new cluster.
    2. Set the maximum number of Pods per node in the Maximum Pods per node box. This value is used to optimize the partitioning of cluster's IP address range to sub-ranges at GKE node level.
  3. Choose CREATE from the console bottom menu to create your new Google Kubernetes Engine (GKE) cluster.

07 (Optional) Once the new GKE cluster is operating successfully, you can remove the source cluster in order to stop adding charges to your Google Cloud bill:

  1. Navigate back to the Clusters page and select the OVERVIEW tab to list the GKE clusters deployed for the selected GCP project.
  2. Select the cluster that you want to delete (i.e., source cluster), and choose DELETE from the console top menu.
  3. In the confirmation box, confirm deletion by typing the cluster name in the required text box, and choose DELETE to remove the selected GKE cluster.

08 Repeat steps no. 5 – 7 for each GKE cluster that you want to re-create, created for the selected GCP project.

09 Repeat steps no. 2 – 8 for each GCP project available in your Google Cloud account.

Using GCP CLI

01 Run container clusters describe command (Windows/macOS/Linux) with the name of the GKE cluster that you want to re-create as the identifier parameter, to describe the configuration information available for the selected cluster:

gcloud container clusters describe cc-gke-backend-cluster
	--region=us-central1
	--format="json"

02 The command output should return the requested configuration information:

{
	"addonsConfig": {
		"gcePersistentDiskCsiDriverConfig": {
			"enabled": true
		},
		"kubernetesDashboard": {
			"disabled": true
		},
		"networkPolicyConfig": {
			"disabled": true
		}
	},
	"autopilot": {},
	"autoscaling": {
		"autoscalingProfile": "BALANCED"
	},

	...

	"releaseChannel": {
		"channel": "REGULAR"
	},
	"securityPostureConfig": {
		"mode": "DISABLED",
		"vulnerabilityMode": "VULNERABILITY_MODE_UNSPECIFIED"
	},
	"shieldedNodes": {
		"enabled": true
	},
	"status": "RUNNING",
	"subnetwork": "default",
	"zone": "us-central1"
}

03 Run container clusters create command (Windows/macOS/Linux) with the information returned at the previous step as the configuration data for the command parameters, to create a new Google Kubernetes Engine (GKE) cluster. Include the --enable-ip-alias parameter to use alias IPs for Pod IPs. This will enable VPC-native traffic routing for the new GKE cluster:

gcloud container clusters create cc-new-gke-backend-cluster
	--project=cc-web-project-123123
	--region=us-central1
	--disk-size=150
	--machine-type=e2-micro
	--num-nodes=3
	--release-channel=regular
	--enable-ip-alias

04 The command output should return the full URL of the new GKE cluster:

Created [https://container.googleapis.com/v1/projects/cc-web-project-123123/zones/us-central1/clusters/cc-new-gke-backend-cluster]

05 (Optional) Once the new GKE cluster is operating successfully, you can run container clusters delete command (Windows/macOS/Linux) to remove the source cluster in order to stop adding charges to your Google Cloud bill:

gcloud container clusters delete cc-gke-backend-cluster
	--region=us-central1

06 Type Y (Yes) to confirm the removal:

The following clusters will be deleted.
- [cc-gke-backend-cluster] in [us-central1]

Do you want to continue (Y/n)?  Y

07 The command output should return the URL of the deleted GKE cluster:

Deleted [https://container.googleapis.com/v1/projects/cc-web-project-123123/zones/us-central1/clusters/cc-gke-backend-cluster]

08 Repeat steps no. 1 - 4 for each GKE cluster that you want to re-create, available within the selected GCP project.

09 Repeat steps no. 1 – 8 for each GCP project deployed in your Google Cloud account.

References

Publication date Jan 7, 2025