Doks with Terraform

Codebase to create a simple DOKS cluster with terraform and Nginx Ingress Controller:

Requirements:

Create Digital Ocean Cluster

This process initialize Digital Ocean kubernetes cluster with node pools and deploy Nginx Ingress controller.

# Generate your access token here: https://cloud.digitalocean.com/account/api/tokens
# Edit do_token inside terraform.tfvars

(~) $ terraform init
(~) $ cp terraform.tfvars.example terraform.tfvars

(~) $ terraform apply

Get IP from load balancer created by Nginx Ingress

Waiting terraform finish and open Load Balance Console to get LB IP.

Download your kubeconfig file to deploy apps

After completion, add the k8s settings made in DO to your .kube/config. We use the doctl doctl is the official DigitalOcean command line interface (CLI).

(~) $ kubernetes cluster kubeconfig save <your-cluster-name>

Follow Digital ocean instructions to get your kubeconfig an interact with cluster, recommended Lens - K8S IDE.

TODO

  • Create specific firewall inside process.
  • An apps folder to maintain all manifests inside same repo.

Knowledge issues

  • Terraform Destroy stuck in a invalid state because delete cluster before Nginx ingress not destroying Loadbalancer created, need enter in Load Balance Console and finish.

References: