Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

function-aicr

function-aicr is a Crossplane composition function that deploys an NVIDIA AI Cluster Runtime (AICR) recipe. AICR captures known-good combinations of GPU drivers, operators and platform components as version-locked recipes. Give the function the recipe criteria (accelerator, service, intent, OS, platform) and it resolves the matching recipe from AICR’s catalog. It expands the recipe into namespaced provider-helm Releases and provider-kubernetes Objects that target a workload cluster, rolled out in AICR’s dependency order.

The function embeds AICR’s recipe engine and catalog, so there is nothing to install besides the function package and the two providers whose resources it composes. The AICR documentation describes the recipes themselves.

Each recipe component becomes one Release for its Helm chart and one Object per document of its manifest files. The function checks each composed resource against the provider CRD schema Crossplane resolves for it before emitting it, and withholds it from the desired state until what AICR orders before it reports Ready.

Where to start

You want toRead
deploy a recipe to a clusterInstall, then Write a Composition
let each composite resource name its own recipeValues from the composite resource
look up a fieldInput reference
serve your own recipe catalogRecipe source
understand a Warning or a Fatal resultTroubleshooting
change the functionDevelopment

Why Crossplane

AICR renders a recipe into a bundle for a deployer such as Helm, Argo CD, Flux, Helmfile, Terraform or Fleet. The bundle is generated once, for one cluster, and regenerated when the recipe or its inputs change.

As a Crossplane composition the recipe is resolved by the control plane, from each composite resource, every time that resource is reconciled.

One API, many clusters. Define an XRD of your own and let each composite resource state its accelerator, service, intent and target cluster. One Composition serves every workload cluster, without a bundle to generate or store for each.

The recipe follows its inputs. A change to a composite resource, to the Composition or to the function’s version takes effect on the next reconcile. provider-helm and provider-kubernetes then converge every Release and Object on the result.

Ordered rollout on observed readiness. A component is withheld until what AICR orders before it reports Ready, read from the providers’ observed conditions.

Pipeline composability. Add functions before or after, to derive values from the composite resource or to enforce policy. Each is an independent step that leaves the recipe untouched.

A local loop. crossplane render runs the function on your machine, and every composed resource is checked against the provider CRD schema before anything is applied.

A request, step by step

Crossplane calls the function when it reconciles a composite resource. This page follows one call from the Input to the desired state, in the order the function works. Each step links to the page that covers it.

  1. The Input is resolved. The static Input from the Composition is merged with the object at overlayFrom.fieldPath on the composite resource. An unknown field in either is Fatal. See Values from the composite resource.
  2. The criteria and the provider config are checked. At least one criteria dimension must be set and each value must be one AICR knows. The provider config needs a name.
  3. AICR resolves the recipe. The criteria select it, and profile and configuration shape it. See Recipe variants and configuration.
  4. The managed components are selected. The function deploys the recipe’s Helm components that AICR enables. skipComponents removes some by name, and componentClasses removes whole classes. See Components and overrides.
  5. Values and namespaces are settled. Each component’s values are resolved and nodeScheduling is written into them. draEviction is wired when set, and a component that’s already deployed keeps its namespace. See Node scheduling.
  6. The manifest files are rendered. AICR’s manifest files are Helm-style templates. The function renders them with the component’s values and splits them into documents. A component whose manifests need its namespace before a chart creates it gets an Object for the namespace. Then the function runs AICR’s bundle checks. What AICR would refuse to bundle is Fatal for a component that isn’t deployed yet.
  7. The provider schemas are required. The function asks Crossplane for the Release schema when the recipe has a chart, and for the Object schema when a manifest rendered a document. Until Crossplane has resolved them the function composes nothing, and Crossplane calls it again within the same reconcile. See Schema validation.
  8. The resources are composed and validated. One Release per chart and one Object per manifest document, each checked against its schema.
  9. The gate withholds what isn’t due. Unless skipDeploymentOrder is set, a resource whose prerequisites aren’t observed Ready is left out of the desired state. See Rollout order.
  10. Upgrades are assessed. A chart version change to a deployed Release is looked up in AICR’s upgrade records. See Upgrades.
  11. The summary is written. When target is set, the function writes the recipe’s identity and the rollout’s progress to the status of the composite resource. See The status summary.

Results

The function reports through the results Crossplane turns into events on the composite resource.

SeverityMeaning
FatalThe function composed nothing this pass. The message says what to fix, such as an Input field or a missing provider.
WarningThe pass went through, with something to look at, such as a namespace that was kept or an upgrade AICR doesn’t rate safe.
NormalProgress. Each resource the gate withholds is named with what it waits for.

Install

This page is for whoever installs the function on a Crossplane control plane. It lists what the function needs around it and how to install the package.

What it needs

NeededWhy
Crossplane v2.2 or laterThe function validates what it composes against the provider CRD schemas, which it asks Crossplane for. Crossplane advertises that capability from v2.2.0, and without it the function is Fatal.
provider-helm with the helm.m.crossplane.io/v1beta1 ReleaseEvery chart-backed component becomes a namespaced Release.
provider-kubernetes with the kubernetes.m.crossplane.io/v1alpha1 ObjectEvery document of a component’s manifest files becomes a namespaced Object. Only needed when the recipe renders one. See Schema validation.
A provider config for the target clusterA ClusterProviderConfig or a ProviderConfig of each provider, under the same name. The function stamps that name on every resource it composes.

The package

Releases are published as ghcr.io/jonasz-lasut/function-aicr and mirrored at xpkg.upbound.io/jonasz-lasut/function-aicr. The releases page lists the versions.

apiVersion: pkg.crossplane.io/v1
kind: Function
metadata:
  name: function-aicr
spec:
  package: ghcr.io/jonasz-lasut/function-aicr:<version>

The recipe catalog comes with the function’s version. Each release embeds the catalog of one AICR release, and upgrading the function can change what an existing composite resource deploys. Read Upgrades before moving a cluster to a new version.

Install function-auto-ready too and run it after function-aicr in the pipeline. function-aicr orders the rollout from the observed readiness of the resources it composes, and leaves the composite resource’s own readiness to the pipeline.

The next page is Write a Composition.

Write a Composition

Use function-aicr as a step in a Composition pipeline. Its Input names the recipe criteria and the provider config of the target cluster. A value is either static in the Composition or set by the composite resource, through the object overlayFrom names.

apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
  name: clusterstacks.example.org
spec:
  compositeTypeRef:
    apiVersion: example.org/v1alpha1
    kind: ClusterStack
  mode: Pipeline
  pipeline:
  - step: aicr
    functionRef:
      name: function-aicr
    input:
      apiVersion: aicr.fn.crossplane.io/v1beta1
      kind: Input
      overlayFrom:
        fieldPath: spec.aicr
      providerConfigRef:
        kind: ClusterProviderConfig
        name: gpu-cluster
      target:
        fieldPath: status.aicr
  - step: auto-ready
    functionRef:
      name: function-auto-ready

A composite resource of that kind then picks its own recipe:

apiVersion: example.org/v1alpha1
kind: ClusterStack
metadata:
  name: gpu-training-stack
  namespace: default
spec:
  aicr:
    criteria:
      accelerator: h100
      service: kind
      intent: training

The object at spec.aicr has the fields of the Input and is merged over it. A composite resource controls the Input fields its XRD declares there, and the function doesn’t need to know the composite resource’s kind. Values from the composite resource has the merge rules.

The XRD

Crossplane prunes anything an XRD doesn’t declare. The schema here declares the Input fields a composite resource may set under the overlay path, and the complete XRD also declares the summary under the target path.

spec:
  type: object
  required:
  - aicr
  properties:
    aicr:
      type: object
      required:
      - criteria
      properties:
        criteria:
          type: object
          properties:
            accelerator:
              type: string
            service:
              type: string
            intent:
              type: string
            os:
              type: string
            platform:
              type: string

The complete XRD is in example/clusterstack/definition.yaml. It also declares profile, configuration and nodeScheduling under the overlay path, and the status schema.

One composite resource per cluster and namespace

A composed resource is named after its component, because the rollout order is worked out by matching observed resources to desired ones by name. Composite resources in one namespace that deploy the same component would claim the same name. A recipe is one stack per cluster in any case: its Helm release names would collide in the target cluster.

