This section describes the usage of Terraform to provision the DigitalOcean infrastructure.
The Terraform code provided in this repository provisions the following:
- DigitalOcean Kubernetes cluster digitalocean-kubernetes.tf
- DigitalOcean Container Registry digitalocean-container-registry.tf
- Input variables and main module behavior is controlled via variables.tf
- Install and configure Argo CD via argo-helm-config.tf
All essential aspects are configured via Terraform input variables. In addition, a bootstrapper.tfvars.sample file is provided to get you started quickly.
Follow the below steps to get started:
Important: List Kubernetes versions that can be used with DigitalOcean clusters.
doctl k8s options versions
Slug Kubernetes Version Supported Features
1.28.2-do.0 1.28.2 cluster-autoscaler, docr-integration, ha-control-plane, token-authentication
1.27.6-do.0 1.27.6 cluster-autoscaler, docr-integration, ha-control-plane, token-authentication
Choose the corresponding Slug
and in the variables.tf
file, modify the default value of the doks_k8s_version
variable with the chosen Slug.
variable "doks_k8s_version" {
type = string
default = "1.28.2-do.0"
description = "DOKS Kubernetes version"
}
-
Clone this repo and change the directory to
infrastructure/terraform
-
Initialize Terraform backend:
terraform init
-
Copy and rename the
bootstrapper.tfvars.sample
file tobootstrapper.tfvars
:cp bootstrapper.tfvars.sample bootstrapper.tfvars
-
Open the
bootstrapper.tfvars
file and adjust settings according to your needs using a text editor of your choice (preferably with HCL lint support). -
Use
terraform plan
to inspect infra changes before applying:terraform plan -var-file=bootstrapper.tfvars -out tf-bootstrapper.out
-
If you're happy with the changes, issue
terraform apply
:terraform apply "tf-bootstrapper.out"
If everything goes as planned, you should be able to see all infrastructure components provisioned and configured as stated in the
bootstrapper.tfvars
input configuration file. -
Use doctl to update your Kubernetes context
# <cluster-id> can be found in the output of the terraform module doctl kubernetes cluster kubeconfig save <cluster-id>
Follow this one-click guide to integrate the registry with the Kubernetes cluster.