![]() |
VOOZH | about |
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.
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.
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.
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 clustersdo-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
flux check.
👁 flux checkfleet 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
flux-system namespace on each cluster. This confirms successful bootstrap.
👁 Imageingress-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
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 namespaceapps 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.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