VOOZH about

URL: https://thenewstack.io/tutorial-a-gitops-deployment-with-flux-on-digitalocean-kubernetes/

⇱ Tutorial: A GitOps Deployment with Flux on DigitalOcean Kubernetes - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2022-01-07 09:59:37
Tutorial: A GitOps Deployment with Flux on DigitalOcean Kubernetes
analysis,
CI/CD / DevOps / Software Development

Tutorial: A GitOps Deployment with Flux on DigitalOcean Kubernetes

the step-by-step guide to using FluxCD with DigitalOcean Kubernetes.
Jan 7th, 2022 9:59am by Janakiram MSV
👁 Featued image for: Tutorial: A GitOps Deployment with Flux on DigitalOcean Kubernetes
GitOps is gaining momentum as the preferred mechanism for continuous deployment. Based on the demo that I showed during the DigitalOcean Deploy Conference in November 2021, I am bringing you the step-by-step GitOps tutorial to perform deployments at scale. We will manage the deployment of a simple web application across three different DigitalOcean Kubernetes clusters running in Bangalore, Singapore, and London regions. The Weaveworks-managed open source Flux, the most popular CD tool will be used to bootstrap GitOps, configure Ingress infrastructure, and finally deploy the application. 👁 GitOps Example
We will follow some of the best practices of GitOps for this tutorial such as leveraging git as the single source of truth, using git workflow to deploy infrastructure and applications. Except for the bootstrapping, we will always use the git command and not rely on the CLIs (fluxctl and kubectl) for the configuration. We will incrementally add an ingress component (infrastructure) packaged as a Helm Chart and a web application (apps) declared in a set of YAML files to the repo, which will be eventually reconciled across all the clusters. Whether it is one cluster or tens of thousands of clusters, the workflow remains the same. The objective of this tutorial is to show at-scale deployment targeting multiple Kubernetes clusters.

Prerequisites

Step 1: Preparing the Environment

Let’s begin by launching the Kubernetes clusters with doctl CLI. By the end of this step, we should have three clusters running in three different regions of the Digital Ocean cloud platform. Once the clusters are provisioned, we will download kubeconfig and rename the context. 👁 GUI showing Kubernetes clusters
Next, create a GitHub repository that will be used for storing the artifacts. Let’s call this do-gitops-demo. Assuming you have created a GitHub personal access token, set the environment variable for Flux to access the repository. export GITHUB_TOKEN=YOUR_GITHUB_PERSONAL_ACCESS_TOKEN

Step 2: Bootstrapping Clusters for GitOps

Let’s make sure that the cluster is ready for Flux. We will do this by running the command, flux check. 👁 flux check
Let’s bootstrap the clusters by pointing them to the GitHub repository created in the previous step. This results in two things — Flux adding the manifests to the fleet directory of the repo and reconciling the cluster with the manifests. The directory structure looks like this:
+-- fleet
│ +-- blr1
│ │ +-- flux-system
│ │ │ +-- gotk-components.yaml
│ │ │ +-- gotk-sync.yaml
│ │ │ \-- kustomization.yaml
│ +-- lon1
│ │ +-- flux-system
│ │ │ +-- gotk-components.yaml
│ │ │ +-- gotk-sync.yaml
│ │ │ \-- kustomization.yaml
│ \-- sgp1
│ +-- flux-system
│ │ +-- gotk-components.yaml
│ │ +-- gotk-sync.yaml
│ │ \-- kustomization.yaml
You can verify the flux-system namespace on each cluster. This confirms successful bootstrap. 👁 Image
We are now ready to configure the infrastructure components (Ingress) and deploy them through the same workflow.

Step 3: Deploying Ingress through GitOps

