flux-local: [DEPRECATED] flux-local is a set of tools and libraries for managing a local flux gitops repository focused on validation steps to help improve quality of commits, PRs, and general local testing. · Pythie
[DEPRECATED] flux-local is a set of tools and libraries for managing a local flux gitops repository focused on validation steps to help improve quality of commits, PRs, and general local testing.
Deprecated.Its authors have deprecated it and no longer maintain it.
[!WARNING]
flux-local is deprecated and has been sunsetted.
We recommend migrating to the following modern, actively maintained alternatives:
flate (an offline validator and renderer written in Go)
konflate (a pull request review tool for Flux using flate)
Thank you to all contributors and users of flux-local over the years!
flux-local is a set of tools and libraries for managing a local flux gitops repository focused on validation steps to help improve quality of commits, PRs, and general local testing.
This library uses command line tools like kustomize and helm to replicate the behavior of
flux to gather objects in the cluster. It only looks at the local git repo, and not a live
cluster. However, this is fine since the local repository has enough information and the
definition is simple. Secrets are ignored as the content is not needed to validate the
cluster is creating valid objects.
This library at first glance is little more than shell scripts running commands, but is easier
to test, maintain, and evolve. This does not support all features of flux, but should
be close enough for home use.
The CLI is written in python and packaged as part of the flux-local python library, which can be installed using pip and uv. If you have not yet embraced python virtual environments, now might be
the right time to do so to avoid clobbering the packages in your system.
This example lists all HelmReleases in the cluster:
$ flux-local get hr -A
NAMESPACE NAME REVISION CHART SOURCE
podinfo podinfo 6.3.2 podinfo-podinfo podinfo
metallb metallb 4.1.14 metallb-metallb bitnami
This example lists all HelmReleases in a specific namespace:
$ flux-local get hr -n metallb
NAME REVISION CHART SOURCE
metallb 4.1.14 metallb-metallb bitnami
flux-local build
You can use the flux-local cli to build objects in a cluster, similar to how you
use kustomize build, which is used underneath. Here is an example to build all flux
Kustomization objects within a git repository, using kustomize cfg count to parse
the yaml output:
Additionally, you can inflate HelmRelease objects inside a Kustomization. This example
again shows kustomize cfg count to parse the yaml output of an inflated HelmRelease
objects defined in the cluster:
You may also use flux-local to verify your local changes to cluster resources have the desird
effect. This is similar to flux diff but entirely local. This will run a local kustomize build
first against the local repo then again against a prior repo revision, then prints the output:
You may also use an external diff program such as dyff which
is more compact for diffing yaml resources:
$ git status
On branch dev
Your branch is up to date with 'origin/dev'.
Changes not staged for commit:
modified: home/dev/hajimari-values.yaml
$ export DIFF="dyff between --omit-header --color on"
$ flux-local diff ks home --path clusters/dev/
spec.chart.spec.version (HelmRelease/hajimari/hajimari)
± value change
- 2.0.2
+ 2.0.1
$ flux-local diff hr hajimari -n hajimari --path clusters/dev/
metadata.labels.helm.sh/chart (ClusterRoleBinding/default/hajimari)
± value change
- hajimari-2.0.2
+ hajimari-2.0.1
metadata.labels.helm.sh/chart (PersistentVolumeClaim/default/hajimari-data)
± value change
- hajimari-2.0.2
+ hajimari-2.0.1
flux-local test
You can verify that the resources in the cluster are formatted properly before commit or as part
of a CI system. The flux-local test command will build the Kustomization resources in the
cluster:
You may also validate HelmRelease objects can be templated properly with the --enable-helm
flag. This will run kustomize build then run helm template on all the HelmRelease objects
found.
GitHub Action
You may use flux-local as a github action to verify the health of the cluster on changes
or PRs. The actions expect to find the flux and kustomize binaries installed.
test action
The test action will validate the cluster will build, and can optionally
validate flux HelmRelease builds.
This example will run flux-local test against the cluster in clusters/prod with
helm release expansion enabled.
The diff action will show you the final diffs of Kustomization or HelmRelease
objects that are fully built. While typically you can just read diffs to understand
how kustomzations may be affected, this action also supports overlays and multiple
clusters showing you the final output.