Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unclear error 400 on creating private cluster: (cluster.master_ipv4_cidr causes http 400) #3981

Closed
vdboor opened this issue Jul 5, 2019 · 5 comments · Fixed by GoogleCloudPlatform/magic-modules#2063
Assignees
Labels
bug forward/review In review; remove label to forward service/container

Comments

@vdboor
Copy link

vdboor commented Jul 5, 2019

When I tried creating a VPC-based cluster, I got an unclear error message. This was caused by a faulty enable_private_nodes = true setting (this should have been kept on false)

Terraform v0.12.3

  • provider.google v2.10.0
  • provider.google-beta v2.10.0
  • provider.kubernetes v1.8.0

Affected Resource(s)

  • google_container_cluster

Terraform Configuration Files

resource "google_container_cluster" "default" {
  name     = "test"
  location = "europe-west1-d"

  logging_service    = "logging.googleapis.com/kubernetes"    # beta
  monitoring_service = "monitoring.googleapis.com/kubernetes" # beta

  # Network config
  network = "projects/${var.gcp_project}/global/networks/terraform"
  subnetwork = "projects/${var.gcp_project}/regions/europe-west1/subnetworks/terraform"

  private_cluster_config {
    # VPC default, but public accessable
    enable_private_nodes    = true   # this causes master_ipv4_cidr error!
    enable_private_endpoint = false

    # no master_ipv4_cidr_block defined here
  }

  ip_allocation_policy {
    use_ip_aliases    = true
    create_subnetwork = false
  }

  network_policy {
    enabled  = true
    provider = "CALICO"
  }

  master_auth {
    client_certificate_config {
      issue_client_certificate = false
    }
  }

  initial_node_count = 1

  node_config {
    disk_size_gb = 20

    oauth_scopes = [
      "https://www.googleapis.com/auth/devstorage.read_only", # access private images on buckets
      "https://www.googleapis.com/auth/logging.write",        # logging_service to google/stackdriver
      "https://www.googleapis.com/auth/monitoring",           # monitoring_service to google
      "https://www.googleapis.com/auth/trace.append",         # stackdriver traces
    ]

    metadata = {
      disable-legacy-endpoints = "true"
    }

    labels = {}
  }
}

Actual Behavior

google_container_cluster.default: Creating...

Error: googleapi: Error 400: Unable to parse cluster.master_ipv4_cidr "" into a valid IP address and mask., badRequest

  on kubernetes_cluster.tf line 1, in resource "google_container_cluster" "default":
   1: resource "google_container_cluster" "default" {

Expected behavior

  • Terraform warning me that this configuration doesn't work
  • Terraform having an option to define the master IP CIDR as the IP requests.

Steps to Reproduce

  1. terraform apply
@ghost ghost added the bug label Jul 5, 2019
@tysen
Copy link

tysen commented Jul 11, 2019

@vdboor - you can specify master_ipv4_cidr_block within the private_cluster_config block. Are you looking for something other than that?

@tysen tysen self-assigned this Jul 11, 2019
@vdboor
Copy link
Author

vdboor commented Jul 11, 2019

@tysen Thanks for taking care! :-) In the end I solved it by setting enable_private_nodes = false because I didn't want a completely private system.

My main reason for reporting this issue is because of it's unclear message. I'd expect that Terraform would at least warn that setting private_cluster_config.master_ipv4_cidr_block is required when enable_private_nodes=false, or that it could auto-generate that value. I don't have any clue what CIDR I should to assign for the master.

@danilo404
Copy link

@vdboor I think there's a typo in your message in the second part, did you mean "private_cluster_config.master_ipv4_cidr_block is required when enable_private_nodes=true"?

@vdboor
Copy link
Author

vdboor commented Jul 15, 2019

@calmacara Yes, that seems to be the case. The API returns a HTTP 400 when it's not provided for private clusters.

@ghost
Copy link

ghost commented Aug 17, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Aug 17, 2019
@github-actions github-actions bot added service/container forward/review In review; remove label to forward labels Jan 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug forward/review In review; remove label to forward service/container
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants