kadet-hub logokadet-hub

flux

Renders Flux GitRepositories, OCIRepositories, HelmRepositories, Kustomizations and HelmReleases from inventory parameters, linking each consumer to its source by name.

kubernetesoperatorsci

Latest
1.0.1 ·
License
Apache-2.0
Owners
Moep90
Source
github.com/kadet-hub/generators · 0 repo stars, shared by 35 generators
Thumbs up
👍 0 on GitHub Discussions
Popularity
16 · 264 pulls

Request a feature Report a problem

Badge

Show the latest listed version in your README. shields.io draws the badge from this page's badge.json, which every catalog build updates; once no version is listed, it reads "not listed".

[![kadet-hub](https://img.shields.io/endpoint?url=https://kadet-hub.org/generators/flux/badge.json)](https://kadet-hub.org/generators/flux/)

Flux Generator

Published on kadet-hub: pin a released version by digest from its catalog page.

Kapitan kadet generator for Flux sources and the objects that consume them. Built for Flux 2.9.6, which pins source-controller 1.9.6, kustomize-controller 1.9.6 and helm-controller 1.6.5 (manifests/bases).

  • GitRepository, OCIRepository, HelmRepository (source.toolkit.fluxcd.io/v1)
  • Kustomization (kustomize.toolkit.fluxcd.io/v1): applies a directory of a Git or OCI source
  • HelmRelease (helm.toolkit.fluxcd.io/v2): installs a chart from a HelmRepository, GitRepository or OCIRepository

Each consumer names its source with source: <name>; the generator looks the name up among the sources of the same inventory and writes the matching sourceRef, chart.spec or chartRef. Flux itself is installed with flux bootstrap or the helm input; Secrets for secret_ref belong in the kubernetes generator; pass secret chart values through values_from with a Secret rather than inline values, which land in the compiled output.

Usage

Kapitan Configuration

parameters:
  kapitan:
    dependencies:
      - type: oci
        source: ghcr.io/kadet-hub/flux@sha256:<digest>
        output_path: lib/flux
    compile:
      - output_path: manifests/
        input_type: kadet
        output_type: yml
        input_paths:
          - lib/flux

Inventory Contract

All keys live under parameters.generators.flux.

Key Kind Output key
namespace Default namespace of all resources, flux-system if unset, as in the Flux CLI.
git_repositories.<name> GitRepository <namespace>/<name>-gitrepository
oci_repositories.<name> OCIRepository <namespace>/<name>-ocirepository
helm_repositories.<name> HelmRepository <namespace>/<name>-helmrepository
kustomizations.<name> Kustomization <namespace>/<name>-kustomization
helm_releases.<name> HelmRelease <namespace>/<name>-helmrelease

Every entry accepts namespace, labels, annotations and a spec dict that passes through to the resource spec. Precedence is generator defaults < spec < flat keys: a flat key wins over the same field in spec and logs Flat key '<key>' overrides spec passthrough '<field>' for resource '<name>'.

Flat keys map to the camelCase spec field of the same name; values pass through unless a shorthand below applies.

Kind Flat keys
GitRepository url, ref, interval, timeout, secret_ref, ignore
OCIRepository url, ref, interval, timeout, secret_ref, provider, layer_selector
HelmRepository url, type, interval, timeout, secret_ref, provider
Kustomization source, path, prune, interval, retry_interval, timeout, wait, target_namespace, depends_on, service_account_name, post_build, patches, components
HelmRelease source, chart, version, release_name, target_namespace, interval, timeout, depends_on, service_account_name, values, values_from, install, upgrade

Shorthands

Input Result
source: <name> on a Kustomization sourceRef: {kind, name} of the GitRepository or OCIRepository <name>, plus namespace if it lives in another namespace
source: <name> on a HelmRelease, HelmRepository or GitRepository source chart.spec: {chart, version, sourceRef}; chart defaults to the HelmRelease name for a HelmRepository and is required for a GitRepository, where it is the chart’s path
source: <name> on a HelmRelease, OCIRepository source chartRef: {kind: OCIRepository, name}; the OCIRepository gets the Helm chart layerSelector below, and its ref selects the chart version
source: {kind, name, namespace} used verbatim, for sources defined outside this inventory; a Kustomization accepts GitRepository, OCIRepository, Bucket and ExternalArtifact, a HelmRelease takes OCIRepository, HelmChart or ExternalArtifact as chartRef and HelmRepository, GitRepository or Bucket as chart.spec
ref: <branch> on a GitRepository ref: {branch: <branch>}
ref: <tag> on an OCIRepository ref: {tag: <tag>}
secret_ref: <name> secretRef: {name: <name>}
depends_on: [<name>, ...] dependsOn: [{name: <name>}, ...]; dicts pass through

The compile fails, with a message naming the resource, when:

  • a source name matches no source or sources of two kinds (use the dict form then), or a dict source lacks kind or name;
  • a Kustomization’s source is not a GitRepository, OCIRepository, Bucket or ExternalArtifact;
  • a HelmRelease ends up with neither or both of chart and chartRef, sets chart or version with an OCIRepository source (set its ref instead), lacks chart with a GitRepository or Bucket source, or has an unquoted numeric version such as 1.10, which YAML reads as 1.1;
  • one OCIRepository serves both a HelmRelease and a Kustomization, since the chart layerSelector would hand the Kustomization a chart tarball.

These rules exist because QA-7 and QA-10 do not evaluate the CRDs’ CEL rules, such as “either chart or chartRef must be set”.

With --no-cross-namespace-refs=true on the controllers, a source must live in the namespace of its consumer (Kustomization, HelmRelease).

Defaults

Kind Field Default Source
GitRepository interval 1m0s Kustomization recommended settings
OCIRepository interval 5m HelmRelease recommended settings
OCIRepository used as a HelmRelease chart layerSelector {mediaType: application/vnd.cncf.helm.chart.content.v1.tar+gzip, operation: copy} HelmRelease recommended settings; without it the controller extracts the first layer (layer selector)
HelmRepository with an oci:// URL type oci type; the default type only reads HTTP/S repositories
Kustomization interval, retryInterval, timeout, wait 60m0s, 2m0s, 3m0s, true Kustomization recommended settings
Kustomization prune false the CRD requires the field; false as in flux create kustomization
HelmRelease interval 30m HelmRelease recommended settings

The oci HelmRepository type is in maintenance mode upstream (type); prefer an oci_repositories entry as the HelmRelease source.

The interval defaults matter because the CRDs require the field for every kind except HelmRepository. Controller defaults (HelmRepository interval 1m, source timeout 60s, HelmRelease timeout 5m) are not emitted.

Deliberately not defaulted:

  • prune: true. With pruning, a Kustomization deletes every object it applied once the object disappears from the source, and deleting the Kustomization deletes them all (prune). Set it per Kustomization together with a path; without path Flux applies the root of the source.
  • ref. Without it a GitRepository tracks master and an OCIRepository the latest tag (Git reference, OCI reference).
  • service_account_name. Without it a Kustomization or HelmRelease applies as cluster admin (role-based access control) unless the controllers run with --default-service-account (enforcing impersonation). The account and its RBAC are cluster specific; set it for tenant objects.
  • HelmRelease driftDetection, install/upgrade strategies and upgrade.crds. The recommended RetryOnFailure suits stateful workloads, RemediateOnFailure stateless ones, and CreateReplace lets a chart replace cluster-wide CRDs; choose per release.

Example

parameters:
  generators:
    flux:
      git_repositories:
        fleet:
          url: https://git.example.com/platform/fleet.git
          ref: main
          secret_ref: fleet-git-token
      oci_repositories:
        podinfo-chart:
          namespace: apps
          url: oci://ghcr.io/stefanprodan/charts/podinfo
          ref:
            semver: ">=6.0.0"
      helm_repositories:
        jetstack:
          url: https://charts.jetstack.io
      kustomizations:
        infrastructure:
          source: fleet
          path: ./clusters/production/infrastructure
          prune: true
        apps:
          source: fleet
          path: ./apps/production
          prune: true
          depends_on:
            - infrastructure
          service_account_name: flux-apps
      helm_releases:
        podinfo:
          namespace: apps
          source: podinfo-chart
          values:
            replicaCount: 2
        cert-manager:
          namespace: cert-manager
          source: jetstack
          version: v1.21.2
          values:
            crds:
              enabled: true

This renders flux-system/fleet-gitrepository, apps/podinfo-chart-ocirepository with the Helm chart layer selector, flux-system/jetstack-helmrepository, the Kustomizations flux-system/infrastructure-kustomization and flux-system/apps-kustomization with sourceRef: {kind: GitRepository, name: fleet}, apps/podinfo-helmrelease with chartRef: {kind: OCIRepository, name: podinfo-chart} and cert-manager/cert-manager-helmrelease with chart.spec: {chart: cert-manager, version: v1.21.2, sourceRef: {kind: HelmRepository, name: jetstack, namespace: flux-system}}.

Versions

Add a version's inventory entry, then compile with the consumer workflow, which verifies the artifact and runs Kapitan in the sandbox.

Free of charge, as is and on a best-effort basis: use at your own risk, and review the compiled output before you apply it. Terms

This catalog was built from index serial 47. Set index_serial: 47 in .kapitan-sandbox.yaml and the consumer workflow refuses any older index, so a rolled-back index cannot bring back a yanked version.

Checks find known patterns; they do not prove a generator safe. What a listing covers

VersionBuilt for (schema-checked)
1.0.1Flux helm-controller 1.6.5
Flux kustomize-controller 1.9.6
Flux source-controller 1.9.6
1.0.0Flux helm-controller 1.6.5
Flux kustomize-controller 1.9.6
Flux source-controller 1.9.6
1.0.1

Inventory

parameters:
  kapitan:
    dependencies:
      - type: oci
        source: ghcr.io/kadet-hub/flux:1.0.1@sha256:2d92417b8066d3f2317e5029402bfb7a4869a4f65ab34cb4e0c68dfdf1eb4a89
        output_path: lib/flux

Verify

gh attestation verify \
  oci://ghcr.io/kadet-hub/flux@sha256:2d92417b8066d3f2317e5029402bfb7a4869a4f65ab34cb4e0c68dfdf1eb4a89 \
  --owner kadet-hub \
  --cert-identity https://github.com/kadet-hub/registry/.github/workflows/release.yml@refs/heads/main

Transparency log: Rekor entry 3250238877, in Sigstore's public, append-only log, so the attestation stays checkable independent of this site.

Kapitan declared
>=0.36.3,<0.37
Kapitan checked
0.36.3
Backends checked
not recorded
With --cache
not recorded
krab
compatible
Built for (schema-checked)
Flux helm-controller 1.6.5
Flux kustomize-controller 1.9.6
Flux source-controller 1.9.6
Source
flux-v1.0.1 · e4891e8fd85ca0a19ebf361e8b54fd6473fd8a2f · flux
Binaries
none
Output capabilities
none
Digest
sha256:2d92417b8066d3f2317e5029402bfb7a4869a4f65ab34cb4e0c68dfdf1eb4a89

Checks

Checked by the release run on , gate at 8fbfd22097fa.

  • Secrets gitleaks 8.30.1
    No secret matched the marketplace's gitleaks rules.
  • Malware ClamAV 1.5.4
    No file matched a ClamAV signature.
  • Malicious package heuristics GuardDog 3.2.0
    No GuardDog threat rule matched.
  • Dangerous code Semgrep 1.180.0
    No marketplace Semgrep rule matched, such as eval, subprocess or network calls.
  • Python errors Ruff 0.17.0
    No syntax error or undefined name (Ruff, error rules only).
  • File tree tree_check.py
    No symlink, executable or banned file; imports within the allowlist.
  • Sandboxed compile gVisor 20261005, Kapitan 0.36.3
    The fixture compiled without network, with decoy credentials; no undeclared program ran, no decoy was read.
  • Output capabilities Conftest 0.71.1
    The compiled output uses only the capabilities the manifest declares.
  • CI detection Kapitan 0.36.3
    The output is the same with CI variables set.

SBOM (SPDX 2.3)

Output diff

No output diff recorded: this version was published before the release run recorded one.

1.0.0

Inventory

parameters:
  kapitan:
    dependencies:
      - type: oci
        source: ghcr.io/kadet-hub/flux:1.0.0@sha256:58203c7658e6a02c618b31d59c8f181f1471b5e550d3525e7a24de7e475e580a
        output_path: lib/flux

Verify

gh attestation verify \
  oci://ghcr.io/kadet-hub/flux@sha256:58203c7658e6a02c618b31d59c8f181f1471b5e550d3525e7a24de7e475e580a \
  --owner kadet-hub \
  --cert-identity https://github.com/kadet-hub/registry/.github/workflows/release.yml@refs/heads/main

Transparency log: Rekor entry 3241123378, in Sigstore's public, append-only log, so the attestation stays checkable independent of this site.

Kapitan declared
>=0.36.3,<0.37
Kapitan checked
0.36.3
Backends checked
not recorded
With --cache
not recorded
krab
compatible
Built for (schema-checked)
Flux helm-controller 1.6.5
Flux kustomize-controller 1.9.6
Flux source-controller 1.9.6
Source
flux-v1.0.0 · 572dda58b592673020f4a8d97142d1cdd2125440 · flux
Binaries
none
Output capabilities
none
Digest
sha256:58203c7658e6a02c618b31d59c8f181f1471b5e550d3525e7a24de7e475e580a

Checks

Checked by the release run on , gate at 461ba3b3c507.

  • Secrets gitleaks 8.30.1
    No secret matched the marketplace's gitleaks rules.
  • Malware ClamAV 1.5.4
    No file matched a ClamAV signature.
  • Malicious package heuristics GuardDog 3.2.0
    No GuardDog threat rule matched.
  • Dangerous code Semgrep 1.180.0
    No marketplace Semgrep rule matched, such as eval, subprocess or network calls.
  • Python errors Ruff 0.17.0
    No syntax error or undefined name (Ruff, error rules only).
  • File tree tree_check.py
    No symlink, executable or banned file; imports within the allowlist.
  • Sandboxed compile gVisor 20261005, Kapitan 0.36.3
    The fixture compiled without network, with decoy credentials; no undeclared program ran, no decoy was read.
  • Output capabilities Conftest 0.71.1
    The compiled output uses only the capabilities the manifest declares.
  • CI detection Kapitan 0.36.3
    The output is the same with CI variables set.

SBOM (SPDX 2.3)

Output diff

No output diff recorded: this version was published before the release run recorded one.