Values from the composite resource

Every field of the Input is static: the value all composite resources of a Composition get. overlayFrom.fieldPath points at an object on the composite resource, with the fields of the Input, that’s merged over it. One Composition then serves many clusters, and each composite resource states its own recipe and target.

# In the Composition
input:
  apiVersion: aicr.fn.crossplane.io/v1beta1
  kind: Input
  overlayFrom:
    fieldPath: spec.aicr
  criteria:
    intent: training
  providerConfigRef:
    kind: ClusterProviderConfig
# On the composite resource
spec:
  aicr:
    criteria:
      accelerator: h100
      service: eks
    providerConfigRef:
      name: workload-a

This composite resource is reconciled with accelerator: h100, service: eks, the static intent: training, and the ClusterProviderConfig named workload-a.

The merge rules

  1. Maps merge key by key, and the overlay’s value replaces the static one. A static key the overlay doesn’t set is kept.
  2. A list in the overlay replaces the static list whole.
  3. An empty string or a null in the overlay counts as unset and keeps the static value. Kubernetes API conventions make "" and an omitted optional field indistinguishable. Chart values are the exception: under componentOverrides.<component>.values an empty string or a null is a value like any other. An empty string in a node selector under nodeScheduling is a value too: many node labels have that value.
  4. A field path that’s absent from the composite resource leaves the static Input unchanged.
  5. A field path that holds anything but an object, an overlay that sets overlayFrom, apiVersion, kind or metadata, and a field the Input doesn’t have are Fatal, never a silent fallback. An unknown field in the static Input is Fatal too.

Fields the overlay may set

Any field of the Input reference but overlayFrom: criteria, providerConfigRef, profile, configuration, skipComponents, componentOverrides and the rest. The overlay is the Input’s fields alone, without the apiVersion, kind and metadata of a whole Input object.

The XRD limits it. Crossplane prunes the fields an XRD doesn’t declare, so declare under the overlay path exactly the fields a composite resource should control. A value that only one cluster knows, such as the GKE network names, belongs there. A value meant for all clusters belongs in the Composition.

Criteria

You can leave any criteria dimension out, but you must set at least one. An Input with no criteria, as when its overlay misses the composite resource, is Fatal instead of a silent deployment of the base recipe.

The function passes an unset dimension to AICR unstated, and AICR then resolves a recipe that doesn’t depend on it. AICR’s catalog alone decides which combinations exist, and AICR rejects a stated value that isn’t part of one.

Recipe variants and configuration

profile and configuration change a recipe after the criteria have selected it. AICR checks both, and rejects either on a recipe it doesn’t apply to. That makes them natural overlay fields: the composite resource that needs one sets it.

Profile

profile selects a variant the recipe declares, as {<name>: <value>}. The GKE COS recipes declare gpuStack with gke-default, bundle-installer and dra. Unset, the recipe’s default variant is deployed.

profile:
  gpuStack: dra

AICR accepts one selection for a recipe, so more than one entry is Fatal. The status summary reports the variant that was deployed.

Configuration

configuration holds typed choices, with the same fields as AICR’s own recipe configuration.

gke.tcpxoInterfaces maps the guest interfaces eth1 to eth8 to the cluster’s GKE Network objects. The h100 / gke / cos / training / kubeflow recipe requires it, and without it the function is Fatal with AICR’s own message. The names differ for every cluster, so set this field on the composite resource.

runtimeInventory.mode is enabled or disabled. enabled adds k8s-aibom, AICR’s runtime AI workload inventory, to a GKE recipe that doesn’t include it. disabled removes it from one that does.

The XRD has to declare profile and configuration under the overlay path for a composite resource to set them, as the example XRD does.

spec:
  aicr:
    criteria:
      accelerator: h100
      service: gke
      os: cos
      intent: training
      platform: kubeflow
    configuration:
      gke:
        tcpxoInterfaces:
        - interfaceName: eth1
          network: my-cluster-gpu-nic-0
        # eth2 to eth8

Components and overrides

A recipe is a set of components. This page says which of them the function deploys, what each becomes, and how to leave one out or change it.

Composed resources

A chart-backed component becomes a helm.m.crossplane.io/v1beta1 Release named after the component (cert-manager, gpu-operator), so the Helm release in the target cluster has that name too.

Components also have manifest files: preManifestFiles that must exist before the chart and manifestFiles that follow it. A manifest-only component has no chart at all. The files are Helm-style templates. The function renders them with AICR’s own renderer from the component’s namespace, chart, version and values, and wraps each document in a kubernetes.m.crossplane.io/v1alpha1 Object named <component>-<pre|post>-<kind>-<name>. The manifests take an override exactly as the Release does. A file that fails to render or parse is Fatal, which keeps a recipe from being deployed with a piece missing.

The namespace has to exist before an Object can be created in it, and for a pre-manifest file that’s before the chart that would create it. A component with pre-manifest files, and a manifest-only component, gets one more Object for that reason, named <component>-pre-namespace-<namespace>. It creates the component’s namespace when it’s missing and never changes or deletes it, as Helm’s --create-namespace does. A recipe that declares the namespace in the component’s own manifest files keeps its own.

Which components are deployed

The function deploys the recipe’s Helm components that AICR enables. A component an overlay of the catalog disables remains in AICR’s inventory but is never composed, exactly as AICR’s own deployers treat it.

skipComponents removes further components by name. A name that matches no component of the recipe raises a Warning, since a typo would otherwise deploy the component it meant to skip.

componentClasses keeps only the components of the classes it names. AICR’s registry puts every component in one of two: core is what a plain GPU pod needs to run, and ops is everything else, workload platforms included. One composite resource can then own the GPU core and another the ops layer.

A component that isn’t deployed, for either reason, counts as satisfied when another depends on it: you opted to manage it elsewhere. This has one consequence for componentClasses. The rollout order is worked out within one composite resource, so an ops component that depends on a core one deployed by another composite resource doesn’t wait for it.

Leaving out a component that’s already deployed removes its Release and Objects from the desired state, and Crossplane deletes them.

Overrides

componentOverrides changes a deployed component, keyed by its name.

componentOverrides:
  gpu-operator:
    version: v26.7.2
    namespace: nvidia
    values:
      driver:
        enabled: false
FieldEffect
versionThe chart version.
namespaceThe namespace the component is installed in.
valuesDeep-merged over the values the recipe resolved. On a conflict the override’s value is used.

An entry for a component that isn’t deployed is ignored with a Warning.

A deployed component keeps its namespace

When the recipe names another namespace than the one a component is deployed in, as after an AICR release that moves a component’s default namespace, the function doesn’t move the live Release. It keeps the namespace the observed Release has and reports it as a Warning. A manifest-only component that the recipe places in the namespace of a component it depends on follows that component. A custom resource then remains next to its operator.

To move a component yourself, set componentOverrides.<component>.namespace. The function uses that namespace whatever it observes.

provider-helm then installs the chart in the new namespace and leaves the release in the old one in place. Uninstall the old release with Helm. A chart with cluster-scoped resources needs that first, because Helm refuses the second install with invalid ownership metadata while the old release owns them.

The status summary

When target.fieldPath is set, the function writes a summary of the resolved recipe and of the rollout to that path on the composite resource. This is the example composite resource once prometheus-operator-crds is observed Ready:

status:
  aicr:
    recipeName: h100-kind-training
    recipeVersion: v1.3.0
    appliedOverlays:
    - base
    - monitoring-hpa
    - h100-any
    - kind
    - h100-kind-training
    componentCount: 13
    deployedComponents:
    - name: nodewright-operator
      namespace: nodewright
      version: v0.21.0
    - name: prometheus-operator-crds
      namespace: monitoring
      version: 28.0.1
    # cert-manager, kube-prometheus-stack and nfd follow
    pendingComponents:
    - name: gpu-operator
      waitingFor: nfd
    - name: kai-scheduler
      waitingFor: gpu-operator
    # six more follow
