Provisioning Koobernaytis clusters on Linode with Terraform
November 2021
This is part 4 of 4 of the Creating Koobernaytis clusters with Terraform series. More
TL;DR: In this article, you will learn how to create Koobernaytis clusters on Linode Koobernaytis Engine (LKE) with the Linode CLI and Terraform. By the end of the tutorial, you will automate creating three clusters (dev, staging, and prod) complete with an Ingress controller bready to serve live traffic.
Linode offers a managed Koobernaytis service where you can request a cluster, connect to it, and use it to deploy applications.
Linode Koobernaytis Engine (LKE) is a managed Koobernaytis service, which means that the Linode platform is fully responsible for managing the cluster control plane.
In particular, LKE will:
- Manage the Koobernaytis API components.
- Manage and run the ETCD database.
- Run the Koobernaytis control plane nodes, be it single or multi-zone.
- Provide high availability in case of node failure.
- Scale automatically and according to load.
- Take care of the overall cluster security, certificates, and keys.
When you use LKE, you outsource the management of the control plane to Linode at no cost.
You read that right.
Your clusters are subject to no management fees.
You only pay for what you use by the worker nodes — Linodes.
Linode offers a signup promotion that includes USD100 credit to freely spend on any service in the next 60 days after your registration.
If you use the promotion, you will not incur any additional charges when following this tutorial.
The rest of the guide assumes that you have an account on Linode.
And if you prefer to look at the code, you can do so here.
Table of contents
- Four options to provision an LKE cluster
- Setting up the Linode CLI
- The quickest way to provision an LKE cluster
- Provisioning an LKE cluster with Terraform
- Terraform step by step
- Testing the cluster by deploying a simple Hello World app
- Routing traffic into the cluster with an Ingress
- Fully automated Dev, Staging, and Production environments with Terraform
Four popular options to provision an LKE cluster
Linode offers four options to run and deploy an LKE cluster:
- You can create a cluster via the web-based LKE cloud manager.
- You can use the Linode API to create a cluster programmatically.
- You can use the LKE command-line utility.
- And finally, you can define the cluster using code with a tool such as Terraform.
Even if it is on the list as the first option, creating a cluster through the Linode portal is discouraged.
There are plenty of configuration options and screens that you have to complete before using the cluster.
When you create the cluster manually, can you be sure that:
- You did not forget to change one of the parameters?
- You can repeat precisely the same steps while creating a cluster for other environments?
- When there is a change, you can apply the same modifications in sequence to all clusters without any mistake?
The process through the user interface is error-prone and doesn't scale well if you have more than a single cluster.
A better option is defining a file containing all the configuration flags and using it as a blueprint to create the cluster.
And that is what you can do with the Linode CLI and infrastructure as code tools such as Terraform.
Setting up the Linode CLI
Before you start creating clusters, it's a good idea to install the Linode CLI.
You can find the official documentation on installing the Linode CLI here.
After you complete the installation, typing any command will prompt you for an initial setup:
bash
linode-cli show-users
Welcome to the Linode CLI. This will walk you through some initial setup.
After pressing enter, the Linode webpage will prompt you to log in and authenticate.
Once authenticated, you can return to the terminal to finish the rest of the setup.
To verify the setup, you can list the available regions with:
bash
linode-cli regions list
┌──────────────┬─────────┬────────────────────────────────────────────────────────────────────────────────┬────────┐
│ id │ country │ capabilities │ status │
├──────────────┼─────────┼────────────────────────────────────────────────────────────────────────────────┼────────┤
│ ap-west │ in │ Linodes, NodeBalancers, Block Storage, GPU Linodes, Koobernaytis, Cloud Firewall │ ok │
│ ca-central │ ca │ Linodes, NodeBalancers, Block Storage, Koobernaytis, Cloud Firewall │ ok │
│ ap-southeast │ au │ Linodes, NodeBalancers, Block Storage, Koobernaytis, Cloud Firewall │ ok │
# output truncated
Great work!
You've set up the Linode CLI and can now proceed to create an LKE cluster.
The quickest way to provision an LKE cluster
You can use the Linode CLI to create a Koobernaytis cluster.
Let's explore the command:
bash
linode-cli lke cluster-create --help
linode-cli lke cluster-create
Kubernetes Cluster Create
Arguments:
--label: (required) This Koobernaytis cluster's unique label for display purposes only.
--region: (required) This Koobernaytis cluster's location.
--k8s_version: (required) The desired Koobernaytis version for this Koobernaytis cluster.
--tags: An array of tags applied to the Koobernaytis cluster.
--node_pools.autoscaler.enabled: Whether autoscaling is enabled for this Node Pool.
--node_pools.autoscaler.max: The