'terraform kubeconfig issue

After the cluster is created, I want to continue the deployment, but I cannot read the kubeconfig file properly. How can i fix that ? By the way, I can connect my cluster with .kubeconfig file. But terraform cannot.

'config_path' refers to an invalid path: ".kubeconfig": stat .kubeconfig: no such file or directory

Error: Failed to create deployment: Post "http://localhost/apis/apps/v1/namespaces/default/deployments": dial tcp 127.0.0.1:80: connect: connection refused

deployment.tf

resource "kubernetes_deployment" "nginx_deployment" {
  provider = kubernetes.kb
  ...
  ...
}

provider.tf

terraform {
  required_providers {
    ovh = {
      source = "ovh/ovh"
      version = "0.16.0"
    }
    kubernetes = {
      source = "hashicorp/kubernetes"
      version = "2.8.0"
    }

    local = {
      source = "hashicorp/local"
      version = "2.1.0"
    }
  }
}

# Configure the OVHcloud Provider
provider "ovh" {
  endpoint           = "ovh-ca"
  application_key    = ""
  application_secret = ""
  consumer_key       = ""
}

provider "kubernetes" {
  alias = "kb"
#  load_config_file = "false"
  config_path = ".kubeconfig"
}

provider "local" {
  #comment
}

resource "local_file" "kubeconfig" {
  content  = ovh_cloud_project_kube.my_kube_cluster.kubeconfig
  filename = ".kubeconfig"
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source