johnybradshaw / acc-lke

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Akamai Connected Cloud - Linode Kubernetes Cluster

acc-lke module

This module creates a Linode Kubernetes (LKE) Cluster on the Akamai Connected Cloud using Terraform.

Important

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

Requirements

The following requirements are needed by this module:

Providers

The following providers are used by this module:

Required Inputs

The following input variables are required:

Description: n/a

Type:

object({
    api_token = string
  })

Optional Inputs

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"
  ]
}

Outputs

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.

Usage

Sample usage of this module is as shown below. For detailed info, look at inputs and outputs.

Step 1

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
}

Note

  • lke is the name of the module. You can use any name you want.

Step 2

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
}

Step 3

Verify your settings using the following command:

terraform init
terraform plan

Step 4

Apply the changes

terraform apply

About

License:Apache License 2.0


Languages

Language:HCL 100.0%