KeyMeaning
recipeNameThe recipe’s identifier, built from the criteria.
recipeVersionThe version of AICR’s Go module, aicr.run, that the function was built with. It pins the embedded recipe data.
recipeSourceThe repository@digest of the recipe source. Present only when the function serves one.
profileThe recipe variant deployed, as name=value. It’s the selected one or the recipe’s default, and it’s absent when the recipe doesn’t declare a profile.
appliedOverlaysThe catalog overlays the recipe was built from, in order. An overlay a recipe source adds shows up here.
componentCountHow many components the recipe deploys for this composite resource. A component that composes no resource isn’t counted.
deployedComponentsThe components whose Release is in the desired state, in AICR’s deployment order, each with its chart version and namespace. A manifest-only component is listed once all its Objects are.
pendingComponentsThe components the rollout order still withholds, each with the dependency or pre-manifest Object it waits for. Empty once everything is emitted.

The path must be status or begin with status.. The keys are set one by one, and keys already present at the path are kept.

Crossplane prunes any status field the XRD doesn’t declare. The XRD needs a matching subschema. example/clusterstack/definition.yaml has one to copy.

Render locally

crossplane render runs the pipeline on your machine, without a cluster. The repository’s example/clusterstack directory has the files it needs.

FileContents
xr.yamlAn h100 / kind / training stack.
xr-eks.yamlAn EKS stack whose manifest-only nodewright-customizations component renders its NodeWright tuning resource into an Object.
composition.yaml, definition.yamlThe Composition and XRD from Write a Composition.
functions.yamlThe pipeline’s functions. function-aicr uses the Development runtime, so render talks to the one you run.
schemas/Stand-ins for the provider CRD schemas.

Run the function, then render:

go run . --insecure --debug
cd example/clusterstack
crossplane render xr.yaml composition.yaml functions.yaml \
  --required-schemas=schemas/ \
  --include-function-results

The function checks composed resources against the provider schemas, so render must be given those schemas.

The first render

The first render has no observed resources, so only the components without dependencies appear: the rollout order withholds the rest. Pass --observed-resources with a file that marks prometheus-operator-crds Ready to see cert-manager emitted:

apiVersion: helm.m.crossplane.io/v1beta1
kind: Release
metadata:
  name: prometheus-operator-crds
  namespace: default
  annotations:
    crossplane.io/composition-resource-name: prometheus-operator-crds
spec:
  forProvider:
    namespace: monitoring
status:
  conditions:
  - type: Ready
    status: "True"
    reason: Available
    lastTransitionTime: "2026-11-20T00:00:00Z"

The schemas

The files under schemas/ are hand-written stand-ins for provider-helm’s Release and provider-kubernetes’ Object CRD schemas, not copies of them. They cover only the fields the function sets. Each is an OpenAPI v3 document, the format kubectl get --raw /openapi/v3/<group-version> returns, which is what --required-schemas reads.

To render against the real schemas, fetch them from a cluster where the providers are installed:

mkdir -p schemas
kubectl get --raw '/openapi/v3/apis/helm.m.crossplane.io/v1beta1' \
  > schemas/helm.m.crossplane.io_v1beta1.json
kubectl get --raw '/openapi/v3/apis/kubernetes.m.crossplane.io/v1alpha1' \
  > schemas/kubernetes.m.crossplane.io_v1alpha1.json

Input reference

The function’s input is an object of kind: Input, apiVersion: aicr.fn.crossplane.io/v1beta1. Its authoritative source is input/v1beta1/input.go, and the generated CRD is package/input/aicr.fn.crossplane.io_inputs.yaml.

Every field is static unless the overlay sets it. See Values from the composite resource.

Where values come from

FieldTypeDefaultNotes
overlayFromobjectunsetWhere an overlay of this Input is read from.
overlayFrom.fieldPathstring, required when overlayFrom is setA field path on the observed composite resource, such as spec.aicr, to an object with the fields of this Input.

The recipe

FieldTypeDefaultNotes
criteriaobjectAICR recipe criteria. At least one dimension must be set, here or by the overlay.
criteria.acceleratorstringunstatedOne of AICR’s accelerators, such as h100, b200 or a100.
criteria.servicestringunstatedOne of AICR’s services, such as eks, gke, aks or kind.
criteria.intentstringunstatedtraining or inference.
criteria.osstringunstatedOne of AICR’s operating systems, such as ubuntu, cos or talos. Unstated, AICR selects the OS-agnostic recipe tier. AICR rejects an OS no recipe for the service honors, and asks for one when a service and accelerator pair has only OS-specific recipes.
criteria.platformstringunstatedOne of AICR’s platforms, such as kubeflow, slurm, runai, dynamo or nim.
profilemap of string to stringunsetOne recipe variant, keyed by profile name, such as {gpuStack: dra}. See Recipe variants and configuration.
configuration.gke.tcpxoInterfaceslist of {interfaceName, network}unsetThe eight eth1 to eth8 GKE Network mappings a recipe with the torch-distributed-tcpxo runtime requires.
configuration.runtimeInventory.modestringunsetenabled adds k8s-aibom and disabled removes it.

The target cluster

FieldTypeDefaultNotes
providerConfigRef.kindstringClusterProviderConfigClusterProviderConfig or ProviderConfig. A kind the overlay sets must be one of the two as well.
providerConfigRef.namestring, requiredStamped onto every composed Release and Object. From the Input or its overlay, so one Composition can target the cluster each composite resource names.

Components

FieldTypeDefaultNotes
componentClasseslist of stringevery classLimits the recipe to the components of the listed AICR classes, core or ops. Any other class is Fatal.
skipComponentslist of {name}noneComponents left out of the recipe. A name that matches no component raises a Warning.
componentOverridesmap of component name to overridenoneAn entry for a component that isn’t deployed is ignored with a Warning.
componentOverrides.<name>.versionstringthe recipe’sThe chart version.
componentOverrides.<name>.namespacestringthe recipe’s, or the one the component is already deployed inThe target namespace. Also how a deployed component is moved to the namespace a newer recipe names.
componentOverrides.<name>.valuesobjectunsetDeep-merged over the values the recipe resolved. On a conflict the override’s value is used. Anything but an object is Fatal on the first pass.
nodeScheduling.system.nodeSelectormap of string to stringunsetNode labels for system workloads, written to the chart values AICR’s registry lists. See Node scheduling.
nodeScheduling.system.tolerationslist of tolerationsunsetTolerations for system workloads, in the pod specification’s own format.
nodeScheduling.accelerated.nodeSelectormap of string to stringunsetNode labels for workloads on accelerated nodes.
nodeScheduling.accelerated.tolerationslist of tolerationsunsetTolerations for workloads on accelerated nodes.
draEvictionboolfalseWires AICR’s eviction contract across three components. See DRA eviction.

See Components and overrides.

Rollout and status

FieldTypeDefaultNotes
skipDeploymentOrderboolfalseEmits every component at once instead of withholding each until its dependencies report Ready. See Rollout order.
target.fieldPathstring, required when target is setWhere the status summary is written. Must be status or begin with status..

Recipe source

By default the function serves the recipe catalog embedded in the aicr.run module, AICR’s Go module, from the function’s build. The module version is the catalog version, and nothing is fetched at runtime.

The --recipe-oci-* flags overlay that catalog with a digest-pinned OCI recipe artifact, pulled once at startup so that a reconcile never waits on a registry:

--recipe-oci-repository=ghcr.io/acme/aicr-recipes
--recipe-oci-digest=sha256:8ac7f6d54e8bcbf074f156a11f2c8c1ca6dcafed85e880e99a3126c0810cd66f

The environment variables RECIPE_OCI_REPOSITORY and RECIPE_OCI_DIGEST do the same. Set either form through a DeploymentRuntimeConfig that the Function package references:

apiVersion: pkg.crossplane.io/v1beta1
kind: DeploymentRuntimeConfig
metadata:
  name: function-aicr
spec:
  deploymentTemplate:
    spec:
      selector: {}
      template:
        spec:
          containers:
          - name: package-runtime
            args:
            - --recipe-oci-repository=ghcr.io/acme/aicr-recipes
            - --recipe-oci-digest=sha256:8ac7f6d54e8bcbf074f156a11f2c8c1ca6dcafed85e880e99a3126c0810cd66f

The source belongs to the function deployment, not to the Input: every composite resource that function serves resolves against the same catalog.

The rules

Digest-pinned only. The selector must be the artifact’s immutable sha256: manifest digest. A tag is refused, because mutable registry state could then change what the function deploys. Rolling the catalog forward is a new digest, and rolling back is the old one.

