Hello,
I’m trying to configure a kubernetes cluster that was previously created with rancher. To do that, I thought that I’d get the kubeconfig file right from rancher with the rancher2_cluster
data source, and then put it in a standard place with a local_file
resource.
Unfortunately, the terraform kubernetes provider is failing with:
Error: Failed to load config (; default context):
invalid configuration: no configuration has been provided
in provider \"kubernetes\"
It seems that the provider must be defined before any execution, including the kubeconfig retrieval.
My provider definition file:
provider "rancher2" {
api_url = "https://rancher.example.com"
token_key = "token-xxxxx:MyTOKEN"
}
# Get kubeconfig file (from rancher)
data "rancher2_cluster" "my_cluster" {
name = "my_cluster"
}
resource "local_file" "kubeconfig" {
filename = "/root/.kube/config"
content = "${data.rancher2_cluster.my_cluster.kube_config}"
}
provider "kubernetes" {
config_path = local_file.kubeconfig.filename
}
Is this expected? Can I do something about it?