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

Provider using local config despite paramaters #234

Open
andrew-gallin-current opened this issue Nov 21, 2022 · 2 comments
Open

Provider using local config despite paramaters #234

andrew-gallin-current opened this issue Nov 21, 2022 · 2 comments

Comments

@andrew-gallin-current
Copy link

My provider appears to have started exclusively using the local config regardless of provider configuration. This only just started and I have been using this for several months.

The active cluster is used if not specified, but if I explicitly set the config profile param, the provider will use that.

I have removed the installed provider, reinstalled, removed and reinitialized my .terraform file and restarted my machine and the issue still persists.

This is the way my provider is invoked

terraform {
  required_version = ">= 1"
  required_providers {
    google = {
      source  = "hashicorp/google"
      version = ">= 4.27.0, < 5.0.0"
    }
    kubectl = {
      source  = "gavinbunney/kubectl"
      version = ">= 1.14.0"
    }
  }
}

data "google_client_config" "default" {
  provider = google.tokengen
}

data "google_container_cluster" "CLUSTER" {
  name     = var.cluster_name
  location = var.region
}

provider "kubectl" {
  load_config_file = false
  host             = "https://${data.google_container_cluster.CLUSTER.endpoint}"
  token            = data.google_client_config.default.access_token
  cluster_ca_certificate = base64decode(
    data.google_container_cluster.CLUSTER.master_auth[0].cluster_ca_certificate,
  )
}

Here are some debug logs:

2022-11-21T15:31:43.425-0500 [DEBUG] provider.terraform-provider-random_v3.4.3_x5: Called provider defined Provider GetDataSources: tf_provider_addr=registry.terraform.io/hashicorp/random tf_req_id=0d6f8408-ebdd-997e-0ebc-8e27d6c67940 tf_rpc=GetProviderSchema @caller=github.com/hashicorp/[email protected]/internal/fwserver/server.go:195 @module=sdk.framework timestamp=2022-11-21T15:31:43.425-0500
2022-11-21T15:31:43.425-0500 [DEBUG] provider.terraform-provider-kubectl_v1.14.0: 
2022/11/21 15:31:43 [DEBUG] Using kubeconfig: /Users/andrewgallin/.kube/config
2022-11-21T15:31:43.425-0500 [DEBUG] provider.terraform-provider-kubectl_v1.14.0: 
2022/11/21 15:31:43 [WARN] Invalid provider configuration was supplied. Provider operations likely to fail: stat /Users/andrewgallin/.kube/config: no such file or directory

Then I auth to the cluster with a  gcloud container clusters get-credentials CLUSTER --zone=us-central1

2022-11-21T15:35:36.123-0500 [DEBUG] provider.terraform-provider-kubectl_v1.14.0: 
2022/11/21 15:35:36 [DEBUG] Using kubeconfig: /Users/andrewgallin/.kube/config

Any idea what may be going on? The provider.go file seems to indicate that as long as it is set to false it would skip the config path.

I think using the local config by default should be turned off and people should opt in regardless. Not sure that would help this bug as it is ignoring that "false" param, but maybe it would.

@MalteGood
Copy link

I had a similar issue and found that the last working version seems to be 1.10.0.

@jamesosbourn
Copy link

Having similar issues trying to configure MetalLB resources using this provider. I was eventually able to get this to work after reading this and downgrading from the latest version to 1.11.0. I tried all of the 1.11.x version in reverse order and this was the first version that worked. I had also tried 1.10.0 as per the comment above which worked.

Getting the same error that the local config file does not exist and a failure to talk to the k8s cluster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants