Releases from a spec (piceli release)¶
Maturity: preview
piceli release is tested end to end against kind; options and JSON fields may still change in a minor release, with a changelog entry. See the Roadmap for every feature’s status.
piceli release deploys a composition to one namespace as a sequence of
immutable, catalogued releases. It is a thin command layer over
ReleaseWorkflow: every write goes through the durable deployment session,
the plan executor and its journal, so each release can be previewed, applied,
resumed, stopped and rolled back.
piceli release plan --spec release.toml [--rotate NAME] [OWNERSHIP…] [--out plan.json]
piceli release preview --spec release.toml # alias of plan
piceli release diff --spec release.toml [OWNERSHIP…] [--exit-code] # read-only
piceli release apply --spec release.toml --approve <plan-hash> | --auto-approve [OWNERSHIP…] [--skip-checks]
piceli release rollback <release|previous> --spec release.toml [--approve <hash> | --auto-approve [OWNERSHIP…]] [--skip-checks]
piceli release resume --spec release.toml [--release NAME] [--skip-checks]
piceli release stop --spec release.toml [--release NAME]
piceli release check --spec release.toml [--release NAME]
piceli release status --spec release.toml [--run EXECUTION_ID]
piceli release orphans --spec release.toml [--prune [--approve <hash>]] [--include-claims] [--include-secrets] [--include-other-owners] [--include-cluster-scoped] [--json]
piceli release secret show NAME --spec release.toml [--key KEY] [--release NAME] [--reveal] [--json]
--spec takes a release.toml path, or MODULE:ATTR
(path/to/file.py:ATTR or package.module:ATTR) naming a
piceli.pipeline.Pipeline, the same target syntax as piceli deploy,
piceli status and piceli access. A value ending in .toml, or without a
:, is a spec path. See Releases deployed by a pipeline.
OWNERSHIP… are the planning flags that authorize taking over existing
objects: --adopt Kind/name, --adopt-all-desired and --replace Kind/name
(see If plan refuses).
Maturity: piceli release is preview. Ownership transitions
(--adopt, --adopt-all-desired, --replace) are preview: flags and JSON
fields may still change before 1.0.
JSON goes to stdout and a short summary to stderr. Exit codes: 0 success,
1 the execution did not become ready or its [[checks]] failed (reason
check-failed), 2 rejected (invalid spec, identity mismatch, unknown or
expired plan), 3 approval required. See
Output and exit codes for the objects each case
prints.
The spec¶
# Top-level keys come before the first [table].
# images_from = "build.receipt.json" # optional: images from a piceli.build-receipt.v1 receipt
[target]
kubeconfig = "release.kubeconfig" # explicit file; KUBECONFIG and ~/.kube/config are never read
context = "kind-release-demo" # explicit context; current-context is never used
namespace = "release-demo" # must exist
cluster_uid = "…" # optional: expected kube-system Namespace UID
namespace_uid = "…" # optional: expected namespace UID
# transport = "loopback-http" # only for a literal loopback test API
# allow_exec = true # GKE/EKS/AKS exec plugins, see "Target and credentials"
# exec_sha256 = "sha256:…" # optional pin of the resolved plugin file
[target.nodes.primary] # optional node pins, exposed as ctx.nodes
name = "node-a"
uid = "…"
[release]
name = "web" # releases are named web-<fingerprint>
owner = "release-demo" # piceli.io/owner of managed objects
field_manager = "release-demo"
composition = "composition.py:build" # or "package.module:function"
state_dir = ".piceli-release" # catalog, journal, secret store, plans (0700)
# state = "cluster" # share the state in the namespace, see docs/state.md
# state_lease_seconds = 60 # how long a dead runner keeps the release lock
approval_window_seconds = 900 # plan validity and evidence age limit
prune = false # delete managed objects a release drops
# inherited_owners = ["old-owner"] # earlier owner ids whose objects count as ours
# adopt = ["Deployment/web", "PersistentVolumeClaim/data"] # see "Adopting existing objects"
# replace = ["Deployment/legacy"] # one-off delete-and-recreate, see "Replacing an object"
# rollback_on_failed_checks = true # re-apply the previous ready release when [[checks]] fail
# auto_approve = { allow = ["create", "apply", "no-op"], max_objects = 10 } # see "Approval policy"
[execution]
max_seconds = 300
readiness_seconds = 240
# write_settle_seconds = 60 # resume re-sends a write that never landed after this long
# fail_fast = true # stop at once when new pods cannot start (apply-crashloop)
# crash_restarts = 3 # restarts of a new container that count as not starting
[images] # pinned by digest
web = "docker.io/library/nginx@sha256:…"
# api = { receipt = "api.delivery.json" } # a piceli.registry-delivery.v1 receipt
[secrets.api-token]
type = "random"
bytes = 32
[secrets.web-tls]
type = "tls-self-signed"
dns_names = ["web.release-demo.svc", "web"]
days = 365
openssl = "/usr/bin/openssl" # absolute path; add openssl_sha256 to pin the binary
# more types: tls-ca, template, import, static (see "Secret generators")
[values] # free-form, passed to the composition
greeting = "hello"
[[checks]] # optional post-deploy checks, run after readiness
type = "http" # http | exec | metric | python (see docs/checks.md)
target = "service/web"
path = "/"
expect = 200
Unknown keys are rejected everywhere except [values]. Relative paths
resolve from the spec’s directory. A complete example lives in
examples/release/.
How big the state grows (0.47.0)¶
The journal (journal.sqlite) has a 64 MB budget. Once it is past half,
opening it forgets finished executions nothing needs any more: an execution
goes, with its actions, events and diagnosis, unless it is still pending,
the latest execution of a release, named in the last 50 history entries,
among the newest 20, or named by a migration lineage. The release’s
deployment session stays, so every catalogued release can still be
reopened. The budget counts the pages in use, and the file is rewritten
(VACUUM) when more than a quarter of it is free.
Keeping only recent releases (0.49.0)¶
Every release adds a catalog record, a session, a sidecar, executions and secret versions (the secret store also keeps a copy of each object an apply writes). Without a limit the secret store reaches its 64 MB budget and no new release can be planned. Release retention keeps the state small. It is off unless the spec sets it:
[release]
keep_releases = 20 # at least 2; leave it out to keep every release
A pipeline sets Pipeline(..., keep_releases=20); each environment keeps its
own releases. It is not part of any plan hash.
What is kept: the newest
keep_releasesreleases (by creation time), the selected (running) one, thepreviousrelease and the release an automatic rollback would return to. A rollback by name to a retired release fails withunknown-releaseand says it was retired.When: at the end of every
applyorresumethat ends with a ready release (after any automatic rollback). It waits while a plan is pending or an execution is running. A failure is logged and never fails the apply.What goes: the retired records, their sessions and input bindings, their sidecar and discovery files, executions nothing needs any more and their check reports.
Secret versions nothing names any more go only on a later run, after a grace period of the longer of
approval_window_secondsand one hour, so a plan in progress never loses a value it wrote but has not named yet. This also removes the old object copies earlier releases left behind. The store’s budget counts the pages in use, and the file is rewritten (VACUUM) when more than a quarter of it is free.Never deleted: replace backups (
backups/<execution>/, recovery data) andhistory.json(the audit trail). Each report gives the backups’ total size, so their growth stays visible.Prune and orphan scans only look at the kinds catalogued releases declare, so a kind only a retired release used is no longer scanned.
Look before you turn it on, and run it by hand (never contacts the cluster):
piceli release retention --spec release.toml --dry-run # change nothing
piceli release retention --spec release.toml --dry-run --keep 10
piceli release retention --spec release.toml # run it now
The dry run lists the releases, sessions and files it would retire, the executions it would remove, the secret versions nothing names (count and bytes, and how many are past the grace period) and the backups it keeps. JSON goes to stdout, a one-line summary to stderr.
Target and credentials¶
[target] names exactly one namespace of one cluster: an explicit kubeconfig
file (KUBECONFIG, ~/.kube/config and in-cluster files are never read), an
explicit context (never current-context) and a namespace that must exist.
cluster_uid and namespace_uid pin the kube-system and namespace UIDs, and
[target.nodes.<alias>] pins nodes.
Credentials may be a client certificate or a bearer token. Managed clusters
(GKE, EKS, AKS, OIDC) use an exec credential plugin instead; Piceli runs
it only with allow_exec = true, pins the resolved file (exec_sha256),
passes it a minimal environment (PATH, HOME, exec_pass_env and the
kubeconfig’s env) and refreshes expiring credentials itself. See
Connect to managed clusters (GKE, EKS, AKS) for the security model, the exec_* keys and the
exec-* error codes. Legacy auth-provider users, proxies,
insecure-skip-tls-verify and basic auth are always refused.
Key |
Default |
Meaning |
|---|---|---|
|
required |
The explicit target. |
|
none |
Expected identities. |
|
|
|
|
|
Limit for one API request, in (0, 60]. |
|
|
Run the context’s exec plugin (preview). |
|
none, |
Plugin pin, extra variables, run limit. |
Images¶
images_from is a top-level key: write it before the first [table],
never inside [images].
Status: preview
The immutability rule and the receipt formats below are stable. The merge
rules for images_from lists and the refusal codes are new in this release
and may still gain cases.
Rule: a release only references an image by a name that no other build can
move. Every ctx.image(name) is one of:
repository@sha256:<manifest digest>: declared by hand, from a build receipt that recorded a manifest digest, or thepull_refof a registry-delivery receipt; orrepository:sha256-<hex>: a content tag, accepted only from a node-delivery receipt that proves the node holds that exact config digest under that name.<hex>is a prefix (12 to 64 characters) of the config digest, so the name can only ever point at this image.
A plain tag (app:dev, app:1.4.2, latest) is never used. When nothing
immutable is known, ctx.image(name) refuses with image-not-immutable; the
image’s identity is still available.
Image sources:
Declared as |
Reference |
Release identity |
|---|---|---|
|
|
the digest |
a bare |
none ( |
the digest |
|
|
the digest |
|
refused ( |
|
|
its |
the manifest digest |
|
its node |
the config digest |
The release records its images as its source identity: with one image,
{"kind": "oci", "identity": <digest>}; with several, the whole set,
{"kind": "oci-set", "images": {<name>: <digest>, …}, "identity": <digest of that map>} (in release status and the catalog). The Python API builds the
same with ReleaseSource.image_set({...}) for ReleaseWorkflow.create.
A build receipt (revision = "piceli.build-receipt.v1", from
piceli artifacts build-spec run) lists outputs.images.<name> with
image_id (the config digest with Docker’s classic store), digest (the
manifest digest, or null with the classic store), platform and ref.
With the classic store, which keeps no manifest, the build alone cannot name
an immutable reference: deliver the image first.
Delivery receipts are accepted only when the delivery succeeded: result
pushed or already-present for a registry delivery, imported or
already-present for a node import. In [images.<name>], digest pins the
expected manifest digest of a registry receipt, or the expected config
digest of a node receipt.
images_from with several receipts¶
images_from takes one receipt or a list. A list merges build and delivery
receipts, in any order:
Build receipts name the images. A name in two build receipts is refused (
image-declared-twice).Each delivery receipt replaces every built image with the same config digest (for a containerd-store build, a registry delivery may instead match the build’s manifest digest). A delivery that matches no built image is refused (
receipt-unmatched); a delivery receipt carries no image name, so use[images.<name>] receipt = …to release it without a build receipt.An image delivered by two listed receipts is refused (
image-declared-twice).
A name in both [images] and images_from is refused, with one exception:
[images.<name>] receipt = "…" may replace a built image of that name. Its
config digest must be the built image’s, otherwise the spec is refused
(image-digest-mismatch).
images_from = ["build.receipt.json", "api.delivery.json", "worker.node.json"]
# or name a delivery explicitly (it must match the built "api"):
# images_from = "build.receipt.json"
# [images.api]
# receipt = "api.delivery.json"
Refusal codes¶
A refused spec exits with 2 and prints
{"state": "rejected", "reason": "<code>", "message": "…"} (see
Output and exit codes). The image codes are fixed
words (piceli.k8s.release_spec.ImageHandoffError.code):
Code |
Meaning |
Fix |
|---|---|---|
|
The only name for the image is a tag that can move: a build receipt without a manifest digest, a node reference that is not a content tag, or a |
Deliver to a registry, or node-import with |
|
Unreadable JSON, an unknown schema or revision, or invalid digests |
Pass the receipt the command wrote |
|
The receipt records a rejected or failed delivery |
Deliver again |
|
The delivery is of another image than the build of that name, or than the pinned |
Deliver the image that was built, or update the pin |
|
One name from two sources (see the merge rules) |
Keep one |
|
A listed delivery receipt matches no built image |
Add its build receipt, or name it with |
Build → deliver → release¶
piceli artifacts build-spec run --spec build.toml --approve-builder sha256:… --out build.receipt.json
piceli artifacts deliver --image <image_id> --approve-digest <image_id> \
--to oci://127.0.0.1:15000/app/api --node-registry 127.0.0.1:5000 \
--via-forward deployment/registry --namespace my-app --kubeconfig kc --context ctx \
--receipt api.delivery.json
# release.toml: images_from = ["build.receipt.json", "api.delivery.json"]
piceli release plan --spec release.toml
For node import, name the image by its content tag, which
piceli.k8s.release_spec.content_tag(config_digest) also computes:
ID=$(docker image inspect --format '{{.Id}}' app/api:dev) # classic store: the config digest
piceli artifacts deliver --image app/api:dev --approve-digest "$ID" \
--ref "app/api:sha256-${ID:7:12}" \
--to 'ssh://ops@node-1.example?runtime=k3s-containerd' --receipt api.node.json
A content-tag image is not pulled, so leave imagePullPolicy at its default
(IfNotPresent) or set Never, and pin the workload to the node that holds it.
Two images, one change¶
examples/two-images/ releases two small images from a node-local registry
(Node-local registry). registry.toml installs the registry as its own
release; release.toml releases one Deployment per image from the two
registry-delivery receipts:
def build(ctx: ReleaseContext) -> DeploymentComposition:
node = ctx.nodes["primary"].name
return DeploymentComposition(
tuple(
DeploymentComponent(name, (_deployment(ctx, name, node),))
for name in sorted(ctx.images)
)
)
Rebuilding and re-delivering one image changes one receipt, so the next plan
differs in exactly one desired manifest, and only that Deployment rolls out.
The opt-in test tests/integration/test_two_images_kind.py runs the whole
flow on kind (see its docstring). Verified on kind v0.29.0 (Kubernetes
v1.33.1): after alpha was rebuilt and re-delivered (2 blobs uploaded, the
shared base layer skipped), alpha went to generation 2 with the new digest
and beta stayed at generation 1.
The plan of the rebuilt release lists Deployment/beta as no-op and
Deployment/alpha as apply with a single field change, its image (see
What a plan shows).
The composition function¶
from piceli.k8s.ops import (
DeploymentComponent,
DeploymentComposition,
ResourceIntent,
)
from piceli.k8s.release_spec import ReleaseContext
def build(ctx: ReleaseContext) -> DeploymentComposition:
secret = ResourceIntent.from_manifest(
{
"apiVersion": "v1",
"kind": "Secret",
"metadata": {"name": "web-token", "namespace": ctx.namespace},
"data": {"token": "<private>"},
}
).with_secret("/data/token", ctx.secret("api-token"))
...
return DeploymentComposition((DeploymentComponent("web", (secret, ...)),))
ctx carries namespace, images (use ctx.image(name) for the pull
reference), values, verified nodes and opaque secrets references.
Secret values never reach the function. Every declared secret input must be
bound, except outputs that a template generator uses. Resources must be
namespaced and in the target namespace, except ClusterRole and
ClusterRoleBinding (rbac.authorization.k8s.io/v1). Those are stamped with
piceli.io/namespace: <target namespace>, and the release manages only the
ones that carry both its owner and its namespace, so releases of one owner in
two namespaces never touch each other’s (see “Cluster-scoped objects in a
release” in Describe an app in typed Python). Other cluster-scoped kinds are refused with
invalid-composition.
Secret generators¶
The how-to Manage secrets: generate, template, import, fetch, rotate covers every generator with examples, secret show, rotation and the error codes. In short:
|
Settings |
Outputs |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
exactly one of |
|
|
|
|
All take encoding = "base64" (default, fits Secret.data) or "raw"
(fits stringData; UTF-8 text only). Certificates come from the pinned
openssl called with an explicit argv, never a shell.
Values are produced only after the plan and its grant validate, so a refused
plan generates, imports and stores nothing. They are stored once per release
in the private SecretVersionStore. A new release carries over the
previous release’s values unless the generator’s settings changed or you pass
--rotate NAME (rotation always creates a new release; templates are
re-rendered from their inputs). An imported value is the first version, is
carried over like the others and is rotatable with --rotate.
Secrets are retained objects: Piceli never rewrites or deletes an existing
Secret, so a rotated value must go into a new Secret. Put a generation in
the Secret’s name, bump it together with --rotate, and reference the new
name from the workloads:
generation = ctx.values["token_generation"] # [values] token_generation = 2
token = ResourceIntent.from_manifest(
{
"apiVersion": "v1",
"kind": "Secret",
"metadata": {"name": f"web-token-{generation}", "namespace": ctx.namespace},
"data": {"token": "<private>"},
}
).with_secret("/data/token", ctx.secret("api-token"))
Rotating under the same name fails at apply with
retained-content-precondition-failed and writes nothing to that Secret. The
old Secret stays until you delete it.
A new, empty state directory does not rotate anything: the plan adopts the
generated values from the Secrets an earlier release of the same owner wrote
(origin adopted, listed under secret_adoptions and bound to the plan
hash). See “When the state starts empty” in Manage secrets: generate, template, import, fetch, rotate.
Plan and approval¶
plan identifies the cluster (kube-system and namespace UIDs, optional node
UIDs), captures bounded live discovery and computes a release name from a
fingerprint of the images, the composition output and the generator settings.
A new fingerprint creates a release (
mode: create): secret inputs are materialized, and the discovery snapshot, plan and grant are frozen in an immutable session in the catalog.An existing fingerprint re-plans that release against fresh discovery (
mode: reapply).
The plan and its evidence are stored privately under the plan hash. apply --approve <hash> executes exactly that plan; the approval is one-shot and
expires after approval_window_seconds. Without --approve, apply plans,
prints the hash and asks you to type its first 12 characters on a terminal;
without a terminal it exits with code 3. --auto-approve is for CI.
$ piceli release plan --spec release.toml
release web-716dfe62698b (create, apply): 4 create
create ConfigMap/web-config
create Secret/web-tls
create Secret/web-token
create Deployment/web
secret api-token: generated
secret web-tls: generated
plan hash: 4123ff6e…29b8e4 (valid until 2026-09-24T17:24:59+00:00)
$ piceli release apply --spec release.toml --approve 4123ff6e…29b8e4
apply web-716dfe62698b: ready
Approval policy¶
[release] auto_approve is the owner’s policy for plans that may apply
without a human approving the hash:
[release]
# ...
auto_approve = { allow = ["create", "apply", "no-op"], deny = ["cluster_scoped"], max_objects = 10 }
piceli release apply --spec release.toml --approve-if-policy plans and
applies only when every action of the plan is inside the policy (the output
adds "approved_by": "policy"). Otherwise nothing is applied: the plan is
stored, its hash and the usual --approve command are printed, and the exit
code is 3 with "reason": "approval-policy-exceeded" and a policy object
whose violations name each action outside it. delete, replace and
adopt are never inside a policy (approval-policy-invalid if allow names
one); cluster_scoped objects and drift need an explicit allow; deny
removes classes from allow; max_objects caps the changed objects.
The policy is part of the plan hash, so changing it changes every plan’s
hash. No flag sets or widens it: --approve-if-policy without a declared
policy is refused (approval-policy-missing) before anything is planned, and
combining it with --approve, --auto-approve, --rotate, --adopt,
--replace or --adopt-all-desired is refused
(approve-if-policy-flags-conflict). A pipeline’s policy
(Pipeline(auto_approve=...), see Let a policy approve routine plans) applies to
piceli release apply --spec MODULE:ATTR --approve-if-policy the same way.
What a plan shows¶
Each object gets one operation: create, adopt, replace, apply,
no-op or delete. An object that exists and that the release already
manages is no-op when applying it would change nothing, and apply
otherwise. Actions on cluster-scoped objects (ClusterRole,
ClusterRoleBinding) carry "cluster_scoped": true in the JSON and
[cluster-scoped] in the text. How plans decide what changes explains how that is decided (a server-side
dry run of the write, so server defaults never make an unchanged object look
changed).
Every apply, adopt and replace comes with a field-level diff. The
human summary prints up to 12 changed fields per object; the JSON output has
all of them under diffs:
$ piceli release plan --spec release.toml
release web-3c1d0a9e22f4 (create, apply): 1 apply, 3 no-op
apply Deployment/web
~ /spec/template/spec/containers/0/image: "docker.io/library/nginx@sha256:6564…" -> "docker.io/library/nginx@sha256:1ead…"
plan hash: 9b0f…c4d1 (valid until 2026-09-24T18:02:11+00:00)
"diffs": [
{
"resource": {"api_version": "apps/v1", "kind": "Deployment", "namespace": "shop", "name": "web"},
"operation": "apply",
"basis": "server-dry-run",
"changes": [
{"path": "/spec/template/spec/containers/0/image", "op": "replace",
"before": "docker.io/library/nginx@sha256:6564…", "after": "docker.io/library/nginx@sha256:1ead…"}
],
"not_compared": [],
"unified": "--- live/Deployment/web\n+++ release/Deployment/web\n@@ …"
}
],
"dry_run_unavailable": []
pathis a JSON pointer into the object,opisadd,removeorreplace, andbefore/afterarenullwhen absent. Secret values are shown as"<redacted>"; values bound to secret versions are listed innot_comparedand never shown. They are compared privately (in-process, see How plans decide what changes), so an unchanged Secret isno-op.A
removechange on a map key (a label, a ConfigMap key) is a three-way removal: an earlier release declared the key and this one no longer does. The action lists them underremoves; see How plans decide what changes.basisisserver-dry-runwhen the “after” side is the API server’s answer to a dry run of the write, orclientwhen no dry run was available and the desired manifest was merged onto the live object locally (server defaults are then missing from “after”).dry_run_unavailablelists managed objects without a dry run and why (rbac-denied,conflict,dry-run-limit-exceeded, …). Such an object is compared literally and may show asapplyalthough unchanged.The diff is evidence, not part of the plan: it is not in the plan hash.
piceli release diff --spec release.toml prints only the diffs: unified
diffs on stderr and {"state": "diffed", "summary", "changes", "actions", "diffs", "dry_run_unavailable"} on stdout. It stores no plan and no local
state and sends the cluster only reads and dryRun=All requests, so it is
safe to run at any time. With --exit-code it exits 1 when the release
would change something, and the object also carries
"reason": "release-changes-pending".
Adopting existing objects¶
Objects that already exist in the namespace without this release’s
piceli.io/owner (for example created by kubectl) are refused at plan
time, with the list of objects to adopt. Authorize each one with
--adopt Kind/name (or apiVersion/Kind/name; repeatable; RBAC names may
hold :, as in --adopt ClusterRole/shop:shop:watcher) on plan,
apply or rollback, or list them in [release] adopt. An entry must name
a resource the composition declares; entries for objects that are absent, or
already managed with nothing to reclaim, are reported as adopt_not_needed
and ignored, so a standing list keeps working after the first release. An
entry for a managed object that other clients have written to since (for
example with kubectl edit) takes it over again, which reclaims those fields. Adoption flags are planning
flags: apply --approve HASH runs exactly the approved plan and refuses them.
The plan shows how each object is adopted, and the mode, previous owner and transferred field managers are part of the plan hash you approve:
$ piceli release plan --spec release.toml \
--adopt Deployment/web --adopt PersistentVolumeClaim/web-data --adopt Secret/web-token
release web-06c982ec7fe9 (create, apply): 3 adopt
adopt Secret/web-token [metadata-only: owner annotation only; previous owner: none]
adopt PersistentVolumeClaim/web-data [metadata-only: owner annotation only; previous owner: none]
adopt Deployment/web [takeover: transfers field managers: kubectl-client-side-apply, kubectl-rollout, kubectl-set; fields they own that the release does not declare will be REMOVED; previous owner: none]
plan hash: b9b282dd…c67a07 (valid until 2026-09-24T19:26:34+00:00)
$ piceli release apply --spec release.toml --approve b9b282dd…c67a07
adopted Secret/web-token (metadata-only)
adopted PersistentVolumeClaim/web-data (metadata-only)
adopted Deployment/web (takeover; transferred field managers: kubectl-client-side-apply, kubectl-rollout, kubectl-set)
apply web-06c982ec7fe9: ready
Retained objects (PVC, Secret, or
piceli.io/retained: "true") are adopted metadata-only: one merge patch writes Piceli’s owner annotation and the labels and annotations the composition declares that differ from the live object (listed asmetadata_changes), never spec or data, and only when the live object already contains everything else the composition declares for it. Keys are set, never removed. Declare a PVC with the same spec as the live claim; declare an existing Secret withoutdatato adopt it and keep its value. A different declared spec or value is refused before any write. A retained object of aninherited_ownersid can be adopted the same way; its owner annotation is re-stamped.Everything else is adopted by a takeover, which makes the composition the object’s full desired state. Every field written by a client (
kubectl-client-side-apply,kubectl-create,kubectl-set,kubectl-edit,kubectl-rollout, other tools) is transferred to Piceli’s field manager, then the manifest is applied without force. Fields those clients wrote that the composition does not declare are removed: a container with another name, arestartedAtannotation, extra labels and thekubectl.kubernetes.io/last-applied-configurationannotation (so a later client-sidekubectl applycannot bring old fields back). Fields defaulted by the API server come back with their defaults. Kept as they are: subresource entries (status, andscalewritten by an autoscaler) and control-plane managers (kube-controller-manager,kube-scheduler,kube-apiserver,kubelet,cloud-controller-manager, names starting withk3sor ending in-controller/-controller-manager). A value that a kept manager owns and the composition sets differently (for examplereplicasunder an autoscaler) fails as a conflict instead of being forced.Afterwards a later
kubectl set imageshows up as drift in the next plan:drift Deployment/web: desired fields also managed by kubectl-setOrdinary creates and updates never force. The only request Piceli sends with
force=trueis a takeover’sdryRun=Alladmission check, which persists nothing.
The apply JSON lists adopted objects with mode, previous_owner,
transferred_managers, completed_transfer and metadata_changes; the
journal records the same. Replaced objects appear there with mode: replace
and their backup file.
Rolling back to an earlier release re-applies its archived composition as
usual; adopted retained objects and their data are never touched by a
rollback. If a takeover is interrupted, the apply ends blocked and resume
converges it. A takeover that was approved with a different transfer list
(for example by an older Piceli) cannot be resumed; plan again with --adopt.
Adopting everything the composition declares¶
--adopt-all-desired authorizes adopting every existing unmanaged object
the composition declares, and nothing else: objects that are not in the
composition are never touched, and objects named by --replace are replaced
instead. The plan still lists each adoption with its mode, and the
authorized field of the plan JSON names every adopted and replaced object,
all bound to the plan hash you approve. Retained objects are still adopted
metadata-only. It is a planning flag only; there is no spec equivalent, so a
later plan never adopts new objects silently.
$ piceli release plan --spec release.toml --adopt-all-desired --replace Deployment/web
release shop-8eebc4a5b6fb (create, apply): 2 adopt, 1 apply, 1 replace
adopt PersistentVolumeClaim/cache [metadata-only: owner annotation and labels/app.kubernetes.io/part-of; previous owner: none]
apply PersistentVolumeClaim/state [retained, metadata-only: sets labels/app.kubernetes.io/part-of; spec and data untouched]
replace Deployment/web [DELETES uid 86d938d2-… and recreates it from the release; backup written first; dependents: deleted]
adopt Service/web [takeover: transfers field managers: kubectl-client-side-apply; fields they own that the release does not declare will be REMOVED; previous owner: none]
plan hash: c354b73f…1e280c (valid until 2026-09-24T20:47:52+00:00)
Metadata changes on retained objects¶
A retained object that this release already manages (its own owner id, or an
id in inherited_owners) is never rewritten. When the only difference from
the composition is in labels or annotations, the plan shows an apply marked
metadata_only and the executor writes exactly those keys, plus Piceli’s
owner and operation annotations, with one merge patch guarded by the observed
UID and resourceVersion. Spec and data are never sent, and the object is
re-stamped with this release’s owner. This covers the common migration case of
a volume claim created by a retired tool: list the tool’s owner id in
inherited_owners and add your labels in the composition. A difference in
spec or data refuses the plan with retained-content-differs.
Replacing an object (delete and recreate)¶
Some objects cannot be adopted into the desired state: a Deployment whose
spec.selector (immutable) must change, or a Service whose type change the
API rejects. --replace Kind/name (repeatable; or [release] replace)
authorizes deleting such an object and creating it from the release. Every
replace needs its own explicit entry; there is no “replace all”.
Replace is allowed only for objects that are unmanaged, not retained
and not owned by another object (ownerReferences), and for managed
Jobs and StatefulSets, whose immutable fields a release cannot update (a
Job’s pod template; a StatefulSet’s serviceName, podManagementPolicy,
selector or claim templates). Such a change refuses the plan with
immutable-field-changed until the object is named with --replace; see
Describe an app in typed Python. A managed Job or StatefulSet named for replace without
such a change is reported as not needed, so a standing [release] replace
entry never reruns a Job. It is refused, before any write, for:
retained kinds and objects (Namespace, PersistentVolume, PVC, Secret,
piceli.io/retained: "true"): adopt them instead;other objects already managed by this release (including inherited owners): the release already updates them;
objects owned by another object, and workloads whose retained dependents a background delete would remove.
What apply does for each replaced object:
re-checks the live object against the planned evidence (UID, resourceVersion, field managers, content) and sends a
dryRundelete;writes a backup: the live object as JSON, cleaned so that
kubectl create -faccepts it (nostatus,uid,resourceVersion,managedFields,creationTimestamp,generation), to<state_dir>/backups/<execution-id>/<n>-<Kind>-<name>.jsonwith mode0600in0700directories. The journal records its path and SHA-256 together with the intent, before the delete;deletes the object with UID and resourceVersion preconditions. Workload controllers (Deployment, ReplicaSet, DaemonSet, Job, CronJob) are deleted with
propagationPolicy=Background, so their old pods go too: expect a short downtime. Everything else, including StatefulSets (so a PVC retention policy can never delete claims), usesOrphan;waits until the object is gone and creates it from the release with Piceli’s owner annotation.
The apply output names the backup:
replaced Deployment/web (deleted uid 86d938d2-…; backup: .piceli-release/backups/9669…/0002-Deployment-web.json; to restore the previous object: kubectl delete Deployment/web, then kubectl create -f .piceli-release/backups/9669…/0002-Deployment-web.json)
Recovery and rollback. A replace is not undone automatically:
compensation and rollback never delete a replaced object or restore its
backup. rollback previous re-applies an earlier release as usual, which
updates the recreated object like any managed object. To go back to the
object as it was before Piceli, restore the backup by hand:
kubectl delete deployment web
kubectl create -f .piceli-release/backups/<execution>/<n>-Deployment-web.json
If the apply stops after the delete (the create failed, the process was
interrupted, the object took too long to disappear), the execution is
blocked, the backup is on disk and the journal records the step reached.
piceli release resume finishes the create for a created release; for a
re-apply, plan and apply again (the object is now absent and is simply
created). If someone else created an object with the same name in between,
the resume stops with replace-recreated-by-another-writer instead of
touching it.
If plan refuses¶
A plan that meets objects it may not change refuses with exit code 2 and
lists every blocking object at once, each with the flags that would
unblock it, in the JSON blocking array and on stderr:
$ piceli release plan --spec release.toml
{"blocking": [{"code": "resource-requires-adoption", "kind": "Deployment", "message": "exists and is not managed by this release's owner", "name": "web", "suggest": ["--adopt Deployment/web", "--replace Deployment/web"]}, …], "code": "resource-requires-adoption", "message": "existing objects are not managed by this release's owner: …", "reason": "resource-requires-adoption", "state": "rejected"}
and on stderr:
rejected: existing objects are not managed by this release's owner: Deployment/web (--adopt Deployment/web or --replace Deployment/web), PersistentVolumeClaim/cache (--adopt PersistentVolumeClaim/cache), Service/web (--adopt Service/web or --replace Service/web); … [resource-requires-adoption]
blocking Deployment/web: exists and is not managed by this release's owner -> --adopt Deployment/web or --replace Deployment/web
blocking PersistentVolumeClaim/cache: exists and is not managed by this release's owner; retained: replace is never allowed -> --adopt PersistentVolumeClaim/cache
blocking Service/web: exists and is not managed by this release's owner -> --adopt Service/web or --replace Service/web
next: Plan again with `--adopt Kind/name` …
Choosing between adopt and replace:
Situation |
Use |
Effect |
|---|---|---|
The live object can become the composition’s object by an update |
|
Takeover: field ownership moves to Piceli and fields the composition does not declare are removed. No downtime, same UID. |
Adopt everything the composition declares, after reviewing the list |
|
The same takeover for each unmanaged declared object; retained ones metadata-only. |
A volume claim, Secret or other retained object |
|
Metadata-only: owner annotation and declared labels/annotations; the spec/data must already match. |
An immutable field must change (selector, Service |
|
Backup, delete, create. New UID; workload pods restart. |
A managed Job or StatefulSet whose immutable fields change ( |
|
Backup, delete, create. A Job runs again; a StatefulSet is deleted with |
The object is not yours to change |
neither |
Rename the object in the composition, or remove it from the composition. |
Refusal codes (reason in the JSON, also per object in blocking[].code):
Code |
Cause |
Fix |
|---|---|---|
|
An object the composition declares exists without this release’s owner. |
|
|
|
Adopt a retained object instead; remove managed objects from the replace list ( |
|
The composition changes an immutable field of a managed Job or StatefulSet. |
|
|
A retained object’s spec or data differ from the composition; only labels and annotations may change. |
Make the composition match the live object (or create a new object under a new name). |
|
The same object is named by an adopt and a replace entry. |
Keep one. |
|
An entry does not name exactly one resource the composition declares. |
Fix the |
|
Several of the above at once. |
See each |
Other refusals:
|
What to do |
|---|---|
|
The |
|
The kubeconfig/context points at another cluster than the one this |
|
|
|
Fix the key named in |
|
Fix the composition function (it must return a |
|
Run |
|
The kubeconfig/context was refused, or the target’s exec credential plugin was not allowed, not pinned, or failed. See “If it fails” in Connect to managed clusters (GKE, EKS, AKS). |
apply --approve HASH refuses a hash that is unknown, expired or already
applied (plan-not-found, plan-expired): run plan again and approve the
new hash. Any code can be looked up with piceli explain <code> or in
Error codes.
Execution failures of these paths (failure_category of apply):
Category |
Cause |
Fix |
|---|---|---|
|
At apply time the object is managed, retained or owned by another object, or no backup directory is available. Nothing was deleted. |
Plan again. |
|
The backup could not be written (permissions, disk). Nothing was deleted. |
Fix the state directory, plan again. |
|
The deleted object was still present after |
Inspect the finalizers, then |
|
Another client created an object with the same name after the delete. Execution |
Decide which object to keep; the backup holds the deleted one. |
|
On resume, the original object is still there although the journal recorded its delete. Execution |
Inspect the object, then plan again. |
|
A metadata-only write was asked to set a non-string value or Piceli’s own annotations. |
Fix the composition’s labels/annotations. |
|
A retained object’s content (for example a private Secret value) differs from the composition at apply time. Nothing was written. |
Use a new object name (see “Secret generators”). |
|
A workload’s new pods cannot start (crash loop, image pull or config error, |
Fix the cause and plan again, or |
|
An object did not become ready in time. For a workload whose pods show a reason, |
See |
piceli release status --spec release.toml --run EXECUTION_ID (an id from
history, a unique prefix of at least 8 characters, or with a pipeline its
piceli deploy run id) prints that execution’s state and, when it failed,
the recorded diagnosis: one line per cause, then the redacted log lines and
events. It reads only the local state (piceli explain --run ID --spec … is
the same). An unknown id is unknown-execution.
Post-deploy checks¶
[[checks]] tables declare checks that run after an execution becomes ready
(apply, rollback and resume). A release is ready only when every check
passes; otherwise the result has release_state = "checks-failed", the command
exits 1 and the release is not selected. With
[release] rollback_on_failed_checks = true the previous ready release is
re-applied automatically and the result carries a rollback object.
--skip-checks skips them (recorded in the history). release check runs the
checks against a release without changing anything. The how-to, every check
type and the state machine are in Check a release and roll back automatically.
Key |
Type |
Default |
Meaning |
|---|---|---|---|
|
|
required |
The check type |
|
string |
derived, e.g. |
Unique name in the spec |
|
seconds |
|
Limit of one attempt |
|
integer |
|
Extra attempts after a failed one |
|
seconds |
|
Wait between attempts |
|
|
required (not |
|
|
|
|
|
|
required, first container, |
|
|
|
required, |
|
|
|
|
required |
|
The checks and the rollback policy are stored with the plan, so apply runs
exactly what was reviewed; the plan JSON shows them under checks.
Rollback¶
rollback <release> re-plans the named release’s archived composition
against current discovery and, once approved, executes it as a new execution
(ReleaseWorkflow.rollback). The release is selected only when the rollback
becomes ready. It reuses the release’s own secret versions; nothing is
regenerated. previous means what was running before the latest change: the
last ready release other than the current one, or, when the latest execution
did not become ready (including checks-failed), the last ready release
itself. A rollback runs the spec’s [[checks]] too; an automatic rollback
after failed checks is described in Check a release and roll back automatically.
One exception to “archived”: the tailnet companions an environment renders
(objects labelled piceli.io/access, see Reach your services from your laptop) come from the
newest release attempted, the one the rollback leaves (0.60.0). They belong
to the environment, not to the app, and an older Piceli may have rendered
them differently: before, rolling back to a release an older version had
rendered could bring back a companion bug the running version had fixed.
Resume, stop and status¶
resumecontinues an interrupted apply of a created release with the same grant and operation IDs, while the grant is valid. Re-apply and rollback executions are not resumable: plan and apply again.stopcancels the latest unfinished execution after checking the owner and target. A stopped execution is not resumed.statusreads the catalog, journal and history without contacting the cluster: releases with their image identities, executions and latest check outcome (checks), the deployed and previous release, pending plans and recent history. Withstate = "cluster"it first refreshes the working copy from the namespace (reads only).
Leftover objects (orphans)¶
A release changes only the objects it declares (and, with [release] prune,
those an earlier release of the same owner declared). Objects that outlive
their release stay in the namespace: the objects of a component you removed,
the names of an earlier environment of the same app. release orphans finds
them; it compares the namespace with the selected release only (the one
status shows as deployed), so the objects of a rollback target are leftovers
too once another release is selected.
piceli release orphans --spec release.toml # list (read-only)
piceli release orphans --spec release.toml --prune # exit 3 + plan_hash
piceli release orphans --spec release.toml --prune --approve <plan_hash>
An object is listed only when Piceli wrote it (a piceli.io/owner
annotation) and the selected release does not declare it, and
its owner is the spec’s
owner(or aninherited_ownersentry): reasonnot-in-current-release, matched onpiceli.io/owner; orit carries every label all of the selected release’s objects share (the app’s ownership labels;
app.kubernetes.io/part-of: <app>for a typedApp) and has another owner: reasonother-owner, another environment of the app.
Each entry has kind, name, namespace, matched (the annotation or
labels that matched), reason, owner, created_at, age_seconds, uid,
resource_version, prunable and, when it is not, blocked_by. The JSON
output only adds fields; a summary (total, prunable, kept) and the
plan_hash come with it.
What is never pruned by default (listed with prunable: false):
Object |
Prunable only with |
|---|---|
PersistentVolumeClaim (its data is deleted), and a StatefulSet whose |
|
Secret |
|
An object of another owner (another environment) |
|
A cluster-scoped ClusterRole or ClusterRoleBinding (scanned only then; it must name this namespace in |
|
An object annotated |
never |
Never listed: an object without Piceli’s piceli.io/owner annotation, an
object with ownerReferences (its owner’s garbage collection decides), an
object already terminating, anything outside the target namespace, and
Namespaces and PersistentVolumes (never scanned).
--prune without --approve deletes nothing: it prints the plan_hash (a
digest over the target, the release, the --include-* flags and the exact
objects with their UIDs and resourceVersions) and exits 3. With
--approve HASH (and the same --include-* flags) the set is read again; if
it differs in any way, nothing is deleted and the refusal is
orphans-plan-changed. Deletes carry UID and resourceVersion preconditions;
an object that changed meanwhile is reported failed
(orphans-delete-failed, exit 1) and the rest are still deleted. Each entry
of deleted has an outcome: deleted once the object is gone, gone if it
was already absent, failed, or deleting when the delete was accepted but
the object is still terminating after [execution] readiness_seconds, with
the finalizers that hold it (a claim stays, kubernetes.io/pvc-protection,
while a pod still mounts it: a pod of a workload pruned just before may take
its grace period to stop). The prune waits for each deleted object until then;
a deleting object is not listed again (terminating objects never are).
release orphans is refused before a release exists
(orphans-no-release) and while an execution is running
(orphans-execution-running).
Releases deployed by a pipeline¶
piceli deploy MODULE:ATTR keeps its release in the pipeline’s
state_dir/release and writes no release.toml. Pass the pipeline itself as
--spec to operate it:
piceli release status --spec deploy/app.py:pipeline
piceli release rollback previous --spec deploy/app.py:pipeline [--approve <hash>]
piceli release secret show cache_password --spec deploy/app.py:pipeline --reveal
piceli release stop --spec deploy/app.py:pipeline
The spec is built from the declaration exactly as piceli deploy builds it:
the same state directory, release name, owner, field manager, target
(kubeconfig, context, namespace, allow_exec and the other exec options),
secret generators and composition, plus the pipeline’s checks= and
rollback_on_failed_checks. Release commands never build or deliver images:
Commands |
Images |
|---|---|
|
The catalogued releases’ own records. A rollback re-applies the archived composition with its recorded image digests ( |
|
The images |
A pipeline with one target per environment (see Environments: one app for dev, staging and prod) needs
--env NAME on every command (environment-required otherwise); each
environment’s release lives in state_dir/environments/NAME. --env with a
release.toml is refused with environment-unsupported.
apply, rollback, resume and stop on a pipeline hold its run lock and
are refused with pipeline-locked while piceli deploy runs on the same
state directory. A module that fails to import is pipeline-load-failed; a
missing module or an attribute that is not a Pipeline is
pipeline-not-found.
Output and exit codes¶
Every piceli release command prints exactly one JSON object on stdout and
human text (summaries, the plan hash to approve, hints) on stderr:
Exit |
stdout |
When |
|---|---|---|
|
|
Success |
|
|
The execution ran but did not become ready. |
|
|
Rejected before any change. Extra fields such as |
|
|
|
reason is always a registered error code: piceli explain <reason> --json
prints its cause, fix and whether a retry can succeed. message is for
people; do not parse it. secret show NAME --reveal without --json prints
the raw value on stdout by design (see Manage secrets: generate, template, import, fetch, rotate).
Contract changes in 0.4.0¶
The output of piceli release changed to follow the CLI contract
(Using Piceli from an agent); scripts that parsed the 0.3.0 output need these updates:
0.3.0 |
0.4.0 |
|---|---|
Refusal |
|
|
|
|
Kept as an alias of |
Refusal stderr started with |
Starts with |
|
Adds |
Result JSON was indented |
The same object; refusals are printed on one line |
blocking[] items keep their fields (kind, name, code, message,
suggest). Exit codes did not change.
Safety model¶
The kubeconfig and context are explicit. Exec plugins run only with
allow_exec = true, pinned and with a minimal environment, and Piceli refreshes their credentials itself (Connect to managed clusters (GKE, EKS, AKS)). Legacy auth providers, proxies,insecure-skip-tls-verifyand basic auth are refused.httpsrequires verified TLS.A state directory serves one cluster and namespace: releases record the kube-system UID, and a later run against another cluster is refused.
Objects are owned by exact
ownermatch. Objects created by other tools are unmanaged; planning them fails until they are adopted or replaced explicitly (--adopt,--adopt-all-desired,--replace). A takeover transfers field ownership and applies without force; retained objects are only ever changed in metadata (owner annotation, declared labels and annotations) and are never deleted or replaced. A replace writes a restorable backup before a delete guarded by UID and resourceVersion.Plans, discovery evidence and secrets stay in the private state directory (owner-only). Reports and the catalog contain opaque references only.
plananddiffsend server-side dry runs (dryRun=All) of the writes an apply would make; the API server persists nothing for them. They need thepatchverb; without it objects are compared literally.
Migrating from a custom deploy script¶
To start from what is already running, piceli import live generates the
typed module for you; see From kubectl scripts to Piceli. By hand:
Move the manifest-building code into a pure
build(ctx)function. Replace hard-coded images withctx.image(...)and inline secret values withResourceIntent.with_secret(pointer, ctx.secret(name)).Declare the target, identities, images (or
images_from) and generators inrelease.toml, and delete the script’s password, certificate and config-file code:tls-careplaces hand-made certificates andtemplatereplaces init-container scripts that write DSNs or config files. To keep a service with existing data working,importthe values it already uses (from a live Secret, a file or an environment variable); see Manage secrets: generate, template, import, fetch, rotate.Ownership: objects that already carry
piceli.io/ownerare managed if you keep that owner or list it inrelease.inherited_owners. Objects created by plainkubectlare unmanaged and planning refuses them, listing each one, until you adopt them (--adopt Kind/nameor--adopt-all-desired) or replace them (--replace Kind/name); see Ifplanrefuses.Replace
kubectl apply, hand-written rollout waits and state files withplan/apply, and ad-hoc rollback withrollback previous. Keep the state directory: it is the release history, and the secret store holds the only copy of generated values.