Spinning Up a Civo Kubernetes Cluster

Kubernetes is powerful, but setting it up doesn't have to be a painful process. If you're looking for a fast, simple way to get a cluster running, Civo is a fantastic option. With lightning-fast provisioning and a developer-friendly interface, it's ideal for test environments and quick deployments.

In this guide, you’ll learn how to create a Civo Kubernetes cluster in two ways:

  • using the Civo CLI
  • using Terraform

We'll start from scratch, assuming no command-line tools or Terraform providers are available.


🧰 Prerequisites

Before we get started, you'll need:

  • A Civo account
  • An API key (grab it from the Civo dashboard)
  • A working terminal on macOS or Linux (Windows WSL is fine too)
  • Basic understanding of Kubernetes and Terraform

⚙️ Option 1: Create a Cluster with the Civo CLI

Step 1: Install the Civo CLI

Install the CLI using Homebrew (macOS/Linux):

brew install civo

Alternatively, you can download a binary from the Civo GitHub Releases if you’re not using Homebrew.

Verify it's installed:

civo version

Step 2: Add Your API Key

civo apikey add my-key-name YOUR_API_KEY

Make it your default:

civo apikey current my-key-name

Step 3: Create a Kubernetes Cluster

Here we'll create a 3-node kubernetes cluster with medium servers, a firewall open to ports 80, 443 for http and https and 6443 for the Kubernetes control plane, in your current region.

Setting --remove-applications=traefik2-nodeport will give us an empty k8s cluster to work from.

civo kubernetes create my-cluster --size g4s.kube.medium --nodes 3 \
--create-firewall --firewall-rules "80,443,6443" \
--remove-applications=traefik2-nodeport --wait

Optionally, you can create a small single-node cluster with

civo kubernetes create my-small-cluster --size g4s.kube.small --nodes 1 \
--create-firewall --firewall-rules "80,443,6443" \
--remove-applications=traefik2-nodeport --wait

Step 4: Verify the Cluster

civo kubernetes list

Step 5: Download the Kubeconfig and switch to using it

civo kubernetes config my-cluster --save
kubectl config use-context my-cluster

Now you're ready to kubectl get nodes.


🌱 Option 2: Create a Cluster with Terraform

Let's use the civo terraform provider.

Step 1: Install Terraform

Use Homebrew:

brew tap hashicorp/tap
brew install terraform

or using Homebrew and tfenv

brew install tfenv
tfenv install latest

Verify:

terraform version

Step 2: Set Up the Terraform Provider

Create an environment variable for your civo API key:

export CIVO_TOKEN=<your token>

Create a directory and main.tf file:

mkdir civo-k8s && cd civo-k8s
touch main.tf

Paste in:

terraform {
  required_providers {
    civo = {
      source  = "civo/civo"
      version = "1.1.5"
    }
    local = {
      source  = "hashicorp/local"
      version = "2.5.3"
    }
  }
  required_version = ">0.13"
}

provider "civo" {
  region = "NYC1"
}

data "civo_firewall" "demo" {
  name = "default-default"
}

resource "civo_kubernetes_cluster" "demo" {
  firewall_id      = data.civo_firewall.demo.id
  write_kubeconfig = true
  applications     = "metrics-server"
  pools {
    size       = "g4s.kube.small"
    node_count = 3
  }
}

resource "local_file" "kubeconfig" {
  filename = "${path.module}/${civo_kubernetes_cluster.demo.name}-kubeconfig"
  content  = civo_kubernetes_cluster.demo.kubeconfig
}

output "kubernetes_name" {
  value       = civo_kubernetes_cluster.demo.name
  description = "The randomly generated name for this cluster"
}

output "kubeconfig_filename" {
  value       = local_file.kubeconfig.filename
  description = "The kubeconfig filename"
}

Step 3: Initialize, Plan and Apply

terraform init
terraform plan
terraform apply

Confirm the plan, and Terraform will do the rest. The cluster usually spins up in under 2 minutes.

You're good to go with kubectl.

kubectl --kubeconfig=$(terraform output -raw kubeconfig_filename) get nodes

You can download the code from this repo: https://github.com/markcallen/civo-example


🧼 Cleanup

To delete the cluster via CLI:

civo kubernetes remove my-cluster --yes

Or with Terraform:

terraform destroy

🧠 Final Thoughts

Civo makes Kubernetes clusters almost too easy to manage. Whether you're spinning up ephemeral environments, testing CI/CD pipelines, or just getting started, Civo offers a low-friction path to cloud-native development. Use the CLI when working quickly, and Terraform when building infrastructure as code.