siderolabs / terraform-provider-talos

Mozilla Public License 2.0
137 stars 17 forks source link

Why is talos_cluster_kubeconfig suddenly being considered to be a resource? #202

Closed Sacro closed 1 month ago

Sacro commented 2 months ago

Following on from #187, why is it no longer a data source? That's what it is, we don't configure it, we retrieve it, it's something the cluster generates, not Terraform.

rotilho commented 1 month ago

The reason is that data do not keep state, this cause all resources that use the data.talos_cluster_kubeconfig data to drift.

Sacro commented 1 month ago

The reason is that data do not keep state, this cause all resources that use the data.talos_cluster_kubeconfig data to drift.

What could drift, and how?

rotilho commented 1 month ago

Basically any resource that uses it. In my case it was the secret manager, every apply was replacing the kubeconfig.

frezbo commented 1 month ago

This is to allow regeneration the kubeconfig when it nears expiration and TF data sources provides no way to store that state

Sacro commented 2 weeks ago

So how are we supposed to bootstrap flux now then? I can't pass resources to a provider.

  kubernetes = {
    host                   = data.talos_cluster_kubeconfig.kubeconfig.kubernetes_client_configuration.host
    client_certificate     = base64decode(data.talos_cluster_kubeconfig.kubeconfig.kubernetes_client_configuration.client_certificate)
    client_key             = base64decode(data.talos_cluster_kubeconfig.kubeconfig.kubernetes_client_configuration.client_key)
    cluster_ca_certificate = base64decode(data.talos_cluster_kubeconfig.kubeconfig.kubernetes_client_configuration.ca_certificate)
  }
rotilho commented 2 weeks ago

@Sacro

provider "kubernetes" {
  host = talos_cluster_kubeconfig.home.kubernetes_client_configuration.host
  cluster_ca_certificate = base64decode(talos_cluster_kubeconfig.home.kubernetes_client_configuration.ca_certificate)

  client_key = base64decode(talos_cluster_kubeconfig.home.kubernetes_client_configuration.client_key)
  client_certificate = base64decode(talos_cluster_kubeconfig.home.kubernetes_client_configuration.client_certificate)
}
Sacro commented 2 weeks ago

Stupid me, no idea why I thought it needed a data prefix! Thanks