Setup

3 min read

spec.setup applies prerequisite resources to the cluster after the CRD is installed but before the Katalog operator starts and the CR is applied. Use it to create Secrets, ConfigMaps, Namespaces, or any other resources the operator needs.

setup is optional. Omit it when the test has no prerequisites.


Shorthand

A plain list of strings is equivalent to setup.apply:

setup:
  - ./prereqs/secret.yaml
  - ./prereqs/namespace.yaml

Full form

setup:
  apply:
    - ./prereqs/namespace.yaml
    - ./prereqs/pull-secret.yaml
  helm:
    - repo: https://charts.cert-manager.io
      chart: cert-manager
      version: v1.14.0
      namespace: cert-manager
      createNamespace: true
  wait:
    - kind: Deployment
      name: cert-manager
      namespace: cert-manager
      ready: true
      timeout: 120s

Execution order: apply → helm → wait. Each phase must complete before the next starts.


setup.apply

An ordered list of YAML file paths to kubectl apply. Files are applied in declaration order. Each file may contain multiple YAML documents separated by ---.

setup:
  apply:
    - ./prereqs/namespace.yaml
    - ./prereqs/pull-secret.yaml
    - ./prereqs/seed-data.yaml

Runs after the CRD is installed, before the operator starts watching.


setup.helm

An ordered list of Helm charts to install as real releases into the cluster. Runs after apply. Each entry uses helm upgrade --install — idempotent and safe to re-run.

setup:
  helm:
    - repo: https://charts.cert-manager.io
      chart: cert-manager
      version: v1.14.0
      namespace: cert-manager
      createNamespace: true
FieldRequiredDescription
repoyesHelm chart repository URL
chartyesChart name within the repository
releasenoHelm release name. Defaults to the chart name.
namespacenoTarget namespace. Defaults to default.
versionnoChart version. Omit for latest.
valueFilesnoOrdered list of values files (local paths).
valuesnoInline key-value overrides (helm --set).
createNamespacenoPass --create-namespace to helm.

setup.wait

An ordered list of resources to wait for after apply and helm complete. The test blocks until every listed resource exists and satisfies the ready constraint. If any wait times out, setup fails and the CR is never applied.

setup:
  wait:
    - kind: Secret
      name: image-pull-secret
      namespace: default
      timeout: 10s
    - kind: Deployment
      name: cert-manager
      namespace: cert-manager
      ready: true
      timeout: 120s
FieldRequiredDescription
kindyesKubernetes resource kind
nameyesExact resource name
namespacenoNamespace. Omit for cluster-scoped resources.
readynoWhen true, waits for a ready/available condition, not just existence.
timeoutnoPer-resource timeout. Default: 30s.

Real example — 03-secret-copy

setup:
  apply:
    - ./setup.yaml   # creates platform/team-alpha/team-beta namespaces + source Secret
  wait:
    - kind: Secret
      name: database-credentials
      namespace: platform
      timeout: 15s   # source Secret must exist before the operator starts

The operator copies the Secret from platform into team namespaces. Without the wait, a race could let the operator start before the source Secret is present.

→ This pattern is from the beginner pack: ork init --pack beginner