I've spun up a simple k8s cluster in my lab. In the process of doing so, I generated a kubeconfig located at ~/.kube/config
. I can confirm that the config is good using kubectl. I can I am attempting to configure resources on this cluster using terraform, and looking at the documentation here it appears that I can just reference the kubeconfig in the provider to handle authentication to the cluster, which I did.
provider "kubernetes" {
config_path = "~/.kube/config"
}
Unfortunately, however, that doesn't seem to work. The output from the terraform apply command seems to indicate that it's trying to hit the cluster via localhost:80 rather than the endpoint defined in the config file. I saw some mention online of needing to specify config_context
as well, but unfortunately, that resulted in the same error as seen here:
│ Error: Post "http://localhost/api/v1/namespaces": dial tcp 127.0.0.1:80: connect: connection refused
│
│ with kubernetes_namespace.test,
│ on main.tf line 35, in resource "kubernetes_namespace" "test":
│ 35: resource "kubernetes_namespace" "test" {
I feel like I must be missing something here, but can't for the life of me figure out what it could possibly be. I would assume that the kubeconfig file should be sufficient for the auth. Any thoughts?