gavinbunney / terraform-provider-kubectl

Terraform provider to handle raw kubernetes manifest yaml files
https://registry.terraform.io/providers/gavinbunney/kubectl
Mozilla Public License 2.0
626 stars 107 forks source link

failed to create kubernetes rest client for read of resource #229

Open bitsofinfo opened 2 years ago

bitsofinfo commented 2 years ago
    kubectl = {
      source  = "gavinbunney/kubectl"
      version = ">= 1.14.0"
    }

....

provider "kubectl" {
  config_path      = local_file.kube_config.filename
  config_context   = var.kube_config_context
  load_config_file = false
}

Constantly get

Error: failed to create kubernetes rest client for read of resource: Get "http://localhost/api?timeout=32s": dial tcp [::1]:80: connect: connection refused

This seems to only happen on destroy

I've tried both load_config_file = true / false to no avail (the option is confusing... what "path" does this pertain to? the default one on the system or the one in config_path?) is this mutually exclusive or not when used in combination with config_path?)

bmitchinson commented 1 year ago

Getting this on apply as well. Doing research to see if it's related to https://support.hashicorp.com/hc/en-us/articles/4408936406803-Kubernetes-Provider-block-fails-with-connect-connection-refused-

I don't think though since the initial apply works fine and creates resources, just the state refresh fails 🤔

thiagoscodelerae commented 1 year ago

Getting the same issue here. It works normally and after some time it starting retrieving the same issue reported by @bitsofinfo

provider "kubectl" {
  apply_retry_count      = 5
  host                   = aws_eks_cluster.this.endpoint
  cluster_ca_certificate = base64decode(aws_eks_cluster.this.certificate_authority[0].data)
  load_config_file       = false

  exec {
    api_version = "client.authentication.k8s.io/v1beta1"
    args        = ["eks", "get-token", "--cluster-name", aws_eks_cluster.this.id]
    command     = "aws"
  }
}
    kubectl = {
      source  = "gavinbunney/kubectl"
      version = "~> 1.14"
    }
romancherednikovopsfleet commented 1 year ago

I'v switch to this provider - https://registry.terraform.io/providers/alekc/kubectl/latest/docs