Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Example DigitalOcean Kubernetes cluster using Terraform

This repository showcases using Terraform to provision a new DigitalOcean VPC, and managed Kubernetes cluster with nodes within.

Install and configure

Setup doctl on your system, and initialise auth:

doctl auth init

When requested, enter a token generated from the Applications & API section of the DigitalOcean dashboard.

Now export the token as an environment variable so Terraform can find it:

export TF_VAR_do_token=YOUR_TOKEN_HERE

Setup variables

name and region are required. cluster_version specifies the Kubernetes version to use (currently defaults to 1.18.)

  • doctl kubernetes options regions shows which regions are available, use the slug value for region.
  • doctl kubernetes options versions shows which Kubernetes versions are available, use the slug value for cluster_version.

Provisioning

terraform init
terraform apply

Configure kubectl

Retrieve the kubeconfig using doctl (replacing mycluster with the name you specified in terraform.tfvars):

doctl kubernetes cluster kubeconfig save mycluster

Test it works

kubectl get nodes -o wide

Tearing down

terraform destroy

What now?

See the Kubernetes on DigitalOcean documentation for general information on the service, and Kubernetes on DigitalOcean resources for guides and tutorials on building and operating Kubernetes. You might also want to check out a guide on upgrading DigitalOcean Kubernetes clusters.

Some examples of integrations with DigitalOcean you can configure: