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

No self link, apply is failing #100

Closed
jonnymcgow7 opened this issue Mar 12, 2019 · 33 comments
Closed

No self link, apply is failing #100

jonnymcgow7 opened this issue Mar 12, 2019 · 33 comments
Labels
bug Something isn't working

Comments

@jonnymcgow7
Copy link

We're following almost exactly the readme spec and terraform plan works fine, but when we run apply we get this error: * module.gke.google_container_cluster.primary: Resource 'data.google_compute_subnetwork.gke_subnetwork' not found for variable 'data.google_compute_subnetwork.gke_subnetwork.self_link'

Is this a versioning problem on our end maybe? We've tried going through the other issues and the readme but have struggled to find the source of our problem. for the provider we have:

provider "google-beta" {
  project     = "project-name"
  region      = "region-name"
}

And in main.tf we define the module with that specified provider:

module "gke" {
  providers {
    google = "google-beta"
  }
...

Any help is much appreciated, thanks.

@rileykarson
Copy link
Contributor

Oh! This is an issue present in 2.1.0. If you restrict your provider to 2.0.0, or wait for 2.2.0 (hopefully later today / early tomorrow) this will work again.

@vdt-mik
Copy link

vdt-mik commented Mar 13, 2019

Hi! I have same issue too, but i have the new provider version:

* provider.google: version = "~> 2.2"
* provider.kubernetes: version = "~> 1.5"
* provider.null: version = "~> 2.1"
* provider.random: version = "~> 2.0"

@brendanator
Copy link

I was able to get around this by using the default network for everything.

module "gke" {
  source                     = "terraform-google-modules/kubernetes-engine/google"
  project_id                 = "${var.project}"
  name                       = "${var.cluster_name}"
  region                     = "${var.region}"
  zones                      = "${var.zones}"
  network                    = "default"
  subnetwork                 = "default"
  ip_range_pods              = "default"
  ip_range_services          = "default"
}

I guess this means that I would have to manually create these networks/subnets to use different names?

Either these networks should be automatically generated or the documentation needs updating

@morgante
Copy link
Contributor

@rileykarson Can you confirm if this has been fixed in the provider?

@rileykarson
Copy link
Contributor

It should have been fixed in 2.2.0, if you can repro in an isolated config please file an issue.

@morgante
Copy link
Contributor

@vdt-mik Any chance you could share your config?

@aaron-lane aaron-lane added the bug Something isn't working label May 27, 2019
@aaron-lane
Copy link
Contributor

@jonnymcgow7 can you please confirm if using version 2.2.0 or greater of the provider fixes this issue?

@s-u-b-h-a-k-a-r
Copy link

s-u-b-h-a-k-a-r commented May 30, 2019

@jonnymcgow7 can you please confirm if using version 2.2.0 or greater of the provider fixes this issue?
I am using the below versions but still facing the same issue.

https://github.com/SubhakarKotta/gcloud-gke-rds-terraform/tree/master/frameworks

provider "google" {
  version     = "~> 2.3.0"
  credentials = "${ file(var.credentials) }"
  project     = "${var.project_id}"
  region      = "${var.region}"
}

provider "google-beta" {
  version     = "~> 2.3.0"
  credentials = "${ file(var.credentials) }"
  project     = "${var.project_id}"
  region      = "${var.region}"
}

@aaron-lane
Copy link
Contributor

@subhakarkotta can you please file as issue against https://github.com/terraform-providers/terraform-provider-google?

@s-u-b-h-a-k-a-r
Copy link

@chrislovecnm
Copy link
Contributor

I am hitting this as well, and I am referencing the networking name in the gke module.

My providers

provider "google" {
  version = "2.7.0"
  project = "${var.project_id}"
  region  = "${var.region}"
}

provider "google-beta" {
  version = "2.7.0"
  project = "${var.project_id}"
  region  = "${var.region}"
}

snippet from my cluster

module "gke" {

  source = "terraform-google-modules/kubernetes-engine/google//modules/private-cluster"
  enable_private_endpoint    = "true"
  enable_private_nodes       = "true"
  // TODO make this configurable
  master_ipv4_cidr_block     = "10.0.0.0/28"

  project_id = "${var.project_id}"
  name       = "${var.cluster_name}"
  region   = "${var.region}"
  zones   = "${var.zones}" // FIXME we may need to convert a list to a string here
  regional   = true
  kubernetes_version    = "1.13.5-gke.10"

  network           = "${module.gke-network.network_name}"
  subnetwork        = "my-subnet" // TODO use a variable??
}

@chrislovecnm
Copy link
Contributor

I even added

output "name" {
  description = "Cluster name"
  value       = "${module.gke.name}"
  depends_on = [ "${module.gke-network.network_name}" ]
}

And that did not help

@aaron-lane
Copy link
Contributor

@chrislovecnm could you try using an element of module.gke-network.subnets_names for the subnetwork argument of module.gke?

@chrislovecnm
Copy link
Contributor

It is an array, not a singular name, let me workout the syntax 😅

@aaron-lane
Copy link
Contributor

"${element(module.gke-network.subnets_names, 0)}" should work, assuming the first subnet is the one you want to use.

@chrislovecnm
Copy link
Contributor

Wahoo! Yes adding the subnet as a var helped.

@aaron-lane
Copy link
Contributor

@chrislovecnm Excellent!
@subhakarkotta does this solution work for you?

@s-u-b-h-a-k-a-r
Copy link

@aaron-lane Thanks It worked

@MichelBoucey
Copy link

Hi Aaron,

Terraform v0.11.14

  • provider.google v2.7.0
  • provider.google-beta v2.7.0
  • provider.kubernetes v1.7.0

I'm stuck on the same error when applying plan.

I tried "${element(module.gke-network.subnets_names, 0)}", but no module by that name.

@morgante
Copy link
Contributor

@MichelBoucey How are you creating your network? For that to work, you need gke-network module defined in the same Terraform config.

If you can share your Terraform config, we'll be able to help easier.

@MichelBoucey
Copy link

MichelBoucey commented Jun 25, 2019

I knew this module wasn't used so far but it seems the only trick to trigger the discover or creation of the resource data.google_compute_subnetwork.gke_subnetwork...

Well, I'm just following the simple_regional_private example:

provider "google-beta" {
  version = "~> 2.7.0"
  project = "${var.project_id}"
  region  = "${var.region}"
}

data "google_compute_subnetwork" "subnetwork" {
  name    = "${var.subnetwork}"
  project = "${var.project_id}"
  region  = "${var.region}"
}

module "gke" {
  source                  = "terraform-google-modules/kubernetes-engine/google//modules/private-cluster"
  project_id              = "${var.project_id}"
  name                    = "${var.project_id}"
  regional                = true
  region                  = "${var.region}"
  network                 = "${var.network}"
  subnetwork              = "${var.subnetwork}"
  ip_range_pods           = "${var.network}-pods"
  ip_range_services       = "${var.network}-services"
  service_account         = "terraform@${var.project_id}.iam.gserviceaccount.com"
  enable_private_endpoint = true
  enable_private_nodes    = true
  master_ipv4_cidr_block  = "172.16.0.0/28"

  master_authorized_networks_config = [{
    cidr_blocks = [{
      cidr_block = "10.0.0.0/28"
      display_name = "VPC"
    }]
  }]
}

data "google_client_config" "default" {}

@morgante
Copy link
Contributor

@MichelBoucey What exactly is the error you get? It expects subnetwork name as an input.

@MichelBoucey
Copy link

I get, exactly as @jonnymcgow7, module.gke.google_container_cluster.primary: Resource 'data.google_compute_subnetwork.gke_subnetwork' not found for variable 'data.google_compute_subnetwork.gke_subnetwork.self_link'

@morgante
Copy link
Contributor

@MichelBoucey Where is var.subnetwork coming from? Where are you defining your subnet creation?

@MichelBoucey
Copy link

MichelBoucey commented Jun 26, 2019

@morgante I thought it was just a name to provide, not to point at an already created resource by its name, but to create the subnetwork by that name. So, var.subnetwork is just a name coming from my terraform.tfvars.

@morgante
Copy link
Contributor

Ah, this module doesn't take care of creating the subnetwork. You need to provide a subnetwork from outside the module, which you can use the network module to handle.

@MichelBoucey
Copy link

MichelBoucey commented Jun 26, 2019

@morgante Oh thank you very much. It's clearer now. I thought terraform-google-kubernetes-engine module was self-sufficient to setup a full GKE service as there is for EKS. BTW: I'm a great beginner on GCP services...

@chrislovecnm
Copy link
Contributor

@morgante we should have an example that builds a network and a cluster as well. I have some TF that I can contribute, once I get the beta module stuff sorted

@morgante
Copy link
Contributor

@chrislovecnm My thoughts exactly. :) I opened #195 to track.

@DXCanas
Copy link

DXCanas commented Jul 11, 2019

Tried the suggestion here: #100 (comment)

  network                    = "default"

I was able to get around this by using the default network for everything.

module "gke" {
  source                     = "terraform-google-modules/kubernetes-engine/google"
  project_id                 = "${var.project}"
  name                       = "${var.cluster_name}"
  region                     = "${var.region}"
  zones                      = "${var.zones}"
  network                    = "default"
  subnetwork                 = "default"
  ip_range_pods              = "default"
  ip_range_services          = "default"
}

I guess this means that I would have to manually create these networks/subnets to use different names?

Either these networks should be automatically generated or the documentation needs updating

I don't really have the need for a shared network, but setting default in this way isn't working for me. Must I create a network despite the fact that the gcloud CLI will auto-assign to default?

@morgante
Copy link
Contributor

@DXCanas I'm a little unclear on your ask. Most users of this module are using it with a custom network rather than the default VPC network.

If you want to use the default VPC, you should be able to though—you just have to specify it. Is that not working for you?

@DXCanas
Copy link

DXCanas commented Jul 12, 2019

@morgante That's exactly right!

I get:

Error: Error applying plan:

1 error occurred:
	* module.kubernetes.module.gke.google_container_cluster.primary: 1 error occurred:
	* google_container_cluster.primary: Error waiting for creating GKE cluster: Retry budget exhausted (5 attempts): Secondary range "default" does not exist in network "default", subnetwork "default".

With this config:

module "gke" {
  source = "terraform-google-modules/kubernetes-engine/google"
  project_id = XXXXX
  name = "XXXX"
  region = "${var.cluster_region}"
  zones = ["${var.cluster_region}-a"]
  network = "default"
  subnetwork = "default"
  ip_range_pods = "default"
  ip_range_services = "default"

  http_load_balancing = true
  horizontal_pod_autoscaling = true
  network_policy = false
}

@morgante
Copy link
Contributor

Got it, opened #211 to track.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

10 participants