Terraform GitOps pipeline for Kubernetes with Flux V2

Ravi Yasakeerthi
2 min readJun 10, 2021

First, we need a Kubernetes cluster for this exercise, Let’s use kind

kind is a tool for running local Kubernetes clusters using Docker container nodes. It’s basically good for testing Kubernetes and Local development.

I’m trying this out in macOS. You can find Installation steps for other OS types here

brew install kind

Now we can start creating a local cluster

kind create cluster

Check Cluster and nodes

Set context for kubectl

Please clone the following repo

Run Terraform Init

Run Terraform Plan

Run Terraform Apply

terraform apply --var-file=vars/dev.tfvars

Once Terraform applies completely. You can check the pod status.

Also, we can see it’s successfully created a new git repo and sync the cluster status to it.

What this means for operators, git is used over kubectl (helm …) to perform cluster operations. pushing to configured branch triggers a deployment to the cluster. So you can use your favorite git workflow to manage Kubernetes clusters.

As of now, it's flux duty to watch all configured repo’s and pull changes to the cluster.

--

--