Post

Updating Flux Installation Using the Latest Binary from CLI

What is Flux?

Flux is a tool for keeping Kubernetes clusters in sync with sources of configuration (like Git repositories), and automating updates to configuration when there is new code to deploy. It’s open source and you can read more about it on the GitHub repo. Looking for a tutorial on how use this? Check out this video on how to use SOPS and Age for your Git Repos!

Updating Flux

We’re going to use curl so you’ll want to be sure you have it installed

1
curl -V

This should return something similar to the following

1
2
3
4
curl 7.68.0 (x86_64-pc-linux-gnu) libcurl/7.68.0 OpenSSL/1.1.1f zlib/1.2.11 brotli/1.0.7 libidn2/2.2.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh/0.9.3/openssl/zlib nghttp2/1.40.0 librtmp/2.3
Release-Date: 2020-01-08
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: AsynchDNS brotli GSS-API HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB PSL SPNEGO SSL TLS-SRP UnixSockets
1
sudo apt update && sudo apt install curl

Then we’ll want to download the latest Flux binary by running

1
curl -s https://fluxcd.io/install.sh | sudo bash

Then we’ll want to be sure it’s installed properly by running

1
flux -v

This should return something similar to the following

1
flux version 0.39.0

Next we’ll need to locate our gotk-components.yaml file for flux in our git repo.For example, mine lives in clusters/cluster-01/base

1
2
3
4
5
clusters
├── cluster-01
│   ├── base
│   │   └── flux-system
│   │       └── gotk-components.yaml

One you locate gotk-components.yaml we’ll patch it by using the following command

1
flux install --export > clusters/cluster-01/base/flux-system/gotk-components.yaml

After this file is updated, you can check to be sure it updated the correct file by running

1
git diff

You should see something like the following

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
diff --git a/clusters/cluster-01/base/flux-system/gotk-components.yaml b/clusters/cluster-01/base/flux-system/gotk-components.yaml
index 79576f0f..9c26b708 100644
--- a/clusters/cluster-01/base/flux-system/gotk-components.yaml
+++ b/clusters/cluster-01/base/flux-system/gotk-components.yaml
@@ -1,6 +1,6 @@
 ---
 # This manifest was generated by flux. DO NOT EDIT.
-# Flux Version: v0.38.3
+# Flux Version: v0.39.0
 # Components: source-controller,kustomize-controller,helm-controller,notification-controller
 apiVersion: v1
 kind: Namespace
@@ -8,7 +8,7 @@ metadata:
   labels:
     app.kubernetes.io/instance: flux-system
     app.kubernetes.io/part-of: flux
-    app.kubernetes.io/version: v0.38.3
+    app.kubernetes.io/version: v0.39.0
     pod-security.kubernetes.io/warn: restricted
     pod-security.kubernetes.io/warn-version: latest
   name: flux-system
@@ -23,7 +23,7 @@ metadata:
     app.kubernetes.io/component: notification-controller
     app.kubernetes.io/instance: flux-system
     app.kubernetes.io/part-of: flux
-    app.kubernetes.io/version: v0.38.3
+    app.kubernetes.io/version: v0.39.0
   name: alerts.notification.toolkit.fluxcd.io
:

if you see something other than the original gotk-components.yaml being updated, you might want to check the location of the file and try again.

Once this is updated, you can simply commit and push this up and let GitOps do the rest!

1
2
3
git add .
git commit -m "feat(flux): Upgraded flux to 0.39.0" # replace with your verion
git push

⚙️ See all the hardware I recommend at https://l.technotim.live/gear

🚀 Don’t forget to check out the 🚀Launchpad repo with all of the quick start source files

This post is licensed under CC BY 4.0 by the author.