With the Flux GitOps agent running in all the clusters, we can leverage it to push newer deployments by committing the artifacts to the Git repository. In this step, let’s create a namespace ingress-system and install the NGINX ingress Helm Chart. Let’s leverage the helmrepositories and helmreleases CRDs added by Flux. Start by cloning the Git repository to your local workstation. git clone https://github.com/$OWNER/do-gitops-demo.git. At this point, this repo contains the YAML artifiacts responsible for deploying Flux operator. We will add a new directory, infrastructure and commit the YAML files with Helm Chart for NGNIX-based ingress. cd do-gitops-demo mkdir infrastructure Let’s add the YAML files to the directory. These three files roughly translate to the same sequence of commands run to install NGINX ingress: kubectl create ns ingress-system helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx helm repo update helm install --namespace ingress-system \ nginx-ingress ingress-nginx/ingress-nginx Finally, we need to add a Kustomization to the cluster directory under fleet which will act as a pointer to the infrastructure components. Since the directory, fleet is registered with the Flux agent during the bootstrapping, that’s the best location to add the below YAML file. For example, to target the Bangalore cluster, copy the below file to fleet/blr1 directory. This approach gives us a chance to customize the artifact per cluster at a later stage. Add the file to all the clusters to ensure that they deploy the ingress. Notice the addition of infrastructure.yaml in each cluster-specific directory and the infrastructure directory with the YAML artifacts.
+-- fleet
│   +-- blr1
│   │   +-- flux-system
│   │   │   +-- gotk-components.yaml
│   │   │   +-- gotk-sync.yaml
│   │   │   \-- kustomization.yaml
│   │   \-- infrastructure.yaml
│   +-- lon1
│   │   +-- flux-system
│   │   │   +-- gotk-components.yaml
│   │   │   +-- gotk-sync.yaml
│   │   │   \-- kustomization.yaml
│   │   \-- infrastructure.yaml
│   \-- sgp1
│   +-- flux-system
│   │   +-- gotk-components.yaml
│   │   +-- gotk-sync.yaml
│   │   \-- kustomization.yaml
│   \-- infrastructure.yaml
\-- infrastructure
 +-- ingress-helm-release.yaml
 +-- ingress-helm-repo.yaml
 \-- ingress-ns.yaml
It’s time to commit the new artifacts and push them to the remote GitHub repository. git add . git commit -m "Added infrastructure components" git push The moment the changes are committed, Flux agent starts the reconciliation process. In a few minutes, you should see all the clusters create the ingress-system namespace. 👁 all the clusters create the ingress-system namespace
Since the creation of an ingress results in provisioning a load balancer, the Digital Ocean cloud console shows that there are three load balancers created per cluster. 👁 GUI showing 3 clusters
This step demonstrated how to deploy a Helm chart through the GitOps workflow. Let’s move to the next step where we will deploy the web application that leverages the ingress created in this step.

Step 4: Deploying a Web App through GitOps

For the web application, let’s follow the same steps of adding the manifests to the apps directory and then adding a Kustomization file to the fleet directory. cd do-gitops-demo mkdir apps Inside the apps directory, create the below YAML files: Finally, add the below Kustomization file to all the clusters under the fleet directory. With the addition of apps, notice how the directory structure has changed.
+-- apps
│   +-- ns.yaml
│   +-- web-ingress.yaml
│   +-- web-service.yaml
│   \-- web.yaml
+-- fleet
│   +-- blr1
│   │   +-- apps.yaml
│   │   +-- flux-system
│   │   │   +-- gotk-components.yaml
│   │   │   +-- gotk-sync.yaml
│   │   │   \-- kustomization.yaml
│   │   \-- infrastructure.yaml
│   +-- lon1
│   │   +-- apps.yaml
│   │   +-- flux-system
│   │   │   +-- gotk-components.yaml
│   │   │   +-- gotk-sync.yaml
│   │   │   \-- kustomization.yaml
│   │   \-- infrastructure.yaml
│   \-- sgp1
│   +-- apps.yaml
│   +-- flux-system
│   │   +-- gotk-components.yaml
│   │   +-- gotk-sync.yaml
│   │   \-- kustomization.yaml
│   \-- infrastructure.yaml
\-- infrastructure
 +-- ingress-helm-release.yaml
 +-- ingress-helm-repo.yaml
 \-- ingress-ns.yaml
git add . git commit -m "Added web application" git push In a few minutes, you will see the mywebapp namespace with the web application. 👁 the mywebapp namespace with the web application.
Access it by visiting the load balancer IP address to see the below web page: 👁 Web app sample
Edit the do-gitops-demo/apps/web.yaml to update the image tag from v1 to v2. 👁 updating the image tag from v1 to v2 in YAML
Commit the code and push it to the remote GitHub repository. Access the load balancer IP again to see the V2 version of the web application. 👁 web app sample v2
If you revert the last commit, you can roll back the deployment to V1. This is the beauty of using GitOps. This completes the step-by-step guide to using FluxCD with DigitalOcean Kubernetes. In the upcoming tutorials, we will explore how to use Kustomization to customize the deployment per each cluster. Stay tuned.
TRENDING STORIES
Janakiram MSV (Jani) is a practicing architect, research analyst, and advisor to Silicon Valley startups. He focuses on the convergence of modern infrastructure powered by cloud-native technology and machine intelligence driven by generative AI. Before becoming an entrepreneur, he spent...
Read more from Janakiram MSV
SHARE THIS STORY
TRENDING STORIES
NGINX and Weaveworks are sponsors of The New Stack.
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.