I have been playing around with one of my Kubernetes cluster and this is about the automated GitOps with Weave Flux, which was developed by Weaveworks. Flux enables continuous delivery of container images using version control of the code. Flux ensure the reproducible, auditable and revertible deployment as well as easy revert if required.
Latest, release of the Flux can be found in the official GitHub repository release page. Let’s see how we can deploy Flux in a Kubernetes cluster. Basically, we can deploy Flux with direct binary installation and, using Helm. I focus binary installation in this post and, I will share a different post with a Helm deployment.
I downloaded the 1.18.0, which is the latest at the time of writing this article.
sudo wget -O /usr/local/bin/fluxctl https://github.com/fluxcd/flux/releases/download/1.18.0/fluxctl_linux_amd64
sudo chmod +x /usr/local/bin/fluxctl
fluxctl version

I have exported, my GitHub username and repository name as the environment variables.

Created separate namespace for Flux and Memcache PODs, named “weave” and, Flux configuration deployment completed with the below command.
fluxctl install \
--git-user=${GHUSER} \
--git-email=${GHUSER}@gmail.com \
--git-url=git@github.com:${GHUSER}/${GREPO} \
--git-path=namespaces,workloads \
--namespace=weave | kubectl apply -f -

“Flux” and “Memcached” pods created in the weave namespace

Read More:
- VMware Kubernetes Academy – A Free Education Platform
- How To Use AWS Instance Profile Credentials In AWSCLI
- How To Perform A Failover Test In MongoDB Atlas Cluster
- Start Working With VMware Fusion Project Nautilus
- AWS Systems Manager (SSM) Hybrid Activations With On Premises Virtual Machines
New ssh key should be created in order to access the code repository and below command will generate a key for you.
fluxctl identity --k8s-fwd-ns weave

This generated key needed to be added to my GitHub repository, to do that go to the “Settings” of the repository, “Deploy Keys” and add the key.

Write access to the repository is preferred and key should be added with a name.

In my repository, my workload folder would look like this and my intention here is to deploy two nginx replicas in my “tc-ns” namespace. I have added these folders in the git paths when I install the fluxctl.

Flux configurations can be synced as below and my expected pods were running in my “tc-ns” namespace.
fluxctl sync --k8s-fwd-ns=weave

Workloads can also be listed as below, if you set an environment variable as FLUX_FORWARD_NAMESPACE=weave (weave is the namespace specified for the fluxctl operation you can see it in the above fluxctl installation command), in the below output same command executed in two different ways.
fluxctl list-workloads --k8s-fwd-ns=weave -n tc-ns

To list the images and the current status of the image deployed, below command is used. My deployed image 1.7.9, behind in 265 images.
fluxctl list-images --workload tc-ns:deployment/nginx-deployment
#Basically it follows the below syntax
#fluxctl list-images --workload [namespace]:[deployment]/[deploymentname]

To release the latest version of the container below release command was issued, it has the user and the commit message with –update-all-images flag

Now image is in the latest version

Confirmed with my running workload

Bizarre Commits To My Repository
In the previous step, I have released the container version and my Fluxctl has the write access to the repository, also it’s a public one. After releasing the new container image to my namespace, I have noticed that there is a commit to the repository from someone else similar to my name, but it was bot me see below output as below.

After dig in to the problem I realize that, I have given to incorrect email id when I was installing Fluxctl and, the given email id is a valid one and has someone else an account with that email Id. I’m not quite sure this is a bug or the expected behavior. This is something I noticed and better to validate the email id when installing the Flux.