Skip to content

Submitting a Folder of Manifests (CLI)

You have a folder of Kubernetes manifests and want it to become a stack’s desired state — from your shell or a CI job, without writing any code. The brokkr CLI does this with one idempotent command.

  • The brokkr binary on your PATH (download the Linux or macOS tarball for your architecture from the GitHub Release, or build it from source with cargo build --release -p brokkr-cli).
  • A reachable broker and a PAK. A generator PAK applies for its own generator: that generator owns the stack. An admin PAK can apply too, but it must name the generator that owns the stack with --generator (see Apply as an admin). To mint a generator PAK, see Create the generator or Working with Generators.

Create ~/.brokkr/config so you don’t repeat the broker URL and PAK on every call:

broker_url = "https://broker.example.com"
pak = "brokkr_BRabcd1234_GeneratorTokenExample0001"

The /api/v1 suffix is added for you. Any value here can be overridden per-invocation with --broker-url / --pak, or supplied instead via BROKKR_BROKER_URL / BROKKR_PAK (handy in CI, where the PAK comes from a secret). Precedence is flag → environment → config file.

Terminal window
brokkr apply -f ./manifests --stack payments

This reads the top-level *.yaml/*.yml files in ./manifests (sorted), concatenates them into one multi-document stream, validates that each document has apiVersion and kind, and submits the bundle as the stack’s latest deployment object — creating the stack payments if it doesn’t exist. You’ll see one of:

created stack "payments": first revision (sequence 1)
updated stack "payments": new revision (sequence 2)
unchanged: stack "payments" already current

An admin PAK has no generator of its own, so it cannot own a stack. Name the owner generator with --generator, by name or by id:

Terminal window
brokkr apply -f ./manifests --stack payments --generator acme-payments

The stack is created under that generator, and the PAK of that generator can manage it from then on. Without --generator, an admin PAK gets:

error: invalid request: apply with an admin PAK needs the generator that owns the stack: give its name or id as `generator` (`--generator` in the brokkr CLI)

With a generator PAK, --generator is optional. If you give it, it must name the generator of that PAK: a generator cannot apply for another generator.

Add one or more labels so only matching agents reconcile the stack:

Terminal window
brokkr apply -f ./manifests --stack payments \
--target-label env:prod \
--target-label region:us

Labels are additive and applied every run; a label that already exists is left as-is.

--target-label is label-based fan-out: any agent whose labels match reconciles the stack — but only if that agent is registered with the generator that owns it. Registration is the consent boundary and it gates both targeting paths:

  • Label and annotation matching is filtered at read time. An agent that never registered with your generator is served nothing, however its labels are set, and no error is raised anywhere — the stack simply doesn’t arrive.
  • Explicit per-agent targets (POST /agents/{id}/targets, created by an admin or by the generator that owns the stack) are rejected outright with HTTP 403 / agent_not_registered when the agent isn’t registered.

brokkr stack label ends with the agents that match the stack’s labels now, or says that none does. A generator sees the labels of the agents registered with it (brokkr agent list). So register the agents you intend to reach before you rely on labels: brokkr register --agent <id> --generator <generator-id> with an admin PAK, or set BROKKR__AGENT__GENERATOR_IDS on the agent at startup so it self-registers. See Registering agents with generators and the error code reference.

apply is idempotent — it compares a checksum of the bundle against the stack’s current latest deployment object and submits a new revision only when the folder changed. That makes it safe to run on every push. A complete workflow around this one command is in CI/CD with Generators, Step 7:

Terminal window
BROKKR_BROKER_URL="$BROKER_URL" BROKKR_PAK="$BROKKR_GENERATOR_PAK" \
brokkr apply -f ./k8s --stack "$SERVICE_NAME" --target-label env:prod

A successful run exits 0 (including the unchanged case); any failure prints error: … to stderr and exits 1, so a failed apply fails the job.

Terminal window
brokkr stack status payments

The latest revision, the agents that have the stack and each one’s health report. Before an agent has reported, one line says so: target an agent or match a label, then wait one poll. For what the cluster said, brokkr stack events payments and brokkr stack logs payments print the broker’s retained window. A generator PAK may read all three for its own stacks.

A stack’s desired state is the single latest bundle, and the agent prunes anything no longer present. To delete a resource, remove its file from the folder and re-apply — the next reconcile deletes it from the cluster. Object ordering within the folder doesn’t matter: the agent front-loads Namespace and CustomResourceDefinition objects.