Layered over the embedded catalog. The artifact’s files are layered over the embedded catalog, and registry.yaml is merged. The artifact only needs what differs. The status summary reports the source as recipeSource next to the embedded recipeVersion.

Fail fast. A pull or validation failure exits the function. It never falls back to the embedded catalog, which would change what gets deployed. The pod’s restart backoff and its logs make the failure visible.

Authored for the embedded AICR release. The artifact’s registry.yaml must declare the apiVersion that release expects. AICR v1.0.0 retired the alpha versions, so an artifact written for an older release is refused at startup.

Registry access. Credentials are read from the Docker config ($DOCKER_CONFIG/config.json): mount a dockerconfigjson Secret and set DOCKER_CONFIG. Connections are HTTPS with the image’s CA bundle. Set SSL_CERT_FILE for a private CA. Extraction needs a writable temporary directory (TMPDIR), so mount an emptyDir when the container filesystem is read-only.

Opt in to a mixin

AICR’s catalog has opt-in mixins that no stock recipe includes, such as the graded NVSentinel remediation steps or nvsentinel-observability. A recipe takes a mixin only when a catalog overlay lists it, and AICR has no criteria value or flag for that. The recipe source is how a function deployment opts in.

The artifact

It needs two small files: a registry.yaml with nothing but its header, and an overlay that extends the stock recipe.

# registry.yaml
apiVersion: aicr.run/v1beta1
kind: ComponentRegistry
components: []
# overlays/h100-kind-training-observability.yaml
kind: RecipeMetadata
apiVersion: aicr.run/v1beta1
metadata:
  name: h100-kind-training-observability
spec:
  base: h100-kind-training
  criteria:
    service: kind
    accelerator: h100
    intent: training
  mixins:
  - nvsentinel-observability

The overlay sets the stock recipe as its base and repeats its criteria, so every composite resource that resolves that recipe gets the mixin.

Publish it

Publish the two files as one gzipped tar layer with AICR’s artifact type:

tar -czf recipes.tar.gz registry.yaml overlays
oras push --artifact-type application/vnd.nvidia.aicr.artifact \
  ghcr.io/acme/aicr-recipes:observability \
  recipes.tar.gz:application/vnd.oci.image.layer.v1.tar+gzip

oras prints the manifest digest to pass as --recipe-oci-digest. Build the tarball yourself, as shown. AICR refuses the layer oras packs from a directory, because its archive has a . entry.

Check it

With the function running on that artifact, the status summary lists the overlay under appliedOverlays, and the nvsentinel Release has the mixin’s values.

Schema validation

The function builds composed resources as plain maps, not typed provider structs. It checks each one against the CRD schema Crossplane resolves for it, through Crossplane’s required-schemas protocol, and doesn’t emit a resource that fails.

StateWhat happens
Crossplane doesn’t advertise the required-schemas capabilityFatal. The function needs Crossplane v2.2 or later, or a crossplane render given --required-schemas.
The function has asked for a schema that Crossplane hasn’t resolved yetThe function doesn’t emit composed resources this pass. Crossplane calls again once the schema is resolved.
Crossplane doesn’t find a CRD of that kindFatal: no schema for helm.m.crossplane.io/v1beta1, Kind=Release: is provider-helm installed?
Crossplane resolves the schemaEvery composed resource of that kind is checked against it. A violation is Fatal.

Schemas the recipe needs

The Release schema is required when the recipe has a chart, and the Object schema when one of its manifest files renders a document. A recipe whose manifest files don’t render anything doesn’t oblige you to install provider-kubernetes. That includes dra-node-labeler, which is part of most stock recipes and whose manifest is empty unless DRA eviction is on.

With crossplane render, supply the schemas with --required-schemas=DIR. See Render locally.

Rollout order

The function withholds composed resources from the desired state until what AICR orders before them is observed Ready. This is the gate. It orders creation only.

Every Release sets spec.forProvider.wait: true. provider-helm then reports a Release Ready only once the Helm release’s resources are up, and that’s the signal the gate reads.

The signal is about the installation. provider-helm waits for the resources while it installs or upgrades a release. Afterward it reports the Release Ready for as long as the Helm release is deployed and matches the Release’s specification, even when its pods have stopped.

An upgrade interrupts the signal for longer than it runs. provider-helm marks a Release unready when it starts to upgrade it, and looks at it again at its next poll, which comes every 10 minutes by default. A component whose values or version changed reports unready until then, and the composite resource with it, although Helm finished the upgrade long before. Nothing is withheld in the meantime, because the gate leaves what’s already deployed alone. provider-helm’s --poll flag shortens the wait.

The rules

For each component:

  • its pre-manifest Objects wait for the components it depends on;
  • its Release waits for those dependencies and for its pre-manifest Objects;
  • its post-manifest Objects wait for its Release.

A manifest-only component has no Release. Its Objects all wait for its dependencies, and as somebody else’s dependency it’s ready when every Object it emitted is.

A dependency counts only when the function deploys it. One that’s skipped, turned off by the recipe or left out by componentClasses is satisfied.

Every resource the gate withholds raises a Normal result that says what it waits for. The status summary lists a component under pendingComponents while its Release, or an Object of a manifest-only component, is withheld.

Crossplane’s circuit breaker

Crossplane limits how often watch events reconcile one composite resource. It allows a burst of 100 events and one more per second after that, counting each change to the composite resource and to the resources it composes. The resources of a rollout are created together and each reports its status more than once, which can use up the burst within seconds. In the end-to-end suite a recipe of three components did so three seconds after its composite resource was created.

Crossplane then sets the condition Responsive to False with the reason WatchCircuitOpen. For the next five minutes it lets one event through every 30 seconds. The rollout continues, but each step waits for the next of those reconciles, and the status summary lags by as much.

If that’s too slow, raise --circuit-breaker-burst in Crossplane’s arguments. The suite’s recipe was ready after 64 seconds with the default and after 5 seconds with a burst of 1000.

Live resources

A resource that has already been observed is never withheld. The gate must not tear down a live resource because a sibling went unready for a moment.

Turning it off

skipDeploymentOrder: true emits every component at once. Use it only when something else orders the installs, or when the order doesn’t matter.

Node scheduling

A cluster for AI workloads often has its accelerated nodes in a pool of their own, set apart from the other nodes by labels and taints. nodeScheduling places a recipe’s components on those pools:

nodeScheduling:
  system:
    nodeSelector:
      nodeGroup: system-pool
    tolerations:
    - key: dedicated
      operator: Equal
      value: system
      effect: NoSchedule
  accelerated:
    nodeSelector:
      nodeGroup: gpu-pool
    tolerations:
    - key: nvidia.com/gpu
      operator: Equal
      value: present
      effect: NoSchedule

AICR’s component registry lists, for each component, the chart values that take a node selector or tolerations. It lists them in two groups: system for operators, controllers and webhooks, and accelerated for what runs on the accelerated nodes, such as device plugins, drivers and exporters. The function writes each placement to the values of its group.

These are the values that AICR’s bundle command writes its --system-node-selector, --system-node-toleration, --accelerated-node-selector and --accelerated-node-toleration flags to, by the same rules.

Merge rules

A placement replaces what the component’s values have at a path. A recipe can decide otherwise with an override of its own at that path:

The recipe’s override at the pathNode selectorTolerations
NoneReplacedReplaced
A list of tolerationsAppended to
Empty, as in tolerations: []Left aloneLeft alone

The kind recipes set the GPU Operator’s daemon set tolerations to an empty list, and so keep the chart’s default there whatever nodeScheduling says.

A path the registry lists in both groups belongs to a workload that runs on every node, such as the worker of Node Feature Discovery. It gets the accelerated tolerations and those system tolerations that name a key. A system toleration without a key, which tolerates every taint, is left out of such a path once accelerated tolerations are set.

componentOverrides.<component>.values are merged afterward. Use them to place one component differently: a list of tolerations there replaces what was written, and a node selector is merged into it.

The function has no default placement

AICR’s command line tolerates every taint when its toleration flags are unset. The function writes only what the Input states, so an upgrade of the function doesn’t reschedule a running stack. To get what the command line does for system workloads, state the toleration:

nodeScheduling:
  system:
    tolerations:
    - operator: Exists

Give the accelerated workloads tolerations that name a key. On AKS a toleration without one deadlocks the first installation of NodeWright’s packages, and AICR’s bundle checks refuse it there.

Components that require a node selector

A registry entry can require a node selector. AICR requires one where the wrong pool breaks the component without an error, as with a StatefulSet whose volume is in one zone. AICR’s bundler refuses to build a bundle without the selector, and the function reports Fatal for a component that isn’t deployed yet:

component "slinky-slurm" requires nodeScheduling.system.nodeSelector: its values have no node selector at …

In AICR v1.3.0 the entries of slinky-slurm, slurm-accounting-mariadb and nvsentinel-mongodb require one. Of the embedded recipes, that’s the six Slurm recipes for AKS, EKS and GKE.

A component that’s already deployed isn’t refused. The function raises a Warning for it and deploys it as before, because a selector added to a running StatefulSet can move it away from the zone of its volume. Give such a component its selector through componentOverrides, where it applies to that component alone.

The check reads the values the component is deployed with, so a selector from componentOverrides satisfies it too. A recipe that sets the path to an empty value has decided to deploy without one, and the check lets it.

AICR’s bundle checks

AICR’s component registry declares checks for some of its components, and AICR’s bundler runs them before it writes a bundle. They guard combinations that install cleanly and then break a cluster. The function runs the same checks, with AICR’s own code, on every request.

Two of them matter for the stock recipes of AICR v1.3.0:

  • On AKS, a toleration without a key deadlocks the first installation of NodeWright’s packages. The tuning manifest renders one when nodeScheduling.accelerated.tolerations is empty. The four AKS recipes need tolerations that name a key.
  • On OKE, the gb300 tuning resource reboots every node it matches, so that recipe needs nodeScheduling.accelerated.nodeSelector.

The 81 stock recipes of that version all pass the checks once both placements are stated, with keyed tolerations.

AICR limits a check like these to a service or an accelerator. Such a check also applies to a recipe whose criteria leave that dimension unstated: a recipe without a service could be deployed to AKS.

Findings

AICR rates a check error, warning or info.

AICR’s ratingThe component isn’t deployed yetThe component is already deployed
errorFatal: the function composes nothingWarning
warningWarningWarning
infoNot reportedNot reported

A component that’s already deployed isn’t refused, because its stack was accepted before, by an earlier version of the function or of the catalog. Refusing it would stop every other change to the stack until the finding is resolved, which for a running workload can need more care than an upgrade allows. The Warning ends in is already deployed, so it is not refused.

The same rule applies to a component that requires a node selector.

A finding reads like this:

AICR's bundle check for "nodewright-customizations": [INVALID_REQUEST] nodewright-customizations renders a wildcard (keyless) accelerated-node toleration. AKS admission collapses a pod's tolerations to just the wildcard, which deadlocks nodewright packages that declare interrupts on first install (NVIDIA/nodewright#296). Pass keyed tolerations instead, e.g. nodeScheduling.accelerated.tolerations nvidia.com/gpu:NoSchedule.

The request as the checks see it

The checks were written for AICR’s command line. The function describes a request to them in its terms:

AICR’s command lineThe Input
--system-node-selector, --system-node-toleration, --accelerated-node-selector, --accelerated-node-tolerationnodeScheduling
--set <component>:enabled=falseskipComponents
--set-json <component>:<path>=<value>componentOverrides.<component>.values
--dra-eviction-node-labeldraEviction

Where AICR’s text has one of the four scheduling flags, the message has the Input field. Any other flag appears as AICR wrote it, and the table says what stands for it.

The function checks the components that the composite resource deploys. One that componentClasses leaves to another composite resource is checked there.

DRA eviction

When the GPU Operator replaces a driver in place, the DRA kubelet plugin has to leave the node first. AICR’s contract for that spans three components, and draEviction: true wires it.

ComponentSetting
dra-node-labelerEnabled. Its manifest is empty by default. Enabled, it labels every GPU node nvidia.com/dra-kubelet-plugin=true.
nvidia-dra-driver-gpuThe kubelet plugin is scheduled only on nodes with that label.
gpu-operatorThe Driver Manager is told the label’s key. It changes the label’s value while it replaces the driver, which makes the plugin leave the node, and restores it afterward.

The wiring is applied after componentOverrides, so an override can’t leave the three disagreeing. Other node selectors and environment entries are kept.

A recipe without all three components has no contract to wire. The function raises a Warning and wires nothing. The OpenShift variants of the components aren’t covered, as in AICR.

Upgrades

Each release of the function embeds the catalog of one AICR release, so an upgrade of the function is also an upgrade of every stack it serves. Chart versions move, components appear, and the default namespace of a component can change. This page covers what the function does about that, and what to check before moving on from v0.2.

The catalog comes with the Function package, not with the Composition. A new function version reaches every composite resource the function serves, on its next reconcile.

Upgrade warnings

A pass can change the chart version of a Release that’s already deployed: a new AICR release moved the recipe’s pin, or an override changed. The function looks every such move up in AICR’s upgrade records. They rate a recorded move safe, manual or blocked. A move the records don’t cover is unknown, or blocked when it crosses a recorded boundary from a version that isn’t the start of a record. Anything but safe raises a Warning on the composite resource with AICR’s explanation and the summary of each record the move crosses.

The upgrade is still applied. The Warning is raised on the passes where the observed and the composed version differ, which is while the change is being applied, so it isn’t a check to run before an upgrade. The records are in AICR’s catalog under recipes/components/<component>/upgrades.yaml.

Namespaces

A component that’s already deployed keeps its namespace when the new recipe places it in another one. See Components and overrides. The Warning it raises quotes both namespaces and the override that moves the component.

Moving on from v0.2

v0.2 embeds AICR v0.20.0. The version after it embeds AICR v1.3.0 and changes the Input.

The Input

criteriaFrom and providerConfigRefFrom are removed. Move the values under one object on the composite resource and point overlayFrom.fieldPath at it. See Values from the composite resource. A Composition that still sets a removed field is Fatal, and the message says what replaced it.

A field the Input doesn’t have is now Fatal. It used to be ignored.

The function now refuses what AICR’s bundler refuses. A new stack isn’t deployed when a component requires a node selector it doesn’t have, which affects the Slurm recipes for AKS, EKS and GKE, or when one of AICR’s bundle checks fails, which affects the AKS recipes and the OKE gb300 recipe. Set nodeScheduling. A stack that’s already deployed keeps running and gets a Warning for each.

In the status summary, componentCount is now the number of components the recipe deploys. It used to equal the length of deployedComponents.

The catalog

AICR’s own upgrade records don’t rate these moves safe. They’re the registry pins of AICR v0.20.0 against the EKS h100 training recipe of v1.3.0. The function applies them and raises a Warning for each.

ComponentMoveVerdict
gpu-operatorv26.3.3 to v26.7.2blocked: no record starts from v26.3.3
nvidia-dra-driver-gpu0.4.1 to 0.5.1blocked: no record starts from 0.4.1
nvsentinelv1.20.0 to v1.31.0blocked: no record starts from v1.20.0
kai-schedulerv0.14.1 to v0.16.9unknown
kube-prometheus-stack84.4.0 to 84.5.0manual
nfd0.19.0 to 0.20.1manual
nodewright-operatorv0.17.1 to v0.21.0manual

Other changes to plan for:

  • nodewright-operator moves its default namespace from skyhook to nodewright, and the kind of its tuning resource changes from Skyhook to NodeWright. The function keeps the operator in skyhook on an existing cluster. The Object for the tuning resource gets a new name, so the old one is deleted and the new one created.
  • The stock recipes use NKTP for telemetry where they used the full kube-prometheus-stack.
  • cert-manager enables its ServiceMonitor and depends on prometheus-operator-crds. If you skip that component, the CRDs must come from somewhere else.
  • A recipe source artifact written for an AICR older than v1.0.0 is refused at startup.

Troubleshooting

Each entry is a message the function reports, or a symptom, with its cause. The function reports through events on the composite resource; with crossplane render, pass --include-function-results to see them.

Fatal results

function-aicr requires a Crossplane that supports required schemas

Crossplane didn’t advertise the required-schemas capability. Upgrade Crossplane to v2.2 or later, or pass --required-schemas=DIR to crossplane render.

no schema for …, Kind=Release: is provider-helm installed?

Crossplane didn’t find a schema. The provider whose CRD has that kind isn’t installed, or the files under --required-schemas have no schema for it. The same message names provider-kubernetes for Kind=Object.

criteriaFrom was removed and providerConfigRefFrom was removed

The Composition was written for an older Input. Move the values under one object on the composite resource and set overlayFrom.fieldPath. See Values from the composite resource.

cannot resolve the function input: invalid Input

The Input, or the overlay merged into it, has a field the Input doesn’t have. The message quotes the field. Check the spelling against the Input reference.

invalid AICR recipe criteria

A criteria value isn’t one AICR knows, such as an accelerator that doesn’t exist. The message quotes the value. Correct it.

cannot resolve AICR recipe: … no recipe provides os 'ubuntu' for criteria(…)

Each value is valid, but AICR’s catalog has no recipe for the combination. Leave the dimension the message quotes unstated, in the Input and in the overlay.

no criteria resolved

The Input and its overlay state no criteria dimension. With overlayFrom set, check that the field path exists on the composite resource. When the path is absent, the function uses the static Input alone.

providerConfigRef.name is required

Neither the Input nor the overlay sets providerConfigRef.name.

the overlay at "…" must not set …

The object on the composite resource sets overlayFrom, apiVersion, kind or metadata. Remove the field: the overlay holds the Input’s own fields only.

invalid Release for "…" and invalid Object "…"

A composed resource failed the provider’s CRD schema. With an override, check its values. Without one, the installed provider is likely older than the fields the function sets.

component "…" requires nodeScheduling.system.nodeSelector

AICR’s registry requires a node selector for the component, and its values have none. Set the selector the message names. See Node scheduling. For a component that’s already deployed the same message is a Warning.

AICR's bundle check for "…"

AICR would refuse to build a bundle for this request, and the message is AICR’s reason. It’s Fatal for a component that isn’t deployed yet and a Warning otherwise. See AICR’s bundle checks for what the checks read from the Input.

cannot resolve the node scheduling

A node selector under nodeScheduling isn’t made of valid labels, or a toleration is one the API server would refuse. The message quotes it.

this recipe ships torch-distributed-tcpxo and requires configuration.gke.tcpxoInterfaces

The h100 / gke / cos / training / kubeflow recipe needs the cluster’s GPU network names. Set configuration.gke.tcpxoInterfaces. See Recipe variants and configuration.

componentClasses names "…", which is not an AICR component class

The classes are core and ops.

Warnings

skipComponents names "…", which is not a component of the resolved recipe

The name matches no component, so nothing was skipped. Check the spelling against deployedComponents and pendingComponents in the status summary.

componentOverrides["…"] names no managed component of the resolved recipe

The override is ignored. The component is misspelled, skipped, left out by componentClasses or turned off by the recipe.

"…" stays in namespace "…", where it is deployed

The recipe now places the component in another namespace, and the function doesn’t move a live Release. Nothing is wrong. To move the component, set the override the message names, and read what a move leaves behind first.

upgrading "…" from … to … is rated … by AICR

AICR’s upgrade records don’t rate the chart version change safe. The change is applied anyway. Read the explanation in the message, and see Upgrades.

draEviction is set, but "…" is not a managed component

The eviction contract spans gpu-operator, nvidia-dra-driver-gpu and dra-node-labeler. One of them is skipped, turned off by the recipe or left out by componentClasses, so the function doesn’t wire any of it.

Symptoms

No resources are composed, or only a few components appear

The gate is withholding the rest. Read the Normal results (delaying X until dependency Y is ready) or pendingComponents in the status summary.

The rollout advances one step every 30 seconds

The composite resource has the condition Responsive at False with the reason WatchCircuitOpen. Crossplane’s circuit breaker is open, and the rollout continues at its pace.

The composite resource is unready for minutes after a change

A component whose values or version changed was upgraded, and provider-helm reports its Release ready again only at its next poll. See Rollout order. The workload is running by then.

delaying X until dependency Y is ready never goes away

Y isn’t reaching Ready in the target cluster. Look at its Release or Object and at the provider’s events for it.

The function pod restarts with cannot pull the OCI recipe source

The function exits when the recipe source can’t be pulled or validated. It never falls back to the embedded catalog.

The error mentionsCause
authenticationThe Docker config (DOCKER_CONFIG) has no credentials for the registry.
a certificateThe registry’s CA isn’t in the trust store (SSL_CERT_FILE).
invalid materialized OCI recipe catalogThe artifact isn’t a recipe tree with registry.yaml at its root.
the apiVersion of the external registry.yamlThe artifact was written for an AICR older than v1.0.0.
unsafe archive path componentThe layer was packed from a directory by oras. See Opt in to a mixin.

The function pod restarts with --recipe-oci-digest must be an immutable sha256 manifest digest

The flags are checked before anything is pulled. --recipe-oci-digest must be the artifact’s sha256: manifest digest. A tag is refused. Set --recipe-oci-repository with it.

The summary doesn’t show up in the status

The XRD doesn’t declare a schema for target.fieldPath, and Crossplane prunes undeclared status fields. Add the subschema from example/clusterstack/definition.yaml.

Development

This page is for contributors. It covers the layout of the repository and the commands that build, generate and lint it. Testing covers the tests.

Layout

PathContents
fn.goRunFunction and the stack type: render, compose, gate, summary. Start here.
main.goThe command line, the gRPC server and the recipe source.
input/v1beta1/The Input API types. The CRD under package/input/ is generated from them.
internal/resolve/The overlay from the composite resource, the criteria and the provider config.
internal/compose/The Release and Object builders, manifest rendering, value merging, DRA eviction wiring.
internal/schema/OpenAPI v3 validation of composed resources.
test-fixtures/The requests TestRunFunction sends and the goldens it compares against.
example/clusterstack/The XRD, Composition and composite resources of the render walkthrough.
test/e2e/The end-to-end suite, a Go module of its own.
Makefile, build/The end-to-end cluster and the Crossplane make library it uses.
docs/This site.

fn.go and main.go live in package main, the layout of Crossplane’s function template.

Build

# Generate the deepcopy code, the Input CRD and the golden fixtures
go generate ./...

# Build
CGO_ENABLED=0 go build ./...

# Lint; the version CI pins is in .github/workflows/ci.yml
golangci-lint run

# Build the runtime image, then a function package from it
docker build . --tag=runtime
crossplane xpkg build -f package --embed-runtime-image=runtime

go.mod is the source of truth for the Go version. CI reads it and passes it to the image build.

CI’s check-diff job runs go mod tidy and go generate ./... and fails when either leaves the tree changed, so commit what they produce.

Add an Input field

  1. Add the field to input/v1beta1/input.go with its kubebuilder markers.
  2. Run go generate ./..., which regenerates the deepcopy code and the CRD.
  3. Use the field in fn.go. The overlay can set it with no further code.
  4. Add a fixture under test-fixtures/input/ and a TestRunFunction case. Give the case a new golden if the field changes the composed resources, regenerate, and review test-fixtures/want/.
  5. Document it in the Input reference.

Bump AICR

The version of aicr.run, AICR’s Go module, is the recipe catalog version. A bump changes what the function deploys, so it’s a minor release and never a patch.

  1. go get aicr.run@vX.Y.Z && go mod tidy
  2. go test ./.... TestRunFunction fails wherever recipe content changed. TestCatalogInvariants fails, with the recipe and component named, wherever a recipe’s shape broke an assumption of the function.
  3. go generate ./..., then review the diff under test-fixtures/want/. It’s exactly what the function now deploys.
  4. Render both example composite resources.
  5. Re-read AICR’s node scheduling pass, applyNodeSchedulingOverrides and validateRequiredNodeSelectors in pkg/bundler/bundler.go, and its DRA eviction wiring, injectDRAEvictionLabel and its helpers. The function has a hand copy of both. TestNodeSchedulingAcrossTheCatalog and TestDRAEvictionConstants catch a registry entry or a constant the copy doesn’t cover, but not a change in behaviour.
  6. Label the pull request e2e. The end-to-end suite then also deploys a stock recipe of the new catalog onto simulated nodes.
  7. Fix behaviour changes by hand. A component the catalog adds joins every TestRunFunction fixture that doesn’t skip it.

AGENTS.md in the repository has the same procedure with more detail.

Conventions

  • Go: a pointer to a literal is new(value). Pointer helper functions aren’t used.
  • Tests are table-driven and compare with go-cmp. No third-party test packages.
  • Commits follow the conventional format, <type>(<scope>): <subject>, one logical change each.

Testing

This page is for contributors adding or changing a test. It says what each suite covers and how the golden fixtures work.

go test ./...            # everything
go test -race ./...      # with the race detector
SuiteWhat it covers
TestRunFunctionThe function end to end at the request level: hand-written requests in, the whole response compared.
TestCatalogInvariantsEvery leaf recipe of the embedded catalog, for the properties the function relies on.
TestDRAEvictionAcrossTheCatalog, TestDRAEvictionConstantsThe hand copy of AICR’s DRA eviction wiring, against the catalog and against AICR’s source.
TestNodeSchedulingAcrossTheCatalogNode scheduling on every leaf recipe: with both node selectors set, each component is accepted and every manifest still renders.
TestEndToEndCatalogThat the end-to-end suite’s catalog resolves to its own components alone.
TestUpgradeRecordsThat AICR’s upgrade records still load and pass AICR’s own checks.
TestGate, TestSummary and the other unit testsOne piece each, with hand-built inputs.
internal/resolve, internal/compose, internal/schemaThe packages’ own tables.

They all run without a cluster. crossplane render on the example is part of the development loop, not a suite. The end-to-end suite is the one tier that needs a cluster, and it’s a separate Go module.

The request suite and its goldens

Each case is a request built from fixtures under test-fixtures/:

DirectoryContents
input/Hand-written function Inputs. Cases that send the same Input share one.
observed/Hand-written observed composite and composed resources.
desired/Hand-written desired composite resources handed to the function.
want/Generated goldens: the function’s own output for those requests.

The static parts of a response (requirements, results, conditions) are asserted in the test’s code. The desired state is compared against the goldens under want/.

go generate ./... rewrites the goldens. It deletes want/ and runs TestRunFunction with -update, so a golden is always the function’s current output. Review the diff: it’s what the function deploys. A case that produces desired resources must have a golden directory, and two cases must not write different content to the same one.

The fixtures skip most of a recipe’s components to pin a small set. When an AICR bump adds a component, add it to the fixtures’ skipComponents.

The tests use a schema that accepts anything. They prove the validation is wired, without pinning the test to a provider’s CRD; internal/schema tests the validation itself.

TestCatalogInvariants

It resolves the leaf recipes of the catalog with AICR’s recipe.ResolveLeaves and asserts shape, not content:

  • every manifest file renders and parses;
  • no two documents map to the same Object name;
  • every deployed component is in AICR’s deployment order;
  • every dependency is a component of the recipe;
  • the gate emits the whole recipe once everything it emitted is Ready.

When it fails after an AICR bump, a recipe’s shape broke an assumption. Fix the function, not the test.

The end-to-end suite

test/e2e runs the function the way a control plane does. make e2e.up builds it from the tree and installs it as a Function package in a kind cluster, next to Crossplane, provider-helm, provider-kubernetes, function-auto-ready and an OCI registry. The providers compose into the kind cluster itself. The registry has a small catalog of the suite’s own, which the function serves as its OCI recipe source. A feature deploys one of its recipes in seconds.

git submodule update --init   # the Crossplane build submodule, once
make e2e.up
make e2e.test
make e2e.function             # after a code change
make e2e.down

The suite follows the one in crossplane/crossplane. Features are built with sigs.k8s.io/e2e-framework and Crossplane’s e2e helpers, and each keeps its manifests in a directory under test/e2e/manifests/. It’s a Go module of its own, so go test ./... at the root doesn’t build it.

A second profile deploys a stock recipe with its real charts onto nodes that KWOK simulates, the way AICR’s own KWOK lane does.

CI runs the suite on request only. On a pull request that’s by label: e2e runs both profiles, and e2e:catalog and e2e:kwok run one. Renovate labels its pull requests e2e. The suite can also be started from the Actions tab.

make e2e.up E2E_PROFILE=kwok
make e2e.test E2E_PROFILE=kwok

test/e2e/README.md describes the clusters, the catalog and how to add a feature.

Conventions

Tests are tables: a map[string]struct keyed by case name, with reason, args and want. Results are compared with cmp.Diff, and a RunFunction case compares the whole response. testify, gomock and similar packages aren’t used.

Design decisions

The decisions behind the function’s design, each with what it rules out. AGENTS.md in the repository has more detail on most of them.

Composed resources are untyped and validated against required schemas

Importing provider-helm’s and provider-kubernetes’ typed API structs conflicts with the function SDK from v0.7 on. Composed resources are plain maps, and each one is checked against the CRD schema Crossplane resolves through the required-schemas protocol: the schema of the provider version that’s installed. Without the capability the function is Fatal. Each schema is compiled once per kind and request.

Readiness comes from observed state only

The gate reads the conditions of observed resources, never the readiness in the desired state. function-auto-ready sets that later in the pipeline, and reading it would deadlock the gate. A resource that’s already observed is never withheld.

A deployed Release is never relocated

A Helm release can’t be moved between namespaces. When an AICR release changes a component’s default namespace, the function keeps the namespace the observed Release has. This is the one place where observed state changes a composed resource instead of only delaying it. The order of the pipeline can’t break it, because the value is read from the spec of the observed Release, which is what the function itself last emitted.

One overlay object instead of per-field paths

Through v0.2 each sourced field had a twin with a field path in it. That doubled the API with every new field and only fit strings, while AICR’s inputs include lists and maps. overlayFrom.fieldPath reads one object with the fields of the Input, so any field can be sourced without a mirrored type. The XRD documents and checks what a composite resource may set, and pruning makes it the allowlist.

A criteria dimension is never defaulted

AICR’s catalog decides which combinations exist. An unstated dimension selects the agnostic tier, and AICR rejects a stated value that isn’t part of a recipe. The function checks the values against AICR’s and passes them through. It mirrors no rule about which values go together.

Manifest files are rendered with AICR’s renderer

Helm-style templates make up most of the catalog’s manifest files. They’re rendered with aicr.run/pkg/manifest, exactly as AICR’s bundler renders them. A file that fails to render or parse is Fatal.

Names are deterministic

A composed resource’s name comes from its component and manifest document alone, because the gate matches observed resources to desired ones by name. The consequence is one composite resource per target cluster and namespace.

The recipe source belongs to the function and is pulled once

AICR’s pull budget is minutes, and the deadline of a function call is seconds. A source per request would need an asynchronous cache and a “still fetching” response. The --recipe-oci-* flags configure one catalog per function deployment, pulled before the function serves. A reconcile never touches the network, and a bad source fails visibly at startup. Only an immutable sha256: digest is accepted.

The DRA eviction wiring is a copy

AICR’s bundler keeps its eviction wiring unexported, and the function doesn’t use the bundler. draEviction applies a hand copy of that logic. One test compares its names and value paths with the constants in the bundler’s source, and another wires every recipe that has the three components.

An unsafe upgrade is reported, not held

When AICR’s records don’t rate a change of chart version safe, the function warns and applies it. Holding a version back needs a way to acknowledge the move, which doesn’t exist yet.

Upgrade approval

  • Owner: @jonasz-lasut (Jonasz Małecki)
  • Reviewers: function-aicr maintainers
  • Status: draft (the design is open for review; an issue for the work follows once this record is merged)

Summary

A release of the function embeds one AICR catalog. Installing it changes chart versions on every stack the function reconciles, on the next pass. The function looks each change up in AICR’s upgrade records and raises a Warning for every one AICR doesn’t rate safe. It applies the change in the same pass.

This record adds an approval that a Composition opts in to. With upgradeApproval set, a component whose version change isn’t rated safe keeps what it has deployed until an approver writes that change into the status of the composite resource. Components that depend on it wait with it. First installs and changes rated safe aren’t delayed.

The approval is a status field, as in function-approve. The rule for what needs one comes from the AICR Operator (ADR-027): a change runs unattended only when AICR rates it safe.

Background

stack.warnUnsafeUpgrades reports AICR’s verdicts and delays nothing. The upgrades page lists what that meant for a stack moving from the catalog of AICR v0.20.0 to the one of v1.3.0: seven changes that aren’t safe, of which AICR rates three blocked, three manual and one unknown. The function applied the seven together with the rest.

With approval on, that catalog change would have needed an approval for four components and a version set by hand for the three blocked ones. AICR v1.3.0 has upgrade records for 24 of its 58 registry components, and a version change of a component without a record is unknown. The 43 recorded transitions are 26 manual and 17 safe.

Design

Opting in

upgradeApproval:
  fieldPath: status.upgrades

fieldPath is an object on the composite resource. The function writes what it delays there and reads the approvals from it. The path must begin with status, as target.fieldPath must. The XRD has to declare the object, because Crossplane prunes a field the XRD doesn’t declare.

Without upgradeApproval the function behaves as it does today.

Which components are held

On every pass the function compares the chart version of each observed Release with the version it’s about to compose and hands the differences to upgrade.Match. That part exists today. With approval on, a component is held when one of these is true:

  • Its version change isn’t rated safe (ComponentResult.FailsRun) and the status doesn’t approve it.
  • It depends on a held component, directly or through other components.

The second rule follows the edges the gate already reads (ComponentRef.DependencyRefs). Without it nvidia-dra-driver-gpu would move to the version of the new catalog while gpu-operator waits at the old one. The driver depends on the operator, and the two charts share the ComputeDomain CRD.

A component that isn’t deployed has no version change, and a first install waits only when the component depends on a held one. When AICR’s records can’t be loaded, every version change is held: a change nobody assessed isn’t safe.

Resources of a held component

The function composes the whole stack as usual and then replaces the held components’ part of it:

  • Each observed composed resource of a held component is emitted with its observed spec.
  • A resource of the component that isn’t observed yet isn’t created.
  • An observed resource that the new recipe doesn’t render any more remains.

The providers don’t see a change. They keep reconciling what’s deployed, and its readiness is still the live one. The rest of the stack follows the new catalog.

A resource belongs to the component its name starts with: the Release has the component’s name, and an Object is <component>-pre-... or <component>-post-.... The longest component name that fits is the owner. Names are already a pure function of the component and the document, because the gate correlates by name.

This is the second place where observed state changes a composed resource. The first is a deployed Release keeping its namespace. It has the same justification: the spec of an observed resource is what the function itself last emitted.

The approval

With the catalog change from the Background section, the composite resource shows this:

status:
  upgrades:
    held:
    - component: nfd
      from: 0.19.0
      to: 0.20.1
      verdict: manual
    - component: gpu-operator
      from: v26.3.3
      to: v26.7.2
      verdict: blocked
      waitingFor: nfd

Each entry with a verdict also has AICR’s explanation and the summary of every record the change crosses, which are the texts of today’s Warning. nvidia-dra-driver-gpu is in the list too, waiting for gpu-operator.

An approver writes the change under approved:

kubectl patch clusterstack gpu-training-stack --subresource=status --type=merge \
  -p '{"status":{"upgrades":{"approved":{"nfd":{"from":"0.19.0","to":"0.20.1"}}}}}'

On the next pass the entry equals the pending change of nfd, and the function composes nfd from the new catalog. The rules:

  • An entry approves one change of one component, from one version to another. A new release of the function with another target needs a new entry.
  • The function never writes approved. An entry that’s been used matches only the same change again.
  • An entry for a held component with other versions raises a Warning that quotes both.
  • blocked can’t be approved. AICR’s records say the change mustn’t happen in one step. componentOverrides.<component>.version sets a target AICR doesn’t block, and the function assesses that change like any other. For gpu-operator in the example the target is v26.7.0, where AICR’s records begin. AICR rates the change to v26.7.0 unknown, which an approver can accept. It rates the change from there to v26.7.2 safe.
  • A component that only waits for another doesn’t need an entry.

Kubernetes RBAC separates the roles. Updating the status of a composite resource is a permission of its own (clusterstacks/status for the example), apart from editing the resource. The audit log records who approved.

Results and status

The function raises today’s Warning for each held change and adds where the approval goes. A component that waits for another gets a Normal result, as a component the gate delays does. held is an empty list when nothing is held. In the status summary, deployedComponents lists a held component with the version it’s deployed with.

Next to the AICR Operator

AICR OperatorThis design
Unit that waitsthe whole transitiona component and its dependents
A chart that renders a CRDneeds approvalnot assessed: the function doesn’t render charts
The approval is bound tothe live engine objects, the plan and its stepsthe component and both versions
Expiry and revocationbothneither: an entry is removed by hand before it’s used
Steps after the changea second acknowledgementthe operator’s to do, from the Warning
Validation after the rolloutdeployment validation, bound as evidencenone
blockedno approval overrides itthe same

Code shape

  • input/v1beta1: UpgradeApproval with FieldPath, and the same check validateTarget makes.
  • internal/compose: Owner, which attributes a composed resource’s name to a component, and Keep, which builds the desired resource from an observed one.
  • fn.go: stack.holdUpgrades runs after composeObjects and before the gate. It takes over the assessment from warnUnsafeUpgrades, which remains for a stack without approval. The held list is written through setStatus.

aicr.run/pkg/upgrade is in AICR’s internal tier. The warnings already depend on it.

Tests

  • TestHoldUpgrades drives stack.holdUpgrades through hand-built maps, as TestGate does. Its cases are a held change and an approved one, a blocked change, a dependent, an approval with other versions and a resource the new recipe drops.
  • TestRunFunction gets cases with goldens for a held and an approved change.
  • TestCatalogInvariants asserts that compose.Owner attributes every name a leaf renders to the component that rendered it.
  • End to end, catalog profile: a second chart version and an upgrade record with a manual transition in test/e2e/catalog. The feature overrides the version of a deployed component and expects the Release unchanged and the change under held. After it patches the status, the release is upgraded. The feature also shows that the function’s status writes keep the field an approver wrote, which function-approve relies on too.

Documentation

A section in Upgrades, the field in the Input reference, an entry in Design decisions and one in Troubleshooting for a stack that doesn’t upgrade. The example XRD declares status.upgrades.

Compatibility

The field is optional and nothing changes without it. Setting it on a running stack delays nothing until a version change is pending. Removing it applies every held change on the next pass.

Alternatives

A pipeline step with function-approve

function-approve hashes one field of the desired composite resource and returns a Fatal result until a status flag approves the hash. That fits a rule that any change to one field needs approval. It can’t express AICR’s verdicts: a list of pending changes is empty again once they’re applied, which is a new hash. It also asks for an approval of the first install and stops the whole composite resource while it waits.

Holding the whole stack

The AICR Operator waits with the entire transition when one component isn’t safe. Here the function would emit every observed resource unchanged until one approval covers the transition. The attribution by name and the rule for dependents would go away, and a stack would be on one catalog at a time. Other changes would wait as well while an approval is pending: a toleration that has to be fixed today waits for the upgrade to be approved.

The approval in the Input

A list of approved changes in the Input, set on the composite resource through the overlay, doesn’t need a status field and fits a stack managed from Git. Whoever edits the composite resource could then approve its upgrades.

Pausing the resources

The function could emit the new spec with crossplane.io/paused. The pending change would be visible on the Release. The provider would stop correcting drift. The observed spec would also stop saying what’s deployed, and the assessment reads the deployed version from it.

A boolean approval

function-approve’s approved: true approves whatever is pending when the function next runs. An entry with both versions approves what the approver read.

Open questions

  1. Whether a held component takes its dependents with it, as designed here, or the whole stack waits, as with the AICR Operator.
  2. Whether blocked can be approved. The three blocked changes in the Background section start from versions older than AICR’s records, and each needs an intermediate version set by hand.
  3. Whether unknown needs an approval. It’s the verdict of every version change of the 34 components without a record, and it’s a Warning today.
  4. Whether the approval remains opt-in after a release or two.

A component with a short-lived credential is a second use for the hold: issue 24 needs a fresh token in a Secret before such a component is upgraded, and an approval is the moment to write one.