Description
VPC-native GKE clusters assign Pod IPv4 addresses from secondary subnet ranges without a separate route per node for its Pods. This is the default mode for new clusters.
Potential impact
Too few addresses can prevent new Pods from starting. Use firewall rules, network policies and private access settings to restrict traffic and cluster access.
Remediation
For a new cluster, set ip_allocation_policy.use_ip_aliases: yes and allow enough addresses for Pods and Services. An existing routes-based cluster cannot be converted in place. Migrate workloads to a new cluster and test connectivity.
Examples
The three tasks create differently named clusters. Supply the project and the path to the service account JSON file.
Before
- name: create a cluster1
google.cloud.gcp_container_cluster:
name: my-cluster1
initial_node_count: 2
node_config:
machine_type: n1-standard-4
disk_size_gb: 500
location: us-central1-a
project: "{{ gcp_project }}"
auth_kind: serviceaccount
service_account_file: "{{ gcp_service_account_file }}"
state: present
- name: create a cluster3
google.cloud.gcp_container_cluster:
name: my-cluster3
initial_node_count: 2
node_config:
machine_type: n1-standard-4
disk_size_gb: 500
location: us-central1-a
project: "{{ gcp_project }}"
auth_kind: serviceaccount
service_account_file: "{{ gcp_service_account_file }}"
state: present
ip_allocation_policy:
create_subnetwork: no
use_ip_aliases: no
my-cluster1 omits the allocation policy. my-cluster3 sets use_ip_aliases: no without requesting routes-based mode, so GKE still chooses its default. Check the actual mode on each cluster.
After
- name: create a cluster
google.cloud.gcp_container_cluster:
name: my-cluster
initial_node_count: 2
node_config:
machine_type: n1-standard-4
disk_size_gb: 500
location: us-central1-a
project: "{{ gcp_project }}"
auth_kind: serviceaccount
service_account_file: "{{ gcp_service_account_file }}"
state: present
ip_allocation_policy:
create_subnetwork: no
use_ip_aliases: yes
my-cluster explicitly requests alias IPs. With create_subnetwork: no, check that the existing subnet has sufficient address space.