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

CUE Model Structure

When developing CUE modules that integrate with Cuestomize, it is important to first understand how Cuestomize interacts with CUE, and which structures are required in order to ensure compatibility.

StructureSourced FromPurpose
apiVersionThe KRM configuration apiVersion field.Allows CUE module developers to constrain the supported version of the KRM configuration.
kindThe KRM configuration kind field.Allows to constrain the supported kind of the KRM configuration.
metadataThe KRM configuration metadata field.Allows to access metadata information from the KRM configuration.
inputThe KRM configuration input field.Access the inputs from the KRM configuration.
includesThe resources in the kustomize input stream matching the configuration includes selectorsAccess the included resources from the KRM configuration.

Here is an example of what a CUE model would see from a given KRM configuration:

apiVersion: cuestomize.dev/v1alpha1
kind: Cuestomization
metadata:
  name: example
input:
  name: example
  annotations:
    example-annotation: example-value
  replicas: 3
includes:
  - version: v1
    kind: Namespace
    annotationSelector: app=example

The configuration above selects all Namespaces with the label app=example from the input stream, and includes them in the includes structure of the CUE module.

The above KRM configuration would provide the following structures to the CUE module (assuming there is a matching Namespace in the input stream):

apiVersion: "cuestomize.dev/v1alpha1"
kind: "Cuestomization"
metadata: {
    name: string
}

input: {
    name: example
    annotations: {
        example-annotation: example-value
    }
    replicas: 3
}

// includes structure: <apiVersion>: <kind>: <namespace>: <name>: {object}
includes: {
    "v1": {
        "Namespace": {
            "": {
                "example-namespace": {
                    metadata: {
                        name: "example-namespace"
                        annotations: {
                            "app": "example"
                        }
                    }
                }
            }
        }
    }
}