operatorBox.observe.watch

2 min read

operatorBox.observe.watch declares secondary Kubernetes resources to observe.

Declaration

spec:
  crds:
    app:
      operatorBox:
        observe:
          watch:
            - apiVersion: apps/v1
              kind: Deployment
              namespace: default
              on: [update]
              keyFrom:
                label: app.kubernetes.io/cr-owner

Fields

FieldTypeRequiredDescription
apiVersionstringyesAPI version of the watched resource.
kindstringyesKind of the watched resource.
namespacestringnoNamespace of the watched resource.
namestringnoName of the watched resource.
on[]stringnoObservation events: create, update, delete. Defaults to all three.
keyFromWatchKeyFromnoDefines how the primary CR key is resolved.
index[]WatchIndexnoCache indexes for fields used by lookups.

keyFrom

FieldTypeDescription
labelstringLabel whose value identifies the primary CR.
namestringName of the primary CR to enqueue.
namespacestringNamespace of the primary CR. Used with name.

Validation

  • apiVersion is required.
  • kind is required.
  • on values must be create, update, or delete.
  • keyFrom must specify exactly one of label or name.
  • keyFrom.namespace cannot be used with keyFrom.label.
  • Duplicate watch identities are rejected.

Include

Watch declarations can be loaded through operatorBox.observe.include.

operatorBox:
  observe:
    include: observe.yaml

The included file may contain watch: and events: declarations.

Index

index declares fields to index in the watcher’s informer cache.

index:
  - name: metadata.labels.app
    field: metadata.labels.app

Defaults

If on is omitted, the watch reacts to:

on: [create, update, delete]