I'm currently going through the terraform tutorial from hashicorp. I have a K8S cluster to which I access from my machine (~/.kube/config).
I tried to create a small tf file with
provider "kubernetes" {}
But when I run
terraform apply
I get this error
Error: Error applying plan:
1 error(s) occurred:
* kubernetes_pod.nginx: 1 error(s) occurred:
* kubernetes_pod.nginx: Post "http://localhost/api/v1/namespaces/default/pods": dial tcp 127.0.0.1:80: connect: connection refused
I've also tried to specify the path to my k8s config
load_config_file = "true"
config_path = "~/.kube/config"
but I have the same issue
I would also like to connect by specifying the certs:
provider "kubernetes" {
host = "https://104.196.242.174"
client_certificate = file("~/.kube/client-cert.pem")
client_key = file("~/.kube/client-key.pem")
cluster_ca_certificate = file("~/.kube/cluster-ca-cert.pem")
load_config_file = false # when you wish not to load the local config file
}
But I can't find how to generate those certs from the .kube/config or directly with kubectl.