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

permadrift on location_policy with beta_private_cluster #1445

Closed
wyardley opened this issue Oct 31, 2022 · 11 comments
Closed

permadrift on location_policy with beta_private_cluster #1445

wyardley opened this issue Oct 31, 2022 · 11 comments
Labels
bug Something isn't working

Comments

@wyardley
Copy link
Contributor

wyardley commented Oct 31, 2022

TL;DR

With v4.41.0 of the terraform provider, we're seeing permadrift with autoscaling => location_policy (with module default settings for autoscaling). I was able to create a simple repro case below.

Expected behavior

Terraform to apply clean

Observed behavior

      ~ autoscaling {
          - location_policy      = "BALANCED" -> null
            # (4 unchanged attributes hidden)
        }

Terraform Configuration

terraform {
  required_version = "1.3.3"
  required_providers {
    google = {
      source  = "hashicorp/google"
      version = "4.42.0"
    }
  }
}

variable "project" {
  type    = string
  default = "xyz"
}

variable "region" {
  type    = string
  default = "us-west2"
}

provider "google" {
  project               = var.project
  region                = var.region
  user_project_override = true
}

module "gke" {
  source                       = "terraform-google-modules/kubernetes-engine/google//modules/beta-private-cluster"
  version                      = "23.2.0"
  project_id                   = var.project
  name                         = "testcluster"
  regional                     = true
  region                       = var.region
  zones                        = ["us-west2-a", "us-west2-b"]
  network                      = "xxxx"
  create_service_account       = false
  dns_cache                    = true
  enable_private_endpoint      = false
  enable_private_nodes         = true
  master_ipv4_cidr_block       = "100.127.192.48/28"
  master_authorized_networks   = []
  master_global_access_enabled = false
  subnetwork                   = "xxx" # I'm guessing these could probably be defaults as well
  ip_range_pods                = "xxxx"
  ip_range_services            = "xxxx"
  kubernetes_version           = "1.24.3-gke.2100"
  remove_default_node_pool     = true
  initial_node_count           = 1
  gce_pd_csi_driver            = true

  node_pools = [{
    name               = "default-node-pool"
    machine_type       = "e2-standard-4"
    node_locations     = "us-west2-a,us-west2-b"
    min_count          = 1
    max_count          = 1
    node_metadata      = "GCE_METADATA"
    local_ssd_count    = 0
    disk_size_gb       = 100
    disk_type          = "pd-ssd"
    image_type         = "COS_CONTAINERD"
    auto_repair        = true
    auto_upgrade       = false
    enable_secure_boot = true
    preemptible        = false
  }]
}

Terraform Version

Terraform v1.3.3
on darwin_arm64
+ provider registry.terraform.io/hashicorp/google v4.42.0
+ provider registry.terraform.io/hashicorp/google-beta v4.42.0
+ provider registry.terraform.io/hashicorp/kubernetes v2.14.0
+ provider registry.terraform.io/hashicorp/random v3.4.3

Additional information

Maybe has to do with deleting default nodepool, but cluster_autoscaling seems to have balanced mode as default. https://registry.terraform.io/modules/terraform-google-modules/kubernetes-engine/google/latest/submodules/beta-private-cluster

I tried going back to 4.36, 4.38, 4.39 providers etc., and the problem persists, so maybe this is an API level change or something else?

If I run with TF_LOG=debug, I see

 "autoscaling": {
  "enabled": true,
  "minNodeCount": 1,
  "maxNodeCount": 1,
  "locationPolicy": "BALANCED"
 },

as well as

 "autoscaling": {
  "autoscalingProfile": "BALANCED"
 },

in API responses

Tested older and newer provider versions, but let me know if this seems to be an upstream provider (and / or Google API response changing) issue. I also tested jumping back to v22.1.0 of this module.

@wyardley wyardley added the bug Something isn't working label Oct 31, 2022
@HametAk
Copy link

HametAk commented Nov 2, 2022

QBYMKPI pushed a commit to QBYMKPI/terraform-google-kubernetes-engine that referenced this issue Nov 2, 2022
@bharathkkb
Copy link
Member

Thanks for the report, I suspect this is an upstream API change since GoogleCloudPlatform/magic-modules#6370 was recently added.

@bharathkkb
Copy link
Member

#1448 possible fix in progress

QBYMKPI pushed a commit to QBYMKPI/terraform-google-kubernetes-engine that referenced this issue Nov 3, 2022
@mmn0o7
Copy link

mmn0o7 commented Nov 3, 2022

Im also having problems with location_policy with private-cluster

  ~ resource "google_container_node_pool" "pools" {
        id                          = "projects/gcp-workcanvas-prod-1/locations/us-east1/clusters/gke-prod-us-east1/nodePools/default-node-pool"
        name                        = "default-node-pool"
        # (10 unchanged attributes hidden)

      ~ autoscaling {
          - location_policy      = "ANY" -> null
            # (4 unchanged attributes hidden)
        }

bharathkkb pushed a commit that referenced this issue Nov 7, 2022
@bharathkkb
Copy link
Member

#1452 now allows you to specify location_policy. We have not set a default yet as the feature is dependent on the kubernetes version but you can set location_policy instead to avoid the permadiff.

@wyardley
Copy link
Contributor Author

Hi folks. Can we reopen? Still seeing this after the v24 release from #1447

@wyardley
Copy link
Contributor Author

Oh I see, have to set it explicitly 😞

@mmn0o7
Copy link

mmn0o7 commented Nov 22, 2022

does the fix work for node_pools under gke module or just for google_container_node_pool resource ?

@tback
Copy link

tback commented Dec 6, 2022

I also don't understand what to do regarding node_pools defined in a gke module. It seems there is nothing in the documentation of the module https://registry.terraform.io/modules/terraform-google-modules/kubernetes-engine/google/24.0.0 .

@lauraseidler
Copy link
Contributor

For node_pools, setting the location_policy key works for us.

@tback
Copy link

tback commented Dec 8, 2022 via email

CPL-markus pushed a commit to WALTER-GROUP/terraform-google-kubernetes-engine that referenced this issue Jul 15, 2024
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

6 participants