This module creates a Linode Kubernetes (LKE) Cluster on the Akamai Connected Cloud using Terraform.
The readme.md has the following sections:
- Requirements - Min requirements for the module to run
- Providers - Providers required by the module
- Inputs- Inputs to the module
- Outputs - Outputs from the module
- Usage - How to use the module
The following requirements are needed by this module:
The following providers are used by this module:
- linode.default (2.10.1)
The following input variables are required:
Description: n/a
Type:
object({
api_token = string
})
The following input variables are optional (have default values):
Description: LKE Cluster Configuration
Type:
object({
name = string // Name of the LKE cluster
region = string // Linode region for the LKE cluster
k8s_version = string // Kubernetes version for the LKE cluster
high_availability = bool // Enable or disable high availability
tags = list(string) // Tags for the LKE cluster
node_pools = list(object({ // List of node pools for the LKE cluster
type = string // Type of nodes in the pool
count = number // Number of nodes in the pool
autoscaler = optional(object({
min_nodes = number
max_nodes = number
})) // Enable or disable autoscaling
}))
})
Default:
{
"high_availability": true,
"k8s_version": "1.27",
"name": "lke-cluster",
"node_pools": [
{
"autoscaler": {
"max_nodes": 5,
"min_nodes": 3
},
"count": 3,
"type": "g6-standard-2"
}
],
"region": "fr-par",
"tags": [
"acc",
"k8s",
"lke"
]
}
The following outputs are exported:
Description: The API endpoint for the deployed LKE cluster.
Description: The ID of the LKE cluster generated
Description: The Kubeconfig file for the deployed LKE cluster.
Description: The link to the LKE cluster in the Linode Cloud Manager.
Description: List of node IDs for the deployed LKE cluster.
Description: The tags for the deployed LKE cluster.
Sample usage of this module is as shown below. For detailed info, look at inputs and outputs.
In your main.tf, add the following code:
# Create the LKE cluster
module "lke" {
source = "./modules/lke"
providers = {
linode.default = linode
}
linode_config = var.linode_config # Pass the Linode configuration to the module
lke_cluster = var.lke_cluster # Pass the LKE cluster configuration to the module
}
output "lke" {
description = "Important outputs from LKE cluster."
value = module.lke # Output from the lke module
}
- lke is the name of the module. You can use any name you want.
In your provider.tf, add the following code, if it doesn't exist already:
terraform {
required_version = ">= 1.5.7"
required_providers {
linode = {
source = "linode/linode"
version = ">= 2.9.3"
configuration_aliases = [ linode.default ]
}
}
}
provider "linode" {
alias = "alternative"
token = var.linode_config.api_token
}
Verify your settings using the following command:
terraform init
terraform plan
Apply the changes
terraform apply