GitOps With Flux (Complete Setup Guide)

Creating A Kubernetes Cluster

Depending on what type of environment you’re in or what you have access to, you can get a Kubernetes cluster up and running in a few different ways:

  • On your localhost with something like Minikube
  • On a Kubernetes service like AKS, EKS, or GKE
  • On a bunch of VMs
  • On Rasberry Pis using K3s
  • And a bunch of other methods…

The App

The whole idea behind GitOps is for a tool (like Flux) to look in your Git repos, check out the Kubernetes manifest, and confirm that what’s in the Kubernetes manifest is what’s on your Kubernetes cluster. Because of that, we need a Kubernetes application.

Flux Configuration

When you’re getting ready to install Flux, there are a few components:

  • The command-line tool
  • Connecting to GitHub
  • GitHub credentials
  • Deploying Flux

Installing Flux

To install Flux, you’ll have to check out the installation guide found here for your operating system.

brew install fluxcd/tap/flux
flux check --pre

Install Flux

To install flux, you’ll need to specify your GitHub username.

flux bootstrap github \\
--owner=adminturneddevops \\
--repository=kubernetes-examples \\
--branch=main \\
--path=./clusters/my-cluster \\

Deploying An Application

Now that Flux is installed, it’s time to deploy an application. The first thing you should do is clone the code repository from The App section and fork it to your GitHub organization.

Add The App To Flux

First, add the nginx app to Flux. The command below will pull the Nginx app in 30 second intervals.

flux create source git kubernetes-examples \\
--url= \\
--branch=main \\
--interval=30s \\
--export > ./clusters/my-cluster/podinfo-source.yaml

Deploy The Nginx App

To deploy the app, you’re going to use Kubernetes kustomize, which is a tool for customizing Kubernetes applications in a declarative fashion.

flux create kustomization kubernetes-examples \\
--target-namespace=default \\
--source=kubernetes-examples \\
--path="./kustomize" \\
--prune=true \\
--interval=5m \\
--export > clusters/my-cluster/podinfo-kustomization.yaml

Ensure That The App Is Deployed

To ensure that the app is deployed, you can use the flux get command to see the apps that are running and managed by Flux.

flux get kustomizations --watch



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Michael Levan

Michael Levan


Leader in Kubernetes consulting, research, and content creation ┇AWS Community Builder (Dev Tools Category)┇ HashiCorp Ambassador