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

Import of existing cluster fails due to addons response empty #1716

Closed
mazzy89 opened this issue Aug 23, 2023 · 3 comments · Fixed by #1978
Closed

Import of existing cluster fails due to addons response empty #1716

mazzy89 opened this issue Aug 23, 2023 · 3 comments · Fixed by #1978
Labels
bug Something isn't working Stale

Comments

@mazzy89
Copy link

mazzy89 commented Aug 23, 2023

TL;DR

Importing an existing cluster fails due to the addons JSON response empty from gcloud CLI.

{
  "addonsConfig": {
    "gcePersistentDiskCsiDriverConfig": {
      "enabled": true
    },
    "kubernetesDashboard": {
      "disabled": true
    },
    "networkPolicyConfig": {
      "disabled": true
    }
  },
...

Expected behavior

I would like to see the cluster imported correctly.

Observed behavior

╷
│ Error: Invalid index
│
│   on .terraform/modules/gke/main.tf line 114, in locals:
│  114:   cluster_output_http_load_balancing_enabled        = google_container_cluster.primary.addons_config[0].http_load_balancing[0].disabled
│     ├────────────────
│     │ google_container_cluster.primary.addons_config[0].http_load_balancing is empty list of object
│
│ The given key does not identify an element in this collection value: the collection has no elements.
╵

╷
│ Error: Invalid index
│
│   on .terraform/modules/gke/main.tf line 115, in locals:
│  115:   cluster_output_horizontal_pod_autoscaling_enabled = google_container_cluster.primary.addons_config[0].horizontal_pod_autoscaling[0].disabled
│     ├────────────────
│     │ google_container_cluster.primary.addons_config[0].horizontal_pod_autoscaling is empty list of object
│
│ The given key does not identify an element in this collection value: the collection has no elements.

Terraform Configuration

module "gke" {
  source  = "terraform-google-modules/kubernetes-engine/google"
  version = "~> 27.0"

  project_id = var.project_id
  name       = "myone"

  region     = "us-central1"
  zones      = ["us-central1-f"]
  network    = "default"
  subnetwork = "default"

  ip_range_pods     = "gke-myone-pods-09c87874"
  ip_range_services = "gke-myone-services-09c87874"

  http_load_balancing        = true
  network_policy             = false
  horizontal_pod_autoscaling = true
  filestore_csi_driver       = false

  create_service_account = false

  node_pools = [
    {
      name            = "default-pool"
      machine_type    = "e2-medium"
      node_locations  = "us-central1-f"
      autoscaling     = false
      node_count      = 3
      local_ssd_count = 0
      spot            = false
      disk_size_gb    = 100
      disk_type       = "pd-balanced"
      image_type      = "COS_CONTAINERD"
      service_account = "default"
      enable_gcfs     = false
      enable_gvnic    = false
      auto_repair     = true
      auto_upgrade    = true
      service_account = "default"
      preemptible     = false
    },
  ]

  node_pools_oauth_scopes = {
    all = [
      "https://www.googleapis.com/auth/cloud-platform"
    ]
  }

  kubernetes_version = "1.26.6-gke.1700"
}

Terraform Version

Terraform v1.5.5
on linux_amd64

Additional information

A similar issue (#494) was reported but in that occasion the user could at least import. I'm not even able to import.

@mazzy89 mazzy89 added the bug Something isn't working label Aug 23, 2023
@mazzy89 mazzy89 changed the title Import of existing cluster fails due to addons empty Aug 23, 2023
@mazzy89
Copy link
Author

mazzy89 commented Aug 23, 2023

I have found something interesting in the GKE documentation

GKE clusters have HTTP load balancing enabled by default; you must not disable it.

Having http enabled by default I guess they do not expose it via the API. At this point still make sense to have it exposed as a boolean flag in this module?

@mazzy89
Copy link
Author

mazzy89 commented Aug 29, 2023

I was able to import successfully the cluster by pulling the module and commenting out the offending Terraform blocks. The import then run successfully. After that I've replaced again the module with the upstream one and it worked. Hope it helps for whoever will come next.

@github-actions
Copy link

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the Stale label Oct 28, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Stale
1 participant