Kubernetes

Provision a Kubernetes Cluster with Spacelift and Terraform

Provision a Kubernetes Cluster with Spacelift and Terraform

By now, you have probably heard about the initial availability of Kubernetes integration in Spacelift. You can read more about the announcement and review the documentation.

Spacelift, like many of our customers, utilizes Kubernetes in a variety of ways. Before the integration, we operated Kubernetes or Public worker pools, testing and hosting the Spacelift platform. Now that the Kubernetes integration is initially available, we thought it would be good to provide a simple way for you to provision a Kubernetes cluster on AWS utilizing Terraform with Spacelift.

This blog will guide you through the process of deploying a Terraform based deployment of an EKS cluster with Spacelift. Below is an example of the cloned Terraform repository.

devrel-k8s-worker-cluster

Repository Creation

Start by cloning the repository found on GitHub and commit to your respective VCS provider. We made a few changes, but that was only to help with the naming and possible confusion in our dev environment. Otherwise, utilizing the repository as-is will work.

Create EKS Cluster Stack

In Spacelift, click the Add Stack button to create a Stack.

Integrate VCS

  • Select the repository you created in the initial step, as seen in the picture.
Integrate VCS

Configure Backend

For this example, I will keep the default selections.

Configure Backend

Define Behavior

If you need to modify the configuration, select the arrow next to Show Advanced Options. You can find out more about these options by reading the documentation.

Define Behavior

Name Stack

Name the stack and provide any labels or descriptions.

Name Stack

Configure Integrations

To provision the EKS cluster, this Stack requires integration with AWS. 

Navigate to the Settings, Integrations page and select the dropdown arrow to access the following selection screen:

Integrations

The following links will help you set up the necessary integration with your Cloud Provider of choice.

To simplify things, I decided to utilize an AWS role that already exists with the necessary permissions to provide the essential resources associated with this Terraform example.

AWS

Trigger a Run

To Trigger a Run, select Trigger on the right side of the Stacks view.

Trigger a Run

Trigger Run Status

Planning

After you manually trigger the Run in the Stack view, Spacelift will deploy a runner image, initialize the Cloud Provider, and run a Terraform Plan based upon the contents of the Terraform code.

After a successful planning phase, you can check the log to see the planned changes.

Trigger Run Status - Planning

To confirm the Triggered run, click the CONFIRM button at the top of the screen.

Finished Deployment

The following screen highlights the Finished Run and output from a successful deployment to your Kubernetes cluster.

Trigger Run Status - Finished Deployment

Outputs

To review the outputs associated with this EKS cluster deployment, navigate to the outputs page. You can find all pertinent information about this cluster.

Outputs

You have completed the deployment of an EKS cluster via Terraform with Spacelift!

Accomplish the Mission

Get started on your journey by signing up for a Free Trial and taking it for a spin around the world! Sign-up is as easy as authenticating with the provider of your choice.

Terraform Management Made Easy

Spacelift effectively manages Terraform state, more complex workflows, supports policy as code, programmatic configuration, context sharing, drift detection, resource visualization and includes many more features.

Start free trial