How do I manage the k8s cluster with the kubernetes terraform provider?

Hi everyone!

I am trying to set up my infrastructure with Terraform, so far, I managed to deploy an LKE cluster.

The next step is setting up the "kubernetes" and "helm" providers in Terraform, but they take in a kubeconfig path while the LKE resource outputs a variable (if I am right).

Things I have tried

So I have been trying things like this without any success.

provider "kubernetes" {
  config_path = linode_lke_cluster.my-cluster.kubeconfig
}

I also tried decoding the file.

I have also tried getting creds to use a different method of setting up the kubernetes by doing stuff like this:

linode_lke_cluster.my-cluster.kubeconfig.clusters.0.cluster…

Has anybody worked with this approach before and how have you passed the creds/config to the Kubernetes provider?

This is how I have set up the cluster:

resource "linode_lke_cluster" "my-cluster" {
    label       = "my-cluster"
    k8s_version = "1.20"
    region      = "eu-central"
    tags        = ["dev"]

    pool {
        type  = "g6-standard-1"
        count = 3
    }
    }

I am new to the whole terraform thing so maybe I have missed something important.

1 Reply

Linode Staff

It looks like your main.tf file may be a bit misconfigured. We have a guide that can walk you through deploying an LKE cluster using Terraform, and it includes an example main.tf configuration that you can refer to while substituting your needed variables:

Deploy an LKE Cluster using Terraform

This section specifically seems to be what you're looking for!

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct