Terraform

Terraform is a declarative tool for building and maintaining infrastructure, like your clusters and node pools on Symbiosis.

This guide will show how to setup a cluster using terraform.

For a complete reference of the Symbiosis terraform provider see the official documentation.

Installing terraform

Terraform is a command line tool. Links to download Terraform can be found here.

Ensure that terraform is properly installed:

which terraform

Generate API Key

In order for terraform to be able to create and delete clusters on your behalf it must have a valid Symbiosis API Key.

API Keys can be created through the Web UI under auth & membershipapi keys.

Creating a Cluster

Create the following file and name it main.tf.

terraform {
  required_providers {
    symbiosis = {
      source = "symbiosis-cloud/symbiosis"
      version = ">= 0.3"
    }
  }
}

variable "symbiosis_api_key" {}

provider "symbiosis" {
  api_key = var.symbiosis_api_key
}

resource "symbiosis_cluster" "staging" {
  name = "production-cluster"
  region = "germany-1"
}

resource "symbiosis_node_pool" "general" {
  cluster = symbiosis_cluster.staging.name
  name = "general-pool"
  node_type = "general-1"
  quantity = 2
}

resource "symbiosis_node_pool" "cpu" {
  cluster = symbiosis_cluster.staging.name
  name = "cpu-pool"
  node_type = "memory-3"
  quantity = 4
}

The manifest will provision one Kubernetes cluster with two node pools, one pool with two general purpose nodes and another pool with four memory optimized nodes. For a list of all node types see section on Nodes.

To create the cluster issue the following command:

terraform apply --var "symbiosis_api_key=<YOUR API KEY>"

Terraform will output a diff showing the new resources that will be created, make sure the diff aligns with your expectations before proceeding. If any future changes are made issuing the same above command will update the configuration.

The terraform state will be stored locally as no backend has been defined. It's considered best practice (and especially useful if you work with others) to define a remote backend, see the terraform documentation.