GitOps Bootstrap K8s with Terraform 🚀

Using a simple managed Kubernetes cluster on Digitalocean you can bootstrap it with Argo CD and an inital app-of-apps seed application. then all your applications from a git repo are automagically pulled onto your cluster. After this initial cluster bootstrapping argocd handle the deployment of all your kubernetes resources

Dependencies

Docker

The following may be installed with brew. Run brew bundle

Required:

Minikube Terraform Kubernetes Helm

Optional:

doctl k9s

Dev Quickstart

Start minikube

minikube start

Set up Terraform environment variables Using the workspace named dev here makes sure the terraform runs against a local minikube cluster

export TF_WORKSPACE=dev

Force Terraform to not use remote execution. We only care about terraform cloud state management

export TF_FORCE_LOCAL_BACKEND=1

The backend here is remote using terraform cloud. sign up for a free account, create an organization, skip creating a workspace and create a user API token.

export TF_CLI_ARGS_init="-backend-config='token=<TF CLOUD TOKEN>' -backend-config='organization=<TF CLOUD ORG NAME>'"

Create a digitalocean access token or make one up if just local testing

export DIGITALOCEAN_ACCESS_TOKEN=<DO API TOKEN>

Now create a new terraform workspace

terraform workspace new $TF_WORKSPACE

Run the standard terraform commands

terraform init

terraform plan

terraform apply

Check your local minikube cluster with kubectl or a tool like k9s and see the various pods created. you can even portforward argo-cd admin UI and sync to get all the example apps installed. You can get the argocd admin UI password here