Skip to main content

flux-local is a python library and set of tools for managing a flux gitops repository, with validation steps to help improve quality of commits, PRs, and general local testing.

Project description

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.

See documentation for full quickstart and API reference. See the github project.

flux-local CLI

The CLI is written in python and packaged as part of the flux-local python library, which can be installed using pip:

$ pip3 install flux-local

You can use the flux-local cli to inspect objects in the cluster, similar to how you might use the flux command on a real cluster.

This example lists all Kustomizations in the cluster:

$ flux-local get ks
NAME                 PATH                                                   HELMREPOS    RELEASES
apps                 ./tests/testdata/cluster/apps/prod                     0            0
infra-controllers    ./tests/testdata/cluster/infrastructure/controllers    0            0
infra-configs        ./tests/testdata/cluster/infrastructure/configs        2            0

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

You can use the flux-local cli to build all 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, which will then build all resources within those:

$ flux-local build clusters/prod/

You can also specify the root to build all clusters.

Additionally, you can inflate HelmRelease objects inside each Kustomization by adding the --enable-helm command line flag:

$ flux-local build clusters/prod/ --enable-helm

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:

$ flux-local diff ks apps
---

+++

@@ -2,6 +2,13 @@

   kind: Namespace
   metadata:
     name: podinfo
+- apiVersion: v1
+  data:
+    foo: bar
+  kind: ConfigMap
+  metadata:
+    name: podinfo-config
+    namespace: podinfo
 - apiVersion: helm.toolkit.fluxcd.io/v2beta1
   kind: HelmRelease
   metadata:

Additionally flux-local can inflate a HelmRelease locally and show diffs in the output objects. This is similar to flux diff but for HelmReleases:

$ flux-local diff hr -n podinfo podinfo
---

+++

@@ -33,8 +33,8 @@

     labels:
       app.kubernetes.io/managed-by: Helm
       app.kubernetes.io/name: podinfo
-      app.kubernetes.io/version: 6.3.2
-      helm.sh/chart: podinfo-6.3.2
+      app.kubernetes.io/version: 6.3.3
+      helm.sh/chart: podinfo-6.3.3
     name: podinfo
   spec:
     ports:
...

Library

The flux_local library documentation for details on the python APIs provided.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flux-local-0.3.0.tar.gz (24.6 kB view details)

Uploaded Source

Built Distribution

flux_local-0.3.0-py3-none-any.whl (27.3 kB view details)

Uploaded Python 3

File details

Details for the file flux-local-0.3.0.tar.gz.

File metadata

  • Download URL: flux-local-0.3.0.tar.gz
  • Upload date:
  • Size: 24.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.2

File hashes

Hashes for flux-local-0.3.0.tar.gz
Algorithm Hash digest
SHA256 3038d79c551b213f151f8a9f7181019871fb9224907fa3276dd000487b217a17
MD5 bc99e261c40040c5ff5d40445669e24b
BLAKE2b-256 25394b8be519fdf4e7b9d101f6287704378f83c55e6212c2b9348b8c4cebf422

See more details on using hashes here.

File details

Details for the file flux_local-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: flux_local-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 27.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.2

File hashes

Hashes for flux_local-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 39bc6dd79d7485277c15386c93f21d5df0b23aa21985c29a96ec2b0956d8938b
MD5 15aecb90a5a960231eb4fc292d8e4ee0
BLAKE2b-256 1f0ac7a97ef774b6bc3cb7a854de64734017968857fe48c2e4cbdfb286038c21

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page