GKE multiple node pools in different subnet from shared VPC

Do we have an option in GKE to create multiple node pools in different subnets within the same Shared VPC?
Is this feature available in GKE? We are facing the below error when trying to create a node pool using the command line in different subnet:

gcloud container node-pools create --cluster <cluster_name> --region us-east1 --subnetwork <subnet_name> --num-nodes 1
ERROR: (gcloud.container.node-pools.create) ResponseError: code=400, message=The custom subnet feature has not been enabled yet.

gke google-kubernetes-engine-gke kubernetes-engine-gke

1 Like

Hi @Manikanta-Daram there, nice to meet you …

Oke let’s solve your problem.

To answer your question: Yes, GKE does support multiple node pools in different subnets, but there are specific requirements and constraints you need to be aware of to avoid the “custom subnet feature” error.

1. Why you are seeing this error

The error The custom subnet feature has not been enabled yet typically occurs because the cluster was not initialized with the necessary configurations to support multi-subnet node pools, or there is a version mismatch. Historically, GKE clusters were tied to a single primary subnet for all nodes.

2. Requirements for Multi-Subnet Node Pools

To place node pools in different subnets within the same Shared VPC:

  • VPC-Native Cluster: Your cluster must be VPC-native (using alias IP ranges). Routes-based clusters do not support this feature.

  • Shared VPC Permissions: Ensure the GKE Service Account has the compute.networkUser role on the specific host project’s subnets you are trying to use.

  • GKE Version: Ensure your control plane is running a recent version (ideally 1.24 or later), as support for this evolved significantly in newer releases.

3. Correct Approach for GKE Standard

If you are using GKE Standard, the ability to specify a subnet per node pool is often restricted to certain configurations. However, for GKE Autopilot, this is handled more dynamically.

For GKE Standard, if your cluster supports it, the command should work, but if it’s an older cluster, you might be hitting a limitation where the cluster “underlying architecture” wasn’t enabled for multi-subnetting at creation time.

4. Workaround/Alternative

If you cannot get the --subnetwork flag to work on an existing cluster, it is likely because the feature cannot be enabled retroactively on that specific cluster instance.

  • Check your cluster’s networking: Run gcloud container clusters describe <cluster_name> and verify if ipAllocationPolicy is enabled (VPC-native).

  • Try Regional vs Zonal: Ensure the subnet you are calling resides in the same region as your regional cluster or the specific zone of your zonal cluster.

Recommended Step: Double-check if you have provided the full path for the subnetwork in the Shared VPC (e.g., projects/[HOST_PROJECT_ID]/regions/[REGION]/subnetworks/[SUBNET_NAME]). Sometimes the shorthand name fails in Shared VPC environments.

Hope this points you in the right direction! :smiling_face_with_three_hearts:

Tried all the possible approaches and not able to create the node pool with in the same VPC with a different subnet other than subnet which we used during cluster creation. But there is a option to select the different VPC with different subnet but not with same VPC.