status

4 min read

Orkestra writes status in two layers — one automatic, one declarative.

Layer 1 — automatic (always on). After every reconcile Orkestra patches:

  • status.conditions[type=Ready]True on success, False on error
  • status.observedGeneration — mirrors metadata.generation

No declaration required. Every managed CR gets this.

Layer 2 — declarative fields. Declared under operatorBox.status. Written after reconcile templates complete.

Wire format

operatorBox:
  status:
    conditions: true    # optional — default true

    fields:
      - path: phase
        value: "Running"

      - path: replicas
        type: int
        value: "{{ toInt .spec.replicas }}"

      - path: database.host    # dot-notation → status.database.host
        value: "{{ .spec.host }}"

      - path: endpoint
        value: "{{ .metadata.name }}.{{ .metadata.namespace }}.svc.cluster.local"

      - path: phase
        value: "Pending"
        when:
          - field: status.phase
            operator: notExists

conditions

ValueDescription
true (default)Write the standard Ready condition and observedGeneration after every reconcile.
falseOpt out. Use only when the CRD’s status schema forbids a conditions field, or you manage conditions entirely in Go hooks.

fields

A list of field declarations. Resolved in declaration order — later entries win on path conflict.

fields:
  - path: <dot.notation.path>   # required
    value: "<string or template>" # required
    type: string                  # optional
    when:                         # optional — AND conditions
      - ...
    anyOf:                        # optional — OR conditions
      - ...

Field properties

FieldRequiredDescription
pathyesDot-notation path relative to status. "phase"status.phase. "db.host"status.db.host.
valueyesValue to write. Supports Go template expressions. Static strings skip parsing.
typenoCast the resolved value before writing. Defaults to string.
whennoList of conditions — all must pass (AND). Field is skipped if any fails.
anyOfnoList of conditions — at least one must pass (OR).

When both when and anyOf are declared, both blocks must pass.

type values

ValueWritten as
string / str / "" (default)string
int / integerinteger
floatfloat64
bool / booleanboolean
autoinferred from the resolved value

Template variables

Values are Go templates evaluated against the full CR object map:

ExpressionDescription
{{ .metadata.name }}CR name
{{ .metadata.namespace }}CR namespace
{{ .spec.* }}Any spec field
{{ .status.* }}Existing status fields
{{ .children.deployment }}Child Deployment status map
{{ .children.statefulset }}Child StatefulSet status map
{{ .children.service }}Child Service status map
{{ .children.job }}Child Job status map
{{ .children.custom }}Child Custom Resource status map

Kubernetes helper functions

Functions from the Orkestra note library useful in status values:

Replicas

FunctionReturnsDescription
allReplicasReady .children.deploymentbooltrue when desired == ready
readyReplicas .children.deploymentintNumber of ready replicas
desiredReplicas .children.deploymentintDesired replica count
availableReplicas .children.deploymentintAvailable (not just ready) replicas
updatedReplicas .children.deploymentintReplicas on current pod template
rolloutComplete .children.deploymentbooltrue when rollout is fully done

Services

FunctionReturnsDescription
serviceClusterIP .children.servicestringCluster IP of the service
serviceNodePort .children.service "portName"intNodePort for the named port
serviceLoadBalancerIP .children.servicestringLoad balancer IP
serviceLoadBalancerHost .children.servicestringLoad balancer hostname
endpointsReady .children.endpointslicebooltrue when endpoints are ready

Jobs

FunctionReturnsDescription
jobSucceeded .children.jobbooltrue when job completed successfully
jobFailed .children.jobbooltrue when job failed

Type casting

FunctionDescription
toInt .spec.replicasCast to integer
toFloat .spec.ratioCast to float
toBool .spec.enabledCast to bool
toString .spec.countCast to string

when and anyOf conditions

Each condition targets a dot-notation field path and applies an operator.

when:
  - field: status.phase      # required — dot-path into the CR object
    equals: "Running"        # shorthand operators (see below)

  - field: spec.replicas
    operator: gt             # explicit operator form
    value: "0"

Shorthand fields (instead of operator + value):

ShorthandEquivalent
equals: "v"operator: equals, value: "v"
notEquals: "v"operator: notEquals, value: "v"
contains: "v"operator: contains, value: "v"
prefix: "v"operator: prefix, value: "v"
suffix: "v"operator: suffix, value: "v"
greaterThan: "v"operator: gt, value: "v"
lessThan: "v"operator: lt, value: "v"
exists: trueoperator: exists
notExists: trueoperator: notExists

All operators:

OperatorDescription
equalsField exactly equals value (string comparison).
notEqualsField does not equal value.
containsField contains value as a substring.
prefixField starts with value.
suffixField ends with value.
existsField is present and non-empty.
notExistsField is absent or empty. Use for first-reconcile detection.
gtField is numerically greater than value. Absent field treated as 0.
ltField is numerically less than value.
inField is one of a comma-separated list: value: "Pending,Running".
typeOfField’s runtime type equals value (map, slice, string, number, bool, null).
typeMapField is a YAML object.
typeListField is a YAML array.
typeStringField is a string.
typeNumberField is a number.
typeBoolField is a boolean.
typeNullField is null or missing.

Example: declarative state machine

status:
  fields:
    - path: phase
      value: "Pending"
      when:
        - field: status.phase
          operator: notExists

    - path: phase
      value: "Running"
      when:
        - field: status.phase
          equals: "Pending"
        - field: children.deployment.status.readyReplicas
          operator: gt
          value: "0"

    - path: phase
      value: "Succeeded"
      when:
        - field: status.phase
          equals: "Running"
        - field: children.job.status.succeeded
          operator: gt
          value: "0"

    - path: ready
      type: bool
      value: "{{ allReplicasReady .children.deployment }}"

    - path: endpoint
      value: "{{ serviceLoadBalancerHost .children.service }}"

→ Next: when-conditions.md