Scenario Image Contract
Categories:
Krknctl and Krkn Operator discover scenario definitions from container image metadata. To add a custom scenario, publish an image with the expected labels and configure its registry in the client. You do not need to add the scenario to krknctl’s source code when the existing input types cover its parameters.
The packaging lab builds this contract without rebuilding krkn-hub. The definitions are implemented in krknctl’s input field parser and type validators.
Image labels
krknctl.is_a_scenarioidentifies scenario images when set to"true".krknctl.titleandkrknctl.descriptiondescribe the scenario.krknctl.input_fieldscontains a JSON array of field descriptors.krknctl.kubeconfig_pathappears in the companion image as metadata. The clients used in this lab do not read it to configure the kubeconfig mount. Set the runtime mount path independently.krknctl.privilegeddeclares a privilege requirement. It is not an RBAC grant; actual permissions depend on the client, runtime, and target credentials.krknctl.has_rollbackdescribes rollback capability. Set it to match implemented behavior, not to indicate an intended future feature.
The base image can also supply global input labels such as
krknctl.input_fields.global. Keep scenario-specific fields in the scenario
label rather than copying every framework setting into it.
Image labels are build artifacts. Changing a JSON file on disk does not change the published label until the scenario image is rebuilt and pushed.
Input field descriptors
krknctl-input.json contains an array, not a JSON Schema object with
properties. A typical field is:
{
"name": "namespace",
"short_description": "Namespace",
"description": "Kubernetes namespace whose pod names will be logged.",
"variable": "NAMESPACE",
"type": "string",
"required": "true",
"validator": "^[a-z0-9]([-a-z0-9]*[a-z0-9])?$",
"validation_message": "namespace must be a Kubernetes namespace name"
}
For ordinary input fields, name, variable, and type are required by the
parser. short_description supplies the display label; description supplies
help text. variable must exactly match the environment variable consumed by
the image’s startup code.
The descriptor format uses strings for required, secret, and default,
including numeric and boolean defaults. Use "required": "true", not the
JSON boolean true. Omit an optional property when it is not needed.
Supported input types
stringaccepts text and can apply avalidatorregular expression with a customvalidation_message.numbervalidates a numeric value. Enforce application-specific integer constraints, ranges, and units in the runtime implementation as well.booleanrepresents a boolean input; it still reaches the container as a string environment value.enumrestricts values usingallowed_valuesandseparator.filedescribes a file input with a containermount_path.file_base64describes file content encoded for a consuming script or application. Use this exact type name, notfile64.groupsupplies presentation metadata for a group of related fields. It is metadata rather than a value injected as a normal input.
Example number and enum descriptors:
[
{
"name": "wait",
"short_description": "Wait (seconds)",
"variable": "WAIT_SECONDS",
"type": "number",
"default": "2",
"required": "false"
},
{
"name": "mode",
"short_description": "Mode",
"variable": "MODE",
"type": "enum",
"allowed_values": "list,inspect",
"separator": ",",
"default": "list",
"required": "true"
}
]
An input file path is a container path, not a path on the user’s workstation:
{
"name": "settings",
"short_description": "Settings file",
"variable": "SETTINGS_FILE",
"type": "file",
"mount_path": "/home/krkn/settings.yaml",
"required": "true"
}
Keep defaults in the input metadata and runtime defaults consistent. Client
validation improves feedback, but direct podman run -e ... bypasses it. Validate
all values again before performing scenario actions.
Runtime compatibility
For Krkn Operator 1.1.2, provide /bin/bash and an executable
/home/krkn/run.sh. The controller invokes that script directly, mounts the
target kubeconfig, injects environment variables, and records the exit status.
Do not rely only on a custom OCI ENTRYPOINT being honored by every client.
The script can launch Krkn or another implementation that obeys the same
runtime contract. It must read the declared inputs, use the configured file
paths, and exit with a meaningful status. For the Krkn plugin path, return
0 or 1 from the plugin and preserve the engine’s process status with exec.
Kubeconfig mount path
Krkn Operator selects the container mount path from the run’s
spec.kubeconfigPath (kubeconfigPath in the API request). When omitted, it
uses the krknctl configuration default, /home/krkn/.kube/config in this lab.
Krknctl also uses its own configured kubeconfig_path for the mount destination;
the image label does not override that setting.
For a custom path, configure the client’s mount destination and make the
startup script read the same path. The demo’s script reads KUBECONFIG and
writes it into kraken.kubeconfig_path, so update that environment value or
the script’s default as well. Changing spec.kubeconfigPath moves the mount;
it does not rewrite the script or the Krkn YAML. Changing only the image label
does neither.
See the operator’s mount-path selection and krknctl’s default configuration.
Inspect the built contract
podman image inspect "$KRKN_SCENARIO_IMAGE" |
jq '.[0].Config.Labels | {
scenario: .["krknctl.is_a_scenario"],
title: .["krknctl.title"],
inputs: (.["krknctl.input_fields"] | fromjson)
}'
Verify discovery, input rendering, runtime validation, and execution separately. An HTTP-enabled registry client can successfully read these labels while the node runtime still fails to pull the image. See the registry lab.