Skip to content
This repository has been archived by the owner on Mar 29, 2023. It is now read-only.

IpAllocation Policy - Secondary Range Names #118

Closed
eliasscosta opened this issue Mar 17, 2021 · 10 comments · Fixed by #121
Closed

IpAllocation Policy - Secondary Range Names #118

eliasscosta opened this issue Mar 17, 2021 · 10 comments · Fixed by #121

Comments

@eliasscosta
Copy link

eliasscosta commented Mar 17, 2021

Hello everyone,

This week I begin to receive this error:
Error: googleapi: Error 400: Pod secondary range name (public-services) should not be the same as service secondary range name., badRequest when I recreate a cluster.

I in my plan module add the same name in cluster and service secondary ranges names.

+ ip_allocation_policy {
          + cluster_ipv4_cidr_block       = (known after apply)
          + cluster_secondary_range_name  = "public-services"
          + services_ipv4_cidr_block      = (known after apply)
          + services_secondary_range_name = "public-services"
        }

Look in detail the name is from vpc_network module and isn't possible to create a new subnetwork with a different name on this module.

I believe Google made few changes to the API.

@Jojoooo1
Copy link

Jojoooo1 commented Mar 19, 2021

Having the same error

@Taiwo-babson
Copy link

I am also having same error.

@Jojoooo1
Copy link

Jojoooo1 commented Mar 23, 2021

I had to create another block of ip for pod

@brianpham
Copy link

brianpham commented Mar 27, 2021

Seeing the same issue right now.

Any way we can get a quick fix in? @robmorgan

@Jojoooo1
Copy link

Jojoooo1 commented Mar 29, 2021

secondary_ip_range {
    range_name = "public-services"
    ip_cidr_range = cidrsubnet(
      var.secondary_cidr_block,
      var.secondary_cidr_subnetwork_width_delta,
      0
    )
  }

  secondary_ip_range {
    range_name = "public-cluster"
    ip_cidr_range = cidrsubnet(
      var.secondary_cidr_block,
      var.secondary_cidr_subnetwork_width_delta,
      1 * (1 + var.secondary_cidr_subnetwork_spacing)
    )
  }

@brianpham
Copy link

brianpham commented Mar 30, 2021

@Jojoooo1 Thanks. So you have to make changes to both the vpc-network module and the gke-cluster module? Still having trouble getting it to work properly. Do you have a branch I can look at?

@brianpham
Copy link

Nevermind. I was able to finally get it to work by doing what you suggested @Jojoooo1.

Had to patch both modules for it to work properly.
brianpham@f2bd4ce
brianpham/terraform-google-network@10f7433

Another workaround is just commenting out this line if you don't really want to point to your cidr block. GKE will just manage it for you if you don't include it.
https://github.com/gruntwork-io/terraform-google-gke/blob/master/modules/gke-cluster/main.tf#L71

@robmorgan
Copy link
Contributor

Hi everyone, thank you for raising this issue. Did anybody need to migrate Terraform state after changing/adding the additional secondary_ip_range? I'm mindful of having to publish a migration guide in order to get a quick fix out or finding a way to maintain backwards compatibility. I have a feeling the latter will not be possible in this case as it seems we are conflicting with GCP's API.

@brianpham
Copy link

@robmorgan Not sure about that. I re-created my cluster since I had to update the cidr blocks.

@robmorgan
Copy link
Contributor

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.