Building an LKE Cluster with OpenTofu
When I learned that the ACM was going to drop Pluralsight support, I decided I should finish up some of the courses I was taking. One of those was a basic Kubernetes course that I wanted to use as a refresher. I often go back to entry-level documentation so that I can reinforce my understanding of the basics.
I realized that I’d need a k8s cluster for the projects in the course. I don’t have enough hardware laying around any longer to build something and I didn’t want to mess with minikube etc. I decided I’d use my Linode account to spin up clusters on demand as I worked on the course.
Building things manually is typically a pain so I took a swing at it with OpenTofu. I use Terraform and OpenTofu daily but I haven’t used the Linode provider yet. It turned out to be a lot nicer than I expected.
Using the LKE Cluster docs, I quickly put together this simple configuration in order to create an LKE cluster with the smallest Linodes available:
terraform {
required_providers {
linode = {
source = "linode/linode"
version = "~> 2.0"
}
}
}
provider "linode" {
token = var.linode_token
}
variable "linode_token" {
description = "Linode API token"
type = string
sensitive = true
}
resource "linode_lke_cluster" "smol_cluster" {
label = "smol-lke-cluster"
k8s_version = "1.33"
region = "us-southeast"
tags = ["terraform"]
pool {
type = "g6-standard-1"
count = 3
}
}
output "kubeconfig" {
value = linode_lke_cluster.smol_cluster.kubeconfig
sensitive = true
}
output "api_endpoints" {
value = linode_lke_cluster.smol_cluster.api_endpoints
}
output "status" {
value = linode_lke_cluster.smol_cluster.status
}I have a lot of little configuration snippets laying around. I’m going to try to consolidate them with this one here in my Devoops Junk Drawer as I remember to.
#100daystooffload #linux #linode #lke #terraform #opentofu #devops