What are the GKE (with IP alias enabled) pod/service IP ranges?

11/28/2018

I am trying to use terraform to create a GKE cluster, but I am stuck because, for the pod / services subnetworks, I do not know which values GKE uses by default for the primary IP range and secondary IP range.

In the below terraform configuration, what are the default GKE values for:

google_compute_subnetwork.pods.ip_range
google_compute_subnetwork.pods.secondary_ip_range.ip_range
google_compute_subnetwork.services.ip_range
google_compute_subnetwork.services.secondary_ip_range.ip_range

?


resource "google_compute_network" "primary" {
    name                    = "${var.cluster_name}"
    auto_create_subnetworks = false
}

resource "google_compute_subnetwork" "pods" {
    name          = "pods-primary"
    region        = "${var.region}"
    ip_cidr_range = ""
    network       = "${google_compute_network.primary.self_link}"

    secondary_ip_range {
        range_name    = "pods-secondary"
        ip_cidr_range = ""
    }
}

resource "google_compute_subnetwork" "services" {
    name          = "services-primary"
    region        = "${var.region}"
    ip_cidr_range = ""
    network       = "${google_compute_network.primary.self_link}"

    secondary_ip_range {
        range_name    = "services-secondary"
        ip_cidr_range = ""
    }
}
-- snkcld
google-cloud-platform
google-kubernetes-engine

2 Answers

11/28/2018

The GKE default values for the primary IP range and secondary IP range are based on Pods and Services ranges

If you need to customize these values, please follow these guidelines

About what CIDRs will be used, if not provided by the user, GKE will allocate a random /14 block from 10.0.0.0/8 (except from 10.128.0.0/9 if the cluster is in the default network).

This range is the Pod range for the cluster. When a node is added to a GKE cluster, a /24 block is allocated from the Pod range and assigned to the node.

For route-based clusters, the final /20 block of a cluster IP range is set aside for IP addresses for services using a ClusterIP, and is not available for node allocation blocks.

For alias IPs clusters, a separate /20 block outside of the Pod range is reserved for services using a secondary range.

-- Daniel
Source: StackOverflow

11/28/2018

nevermind, with vpc native, there is no default cidr range defined

-- snkcld
Source: StackOverflow