Status: design. Not implemented. Phased plan at the bottom; task tracking lives outside this doc.
Companion to principles.md (configuration as data,
two layers of override) and lifecycle.md (the
plan / update / upgrade loop). This doc covers two changes:
- Folding the ConfigHub function chain into kustomize as an exec
transformer plugin instead of running it as a post-
kustomize buildstep. - Supporting
AppConfig/*toolchains in installer packages by routing them through kustomize'sconfigMapGenerator.
The two are intertwined: AppConfig only makes sense if the function chain can operate on it from inside the kustomize pipeline.
- Run the function chain and validators as a kustomize transformer
plugin. The plugin is a real, non-hidden subcommand of
installerso anyone can use it standalone against raw kustomize. - Make
out/compose/durable, not a temp dir. Operators can reproduce a render byte-for-byte withcd out/compose && kustomize build. - Let components carry their own function chains (mixins) in the
kustomize-native way: a KRM function config listed under the
component's own
kustomization.yamltransformers:. - Support
AppConfig/*toolchains in the function chain without introducing a new KRM wrapper kind. AppConfig content stays in ConfigMaps in the rendered tree; the transformer reverses the ConfigMap → AppConfig content boundary in-process, mutates, and writes back. - At upload, materialize annotated ConfigMaps into the right ConfigHub objects: AppConfig Unit + render-configmap Invocation + Kubernetes/YAML placeholder Unit, wired by an Upsert link and the existing intra-Space link inference.
- Generalized templating. The variable surface stays restricted to
.Namespace,.Inputs,.Selection,.Facts,.Packagewithmissingkey=error. Same constraint everywhere we accept templated text. - A custom KRM kind to ferry non-Kubernetes config through KRM
function pipelines. See kpt issue
3118 — the kustomize
community never settled the question. We sidestep it by piggybacking
on
configMapGenerator. - Secrets. The current
out/secrets/opt-out path stays; secrets are never uploaded. A better secrets story is on the roadmap.
Today internal/render/render.go shells out to kustomize build,
then runs the function chain in-process via
funcimpl.NewStandardExecutor. Authors declare the chain in
installer.yaml.spec.transformers and validators in
installer.yaml.spec.validators. Both are resolved against installer
state with a restricted Go template pass (resolveChainTemplate,
resolveValidatorTemplate) before execution.
Three constraints from the current setup carry into the new design:
- The function chain is part of the render contract — re-rendering must produce identical output for identical inputs. This rules out general templating.
- The chain runs as one in-process executor. Each group's output feeds the next. Subprocess fan-out per group would be a regression.
whereResourceis a ConfigHub filter expression (not CEL) — evaluated by the function executor against resources, with field references likeConfigHub.ResourceType = 'apps/v1/Deployment'. See filter concepts.
First-class CLI verb. Reads a KRM ResourceList from stdin, joins
items into a YAML doc stream, runs the chain encoded in
functionConfig.spec.groups, splits the result back into items,
writes the ResourceList to stdout. Validator failures emit
ResourceList.results with severity: error so kustomize fails the
build.
Two functionConfig kinds:
ConfigHubTransformers— mutating; all groups run in one process call (preserves today's in-process executor pattern).ConfigHubValidators— non-mutating; rejects mutating functions before any invocation runs (mirrors currentrunValidators).
Both share the same shape:
apiVersion: installer.confighub.com/v1alpha1
kind: ConfigHubTransformers # or ConfigHubValidators
metadata:
name: transformers
annotations:
config.kubernetes.io/function: |
exec:
path: ./installer-transformer.sh
spec:
groups:
- toolchain: Kubernetes/YAML
whereResource: "ConfigHub.ResourceType = 'apps/v1/Deployment'"
invocations:
- name: set-container-image
args: ["kuberay-operator", "quay.io/kuberay/operator:v1.6.1"]whereResource is ConfigHub's filter syntax — passed through to the
function executor's FunctionInvocationOptions.WhereResource
unchanged.
The same binary is usable outside the installer. Drop a
ConfigHubTransformers config into any kustomization, reference it
from transformers:, and as long as installer-transformer.sh is
reachable from kustomize's working directory (PATH, a shipped
wrapper, or a symlink) it works against raw kustomize.
compose.go writes everything kustomize needs into a durable
out/compose/ instead of a temp dir:
<work-dir>/out/
├── manifests/ # per-resource non-sensitive output
├── secrets/ # per-resource sensitive output (unchanged)
├── record/ # selection, inputs, facts, function-chain, manifest-index
└── compose/
├── kustomization.yaml # synthesized: resources, transformers, validators, images
├── transformers.yaml # resolved package-level ConfigHubTransformers
├── validators.yaml # resolved ConfigHubValidators
├── installer-transformer.sh # exec wrapper: INSTALLER_RUN_TRANSFORMER=1 exec <installer>
└── components/<name>/... # pre-resolved component-scoped configs (if any)
Render builds out/compose/ with kustomize's Go API, so the installer
needs no kustomize binary, and rewrites it on every render. The wrapper
re-executes the program that rendered, the installer or a program embedding
it, with INSTALLER_RUN_TRANSFORMER=1, which asks it for the transform
step: the same step installer transformer runs. A program embedding the
installer answers it by calling installer.RunTransformerIfRequested() at
the start of main (see library.md). During a render the
transform step writes its log, a line per function it runs and its error
if it fails, to the file INSTALLER_TRANSFORMER_LOG names, which the
render passes it through kustomize; the render then writes the log to its
error output, or puts it in the error when the step fails. kustomize
would otherwise hand the step the stderr of the process rendering, which
a program embedding the installer doesn't let it write to. Same render
is reproducible with a kustomize binary by anyone with
installer-transformer.sh on PATH (or present alongside the
kustomization in out/compose/), byte-for-byte unless that kustomize
release builds differently from the one built into the installer:
cd <work-dir>/out/compose
kustomize build --enable-exec --enable-alpha-plugins
The exec wrapper exists because the KRM
config.kubernetes.io/function annotation's exec.path accepts no
args. Wrapper is one line:
#!/bin/sh
exec "$INSTALLER_BIN" transformer$INSTALLER_BIN is baked in at render time pointing at the
currently-running installer binary, so wrapper and binary always
match. For users running raw kustomize without the installer, ship
the wrapper alongside installer in release artifacts.
A subprocess per group would mean N round-trips of YAML parse +
serialize for the same in-process executor work we do today. One
ConfigHubTransformers with spec.groups: [...] keeps the
existing data flow: one subprocess, one parse, N executor invocations
sharing in-process state, one serialize. Groups still feed each
other through ConfigData, same as today's runChain.
Kustomize runs its built-ins (namePrefix, nameSuffix,
commonLabels, commonAnnotations, namespace, replacements,
configMapGenerator, secretGenerator, images:) before
user-listed transformers, unless they're explicitly placed in the
transformers: list (plugin orchestration
docs).
The installer relies on this: by default our ConfigHubTransformers
runs last, so it sees the post-built-in resources — including the
ConfigMaps that configMapGenerator produced. Authors who need to
interleave (e.g. mutate before commonLabels decorates) can
explicitly list our transformer earlier in their component's
transformers:.
The package surface stays familiar; components get a kustomize-native mixin path.
Package-wide chain stays in
installer.yaml.spec.transformers. Existing tests,
existing author muscle memory. Resolved by today's
resolveChainTemplate, emitted as out/compose/transformers.yaml.
Component-scoped mixins. Each component declaration in
installer.yaml.spec.components can carry optional transformers: and
validators: fields. They take the same FunctionGroup shape as the
package-wide list and only run when the component is selected.
Components contribute their groups in the order they appear in
spec.components so re-render is deterministic regardless of which
order the operator passed --select. All groups — package-wide and
component-scoped — are resolved together and emitted as a single
out/compose/transformers.yaml, so the in-process executor still
runs them in one kustomize subprocess.
# packages/<pkg>/installer.yaml
spec:
components:
- name: observability
path: components/observability
transformers:
- toolchain: Kubernetes/YAML
whereResource: "ConfigHub.ResourceType = 'monitoring.coreos.com/v1/ServiceMonitor'"
invocations:
- name: set-yq
args: ['.spec.namespaceSelector.matchNames = ["{{ .Namespace }}"]']
transformers:
- toolchain: Kubernetes/YAML
invocations:
- {name: set-namespace, args: ["{{ .Namespace }}"]}Authors who'd rather use the kustomize-native pattern — declaring a
KRM function config inside the component directory and referencing
it from the component's own kustomization.yaml transformers:
list — can do that too against raw kustomize, pointing
exec.path at installer-transformer.sh. The installer doesn't
manage those files; they're the user's surface area and bypass the
installer's template-resolution pre-pass.
Built-in namespace: transformer. Not yet implemented — would
let authors who prefer kustomize's built-in namespace: field over
the set-namespace function write namespace: "{{ .Namespace }}"
directly in kustomization.yaml. That requires a templating
pre-pass over package kustomization.yaml files, with resolved
copies written to out/compose/ (the package tree stays
read-only). Deferred; for now, package authors use
spec.transformers with set-namespace.
Authors use standard configMapGenerator and annotate it once with
the toolchain:
configMapGenerator:
- name: app-config
files:
- application.properties
options:
annotations:
confighub.com/toolchain: "AppConfig/Properties"
- name: app-env
envs:
- .env
options:
disableNameSuffixHash: true
annotations:
confighub.com/toolchain: "AppConfig/Env"The annotation key is generalized to
confighub.com/toolchain, not appconfig-toolchain, so
the same mechanism can roundtrip future non-Kubernetes toolchains
that have a natural ConfigMap (or equivalent) carrier.
Kustomize copies options.annotations from a configMapGenerator
entry onto the rendered ConfigMap, so the toolchain annotation
is what reaches the installer transformer (running as an exec
plugin) and the upload step (reading out/manifests/).
The installer transformer infers three more annotations from the rendered carrier and injects them back onto the ConfigMap so downstream consumers (upload, drift) see one canonical contract:
confighub.com/appconfig-mode: file | env— derived from thedata:shape.AppConfig/Envalways implies env mode unless the data looks file-shaped; everything else implies file mode.confighub.com/appconfig-source-key: <name>— file-mode only. Thedata:key whose value is the raw config body. Skipped when there's a singledata:key (the unambiguous case).confighub.com/appconfig-mutable: true | false— whether the generator hashes the ConfigMap's name. Kustomize appends the hash after the transformer runs, so the name the transformer sees is never hashed; a ConfigMap kustomize will hash carries the build annotationinternal.config.kubernetes.io/needsHashSuffix: enabled, which kustomize removes when it appends the hash. Present → immutable (versioned ConfigMaps, each content change rolls a new one); absent → mutable (stable name, hash annotation on the consuming workload triggers restarts). The upload step reads this to pass--immutable=falseto the render-configmap Invocation in the mutable case.confighub.com/appconfig-name: <name>— only for a ConfigMap kustomize will hash: its name before the hash. Upload names the AppConfig Units after it, so a change to the content, which changes the hashed name, updates them.
Authors don't write the mode, source-key, mutable, or name
annotations themselves; the transformer infers and injects them.
Authors who need to override the inference (rare: file-shaped .env
content, or an ambiguous data: shape) can set the mode, source-key
or mutable annotation explicitly on the generator entry and the
transformer respects it.
We deliberately don't modify the package's kustomization.yaml
files — that would conflict with the read-only-package principle.
Injection at the transformer stage means the resolved annotations
ride into out/manifests/ cleanly and the package tree stays
untouched.
When a FunctionGroup declares toolchain: AppConfig/*, the
transformer:
- Pre-filters
ResourceList.itemsto ConfigMaps whoseconfighub.com/toolchainannotation matches the group'stoolchain. The group'swhereResourcethen filters further over the carrier ConfigMap — kind, name, labels — using standard ConfigHub filter syntax. Intra-content filtering is the function's own job, via its arguments. - For each match, extracts the raw AppConfig content from
data::- file-mode: the value at
appconfig-source-key. - env-mode: re-emit a
.env-shaped doc from the flat key/value map.
- file-mode: the value at
- Invokes the executor against that content as a single doc, with the group's invocations.
- Writes the mutated content back into
data::- file-mode: replace the source-key value.
- env-mode: re-parse the mutated
.envinto key/value pairs and replace the ConfigMap'sdata:.
Other kustomize transformers (commonLabels, namespace,
namePrefix, replacements) continue to decorate the ConfigMap
normally — the data round-trip is invisible to them.
Validators on AppConfig run the same way: extract, validate, no
write-back; failures become ResourceList.results.
At upload, ConfigMaps with confighub.com/toolchain are
split into four ConfigHub objects:
- AppConfig Unit (slug =
<carrier-name>: theappconfig-nameannotation when set, else the ConfigMap's name). Toolchain from the annotation. Data = the extracted raw file body. Day-2 source of truth in the native format. No target — it is a pure data source. Therender-configmapfunction uses the Unit slug as the rendered ConfigMap'smetadata.name(<slug>-<hash>in immutable mode,<slug>in mutable mode). A workload reference that already holds that name (a mutable ConfigMap under a stable name) is left alone. Upload replaces any other reference to the carrier with a named placeholder for the Unit, e.g.confighubplaceholderapp_envforapp-env, which Needs/Provides fills with the rendered name, and with the newest render's as new ones are added. - render-configmap Invocation (slug
<carrier-name>-render). Toolchain from the annotation. This is theTransformInvocationthe Upsert link runs to render the AppConfig Unit's data into a Kubernetes ConfigMap. Function arguments:--as-key-value=trueiff mode=env AND toolchain=AppConfig/Env. The function ignores it for non-Env toolchains; we set it only where it's meaningful.--immutable=falseiffappconfig-mutable=true(the transformer pre-pass infers this from kustomize'sneedsHashSuffixbuild annotation; see "Author contract" above), otherwise--immutable=true. Mutable ConfigMaps update in place with a stable name; immutable ones (the kustomize default) get hashed names and accumulate as revisions. Aprune-configmapsMutation Trigger bounds them, and is also what moves workloads to the newest render: until it withdraws the older ones, a reference stays on the render it named first.
- Placeholder Kubernetes/YAML ConfigMap Unit (slug =
<carrier-name>-rendered). Body is empty at creation; populated by the Upsert link below. Unlike the AppConfig Unit it is releasable, so a Release of the Space delivers it, through the Space's release Target, to the same place as every other rendered manifest. The-renderedsuffix avoids colliding with the AppConfig Unit (which owns the bare carrier name). Workloads still resolve to the rendered ConfigMap bymetadata.name(=<carrier-name>, set by render-configmap from the AppConfig Unit's slug), so intra-Space link inference (internal/upload/links.go) wires them into this placeholder via the rendered content. - Upsert link (server-assigned slug via
-).--update-type Upsert --auto-update --transform-invocation <space>/<carrier-name>-render. On resolution therender-configmapfunction renders the AppConfig Unit's data into a Kubernetes ConfigMap and upserts it into the placeholder's Data — no apply — so the runtime ConfigMap name flows through to the workload'svolumeMounts/envFromreference.--auto-updatekeeps the placeholder in sync as the AppConfig Unit changes. cub function do set-namespaceon the placeholder Unit, using the wizard'sInputs.Spec.Namespace.render-configmapstampsmetadata.namespace=confighubplaceholderon the rendered ConfigMap (the placeholder is meant to be resolved by a namespace link at apply time), but the intra-Space link inference matches bymetadata.namespaceand a placeholder value never resolves. Stamping the real namespace onto the placeholder Unit here unblocks the inference so Deployments referencing the carrier by name link to it cleanly.
The inference reads a workload's envFrom.configMapRef.name as well
as its volumes, so a workload that takes its environment from the
carrier through envFrom alone is linked to the placeholder Unit too
(test/e2e/env-configmaps.sh checks it).
The rendered ConfigMap YAML in out/manifests/ is NOT uploaded as a
Unit — the render-configmap Invocation re-derives the ConfigMap from
the AppConfig Unit's content via the Upsert link, and the placeholder
- link pair handles the namespace/reference wiring.
The manifest-index.yaml schema can later gain fields recording the
AppConfig source-key and toolchain so update / upgrade can
reason about ConfigMaps that have split provenance; deferred to a
follow-up.
We considered defining a new KRM kind (e.g.
installer.confighub.com/v1alpha1, kind: AppConfig) that would
carry the raw file body through the kustomize pipeline, with the
ConfigMap synthesized at the end. Three problems:
- Built-in kustomize transformers (
commonLabels,namespace,replacements) only decorate Kubernetes resources by GVK. Our wrapper kind would be invisible to them, so any author wanting common-labels behavior on their AppConfig would have to re-implement it. ConfigMap-as-carrier gets the decoration for free. - Downstream consumers (other transformers, validators, KRM functions written elsewhere) would need to learn our kind. That's the kpt 3118 problem.
- Two sources of truth: the wrapper and the synthesized ConfigMap. Diffing, upgrade, drift all get harder.
ConfigMap-as-carrier + reverse-on-extract pays a small cost (re-parsing data on every AppConfig function group invocation) and buys full kustomize compatibility.
We test all of these against AppConfig-bearing ConfigMaps:
images:— already driven byinstaller --set-image. Works unchanged; ConfigHub functions see the post-image-set Deployment.namespace:— supported either via theset-namespacefunction in the chain or via the kustomize built-in with{{ .Namespace }}templating inkustomization.yaml.commonLabels:/commonAnnotations:— applied before the ConfigHub transformer. Transformer sees decorated resources. AppConfig ConfigMaps still extract cleanly becausedata:is untouched by label/annotation transforms.namePrefix:/nameSuffix:— applied to the rendered ConfigMap. The AppConfig Unit slug is derived from theconfigMapGenerator.name(the pre-prefix logical name), so the AppConfig slug stays stable across rename mutations.replacements:— applied before our transformer when in the default slot.configMapGenerator:/secretGenerator:— run before transformers, so AppConfig hashing and data-merging happen before the transformer extracts.secretGeneratoris not annotated; secrets continue to flow intoout/secrets/and are never uploaded.
- Lift chain execution. ✅ Moved
runChain,runValidators,parseFunctionArguments,ValidatorFailure,FormatValidatorFailures,decodeValidatorFailuresfrominternal/render/chain.gointo a newinternal/chainexec/package. Render andinstaller vetimport it. installer transformersubcommand. ✅ Standalone-usable KRM Functions exec plugin. Two functionConfig kinds:ConfigHubTransformersandConfigHubValidators.- Kustomize-driven render with durable
out/compose/. ✅ Single path:Rendergeneratesout/compose/{kustomization, transformers, validators}.yamland a one-lineinstaller-transformer.shwrapper, then builds it with kustomize, askustomize build --enable-exec --enable-alpha-pluginsdoes (in-process, through kustomize's Go API). No legacy fallback; the in-process chain code path is gone. - Component-scoped transformer mixins. ✅ Added optional
transformers:andvalidators:to each entry inspec.components. Resolved alongside the package-wide chain in declaration order, emitted as a singleout/compose/transformers.yaml. - AppConfig annotation contract. ✅ Documented in
author-guide.md; the transformer reads
confighub.com/toolchainfrom kustomize-copied generator annotations. - AppConfig transformer round-trip + annotation injection. ✅
installer transformerruns a pre-pass that derives and injectsappconfig-mode(file/env, from data: shape) andappconfig-source-key. Function groups with toolchainAppConfig/*extract fromdata:, invoke, write back. Both mutating and validating paths supported. - AppConfig upload split. ✅ Detected ConfigMaps become a four-piece bundle: render-configmap Invocation, AppConfig Unit, placeholder Kubernetes/YAML ConfigMap Unit (slug matches the carrier name so intra-Space link inference works), and an Upsert link from placeholder → AppConfig Unit with the Invocation as its TransformInvocation.
- Cleanup. Remove the AppConfig roadmap bullet from README.md once 5–7 land.
RevisionHistoryLimitdefault for the immutable (hashed-name) case. 10? 5? Match the cub default. Decide before phase 7.- Whether component-supplied transformer configs should be template-resolved at compose time (current plan) or via a small vars-KRM function injected upstream in the transformers list. Compose-time is simpler and preserves the principle of read-only package files; revisit if components ever need per-resource variable substitution that can't be hoisted.
- Whether to surface a CLI hint when an annotated
configMapGeneratorwithdisableNameSuffixHash: falseis used by a workload that doesn't haveenvFrom/volumeplumbed — i.e. catch the common "I forgot to wire the ConfigMap into the Pod" mistake at render time. Defer.