Publish images for other people’s clusters¶
When someone else runs your app on their own cluster (a client on GKE, EKS
or AKS), your images must run on their nodes, whatever their CPU, and come
from a registry they can pull from. piceli artifacts publish takes a build
and pushes every image as a multi-platform image: one manifest per
platform joined in an OCI image index, under a version tag, pinned by
digest, with its SBOM and provenance attached and, optionally, signed. The
result is the images: values of the Helm chart that piceli chart makes
from the same App (see Publish for other people’s clusters: a Helm chart and manifests).
Maturity: experimental
Multi-platform builds, piceli artifacts publish, attached attestations and
cosign signing are new in 0.10.0 and may change in a minor release, with a
changelog entry. See the Roadmap for every feature’s status.
# 1. Build every platform from one spec (plan, then run the approved plan).
piceli artifacts build-spec preview --spec host-build.toml \
--platform linux/amd64 --platform linux/arm64
piceli artifacts build-spec run --spec host-build.toml \
--platform linux/amd64 --platform linux/arm64 \
--approve-plan sha256:<plan_hash> --out dist/receipt.json
# 2. Publish: without --approve it prints the plan and its digest (exit 3).
piceli artifacts publish --receipt dist/receipt.json \
--to oci://registry.example/shop --tag 1.4.0 \
--docker-config ~/.docker/config.json --sign-key cosign.key
piceli artifacts publish --receipt dist/receipt.json \
--to oci://registry.example/shop --tag 1.4.0 \
--docker-config ~/.docker/config.json --sign-key cosign.key \
--approve sha256:<digest> --out dist/publish.json --values-out dist/images.yaml
# 3. The client installs your chart with those images.
helm install shop oci://registry.example/charts/shop --version 1.4.0 \
--values dist/images.yaml --values client-values.yaml
Build for several platforms from one spec¶
Host builds (no container VM, see Builds without a VM): declare the
platforms in the host-build.toml, or pass --platform once per platform:
[build]
tools = ["cargo", "cargo-zigbuild", "zig"]
platforms = ["linux/amd64", "linux/arm64"]
commands = [
["cargo", "zigbuild", "--release", "--locked",
"--target", "{rust_arch}-unknown-linux-gnu.2.36"],
]
[[output.image]]
name = "api"
repository = "shop/api"
target_files = { "{rust_arch}-unknown-linux-gnu/release/api" = "/usr/local/bin/api" }
The build runs once per platform, one after another, with the facts of the
platform alone: {platform}, {arch} and {rust_arch} are the platform’s,
and the page size is the architecture default (4 KiB, so {page_size_log2}
is 12), because the build cannot know your clients’ kernels. Every
platform shares the cache and its target directory (--cache-dir, default
<XDG cache>/piceli/host-build); cargo zigbuild --target keeps each
platform’s output apart, so the second platform recompiles only what
differs. Each platform gets its own layers, SBOM and provenance under
<output-dir>/<platform-slug>/, and each image one canonical index
(indexes/<image>.index.json, manifests sorted by platform): the same
inputs give the same index digest. One approval (--approve-plan) covers
every platform; the plan hash covers each platform’s plan. With one
platform the plan hash and the receipt are those of a single-platform
build. Steps whose result is the same for every platform (a wasm32
browser bundle) belong in build.shared_commands: they run once, with the
first platform, into a target directory every platform’s images copy from
(see Builds without a VM). A build.platforms list also restricts which node a
Build.spec(..., builder="host") deploys to (node-platform-mismatch).
Docker builds (Containerized builds): list the platforms in the
build.toml (platforms = ["linux/amd64", "linux/arm64"]). Every platform
is built and loaded into the local engine (repository:tag-amd64,
repository:tag-arm64); a platform other than the engine’s runs under
emulation (QEMU), which is slow for compilers: prefer a host build with
cargo zigbuild for Rust, or a buildx_builder on a machine of that
architecture. The index is assembled when the images are published.
What piceli artifacts publish does¶
Each image goes to <registry>/<prefix>/<key>, where key is the last path
segment of the image’s repository in the build spec (shop/api -> api),
the name piceli chart gives its values.
Plan, no network. The images, each platform’s config digest (and manifest digest for a host build), the tag, the attestations and their sha256, and the signing key’s and cosign’s sha256. Without
--approveit prints them and theirdigest(exit3).--approvemust be that digest (publish-not-approved).Each platform’s manifest by digest. The config digest recomputed from the archive (host build) or from
docker image save(Docker build) must equal the receipt’s before anything is sent. Only blobs the registry lacks are uploaded; publishing the same build twice sends nothing.The image index, by digest. When the version tag already names another image, publishing is refused (
publish-tag-exists) unless--move-tag; for a host build this is known before anything is pushed.The SBOM and the provenance of each platform, as OCI 1.1 referrers of that platform’s manifest (an artifact manifest with
subjectandartifactTypeapplication/spdx+jsonorapplication/vnd.in-toto+json). A registry without the referrers API gets the fallback tagsha256-<manifest digest>that the OCI distribution spec defines, which OCI 1.1 clients such asoras discoverread.--no-attestationsskips them.Signatures (
--sign-key, below): the index, every platform manifest and every attestation, before the tag.The tag, last, so a client never pulls a version whose signature or SBOM is not there yet. Then everything is read back: the tag names the index, the index bytes and every child are served, every attestation is listed as a referrer (
publish-verification-failedotherwise).
The receipt (--out, piceli.publish-receipt.v1) gives per image
repository (with the registry), tag, digest (the index), each
platform’s manifest digest and size, the blobs uploaded and skipped (count
and bytes), the attestations (kind, digest, subject, fallback_tag),
the signatures and previous (the digest a moved tag named). Its values
key, and the file --values-out writes, is the Helm values fragment:
images:
api:
repository: registry.example/shop/api
tag: 1.4.0
digest: sha256:… # the index: each node pulls its own platform
piceli chart manifests app.py:app --values dist/images.yaml and
helm install … --values dist/images.yaml render
registry.example/shop/api:1.4.0@sha256:….
Promote a built image by digest: piceli artifacts copy (0.74.0)¶
When a GitOps pipeline already built and tested an image, a release need
not build it again: copy that digest to the release registry. piceli artifacts copy copies the index, every platform’s manifest and blob, and
its referrers (SBOM, provenance and signatures, also a signature of an
SBOM), keeping every digest. skopeo copy --all --preserve-digests keeps
the image but not the referrers.
# The digest the environment runs (a pipeline spec that declares
# build.platforms records an OCI index; see compositions).
piceli gitops status --json | jq -r '.envs.main.components.api.digest'
# Without --approve it prints the plan and its digest (exit 3).
piceli artifacts copy --in-cluster --kubeconfig ~/.kube/config --context my-cluster \
--from oci://127.0.0.1:5000/shop/api@sha256:<index digest> \
--to oci://ghcr.io/example/api:1.4.0 --docker-config ~/.docker/config.json
piceli artifacts copy --in-cluster --kubeconfig ~/.kube/config --context my-cluster \
--from oci://127.0.0.1:5000/shop/api@sha256:<index digest> \
--to oci://ghcr.io/example/api:1.4.0 --docker-config ~/.docker/config.json \
--approve sha256:<plan digest> --out dist/copy.json
--in-cluster (0.83.0) runs the copy as a Job next to the registry, so no
kubectl port-forward can drop in the middle of a release. See
Several images, retries, a ledger and a Job (0.83.0) below. --from oci://127.0.0.1:5000/... is
renamed to the registry’s Service (piceli-registry.piceli-system.svc:5000)
inside the Job.
Fallback: a port-forward. Without --in-cluster the copy runs on your
machine and needs a route to the registry. Reach it with a forward (plain
HTTP is allowed on loopback) and drop --in-cluster, --kubeconfig and
--context. A dropped forward is retried as a whole copy (--attempts,
below), but you must restart the forward yourself:
kubectl -n piceli-system port-forward svc/piceli-registry 5000:5000 &
piceli artifacts copy --from oci://127.0.0.1:5000/shop/api@sha256:<index digest> \
--to oci://ghcr.io/example/api:1.4.0 --docker-config ~/.docker/config.json \
--approve sha256:<plan digest>
Plan (no network): the source repository and digest, the target repository and tag,
--no-referrersand--move-tag. Its digest is what--approvenames.The image: the index (or manifest) by digest, each platform’s manifest, and only the blobs the target lacks.
The referrers of the index, of each platform manifest and of each referrer, read from the referrers API or the
sha256-<digest>fallback tag and written the same way.The tag, last. A tag that names another digest is refused (
copy-tag-exists) before anything is pushed, unless--move-tag.Read back: the tag names the digest, each platform manifest is there and each referrer is listed (
copy-verification-failedotherwise; since 0.96.0 the receipt’smessagenames the check and what it compared).
Before step 2 the source digest is scanned for known vulnerabilities
(0.94.0; --scan-policy FILE, --no-scan): see Scanning images for known vulnerabilities (0.94.0).
--to without a tag copies by digest only. The source is read anonymously
unless --from-credentials or --from-docker-config; the target uses
--credentials or --docker-config (below); --from-ca-file and
--ca-file add a CA. The receipt (piceli.copy-receipt.v1) gives the
digest, its media_type, platforms (each platform’s manifest digest),
the blobs uploaded and skipped, each referrer (subject, digest,
artifact_type, result) and previous (the digest a moved tag named).
A second run copies nothing (result: already-present).
A flaky network (0.78.0). One dropped connection no longer fails the
copy. A transient failure (a refused, reset or aborted connection, a
timeout, a name not resolved, a TLS connection cut short, or HTTP 429, 502,
503 or 504) is tried again up to 5 times per request, after about 1, 2, 4
and 8 seconds (half fixed, half random; a Retry-After up to 60 seconds is
honoured), and never past --timeout. A GET, HEAD or monolithic PUT
is simply repeated. A failed chunk of a large blob is not: Piceli asks the
upload session how much it holds (its Range) and goes on from the next
byte; when the session is gone it starts that blob again (up to 3 times).
The receipt lists each retry in retries (side, host, method, path
without its query, attempt, cause, action: resume or restart, and
the blob’s digest and offset). When the copy still fails, error says
where, and so does the last line:
copy: failed [registry-unreachable] target ghcr.io PATCH blob sha256:9072a3f9… at 33554432: ConnectionResetError(54)
error holds side (source or target), host, method, path,
digest, offset, exception and errno (or the HTTP status); never
a credential, a token or a query string. The same retries cover
artifacts publish, artifacts deliver, mirrors and every other command
that talks to a registry.
Several images, retries, a ledger and a Job (0.83.0)¶
A set.
--set FILEreplaces--fromand--towith a list of copies, in JSON ([{"from": "...", "to": "..."}]) or TOML ([[copy]]tables withfromandto). One plan digest covers the whole set, so one--approveapproves exactly these copies. A set of one has the digest of that copy.Whole-copy retries.
--attempts N(default 5) tries a copy again as a whole when it failed for a transient reason (registry-unreachable, or HTTP 429, 502, 503, 504), after about 2, 4, 8, 16 seconds (at most 60; half fixed, half random). It adds to the per-request retries above: one dropped connection that outlasts those no longer fails a release. The registry already holds what was copied, so a retry sends only what is missing. Any other reason (copy-tag-exists,registry-unauthorized, …) stops at once and names itself.A ledger.
--ledger NAMErecords each copy asdoneorfailed(attempts, reason, the receipt’s digest, time) after every copy and every failed attempt, in--ledger-dir(default~/.local/state/piceli/copy, private files). Running the same command again with the same name skips what isdoneand continues at the first copy that is not. The ledger holds no credential and at most 500 copies. A skipped copy reports the receipt of the run that made it (0.87.0: source, target and tag, digest, platforms, pull reference, result, referrers;from_ledger: true), so a rerun’s--outsays what was copied; a copy recorded before 0.87.0 has none.In the cluster.
--in-cluster(with--kubeconfigand--context,--namespace piceli-system) writes the set and the ledger into ConfigMappiceli-copy-<ledger>and creates one Job (backoffLimit: 0, deadline--timeout) from the controller’s image (--imageto choose another) that runspiceli artifacts copy-job-run. The Job reaches the cluster registry by its Service name, runs the same retries and ledger, and prints its ledger and report as log lines that your command reads, saves and prints. Without--ledgerthe ledger is named after the plan digest. Registry credentials never go into the Job’s arguments or the plan:--credentialsor--docker-configfiles are put into a Secret that the Job reads into environment variables and that is removed afterwards, or name your own with--credentials-secret NAME(keyssource-username,source-password,source-token, and the same fortarget, each optional).A killed client. The Job keeps running. Run the same command again with the same ledger: it finds the Job (its name is a hash of the ledger and the set), waits for it and prints its result; a Job that already ended is read the same way, and a failed one is replaced and continues at the first copy not done. A failed Job is kept until then, so its log stays.
The output of a single --from/--to copy is still its receipt. With
--set it is a piceli.copy-set.v1 report: ledger, ok, failed (the
first failed reason), items (each with state done, failed or
pending, attempts, reason, receipt_digest, skipped and, when it ran,
its receipt) and retries.
Registries and credentials¶
A public registry needs no credentials to pull; pushing always does.
--docker-config PATHreads a Dockerconfig.json: acredHelpersentry for the registry (orcredsStore) asks that helper (docker-credential-<name> get, for examplegcloudfor Artifact Registry orecr-loginfor ECR); otherwiseauths.<registry>.auth.--credentials FILEreads a private JSON file ({"username", "password"}or{"token"}), asartifacts deliverdoes. Credentials are never printed, never part of the plan or the receipt, and never passed to cosign as arguments.TLS is required except for a loopback registry;
--ca-fileadds a CA.Your clients pull with their own credentials: the chart’s
imagePullSecretsvalue names the Secret they create (see Publish for other people’s clusters: a Helm chart and manifests).
Signing and verifying¶
--sign-key cosign.key signs with cosign 3
(on PATH or --cosign PATH, pinned by sha256) and a key pair you keep:
cosign generate-key-pair # cosign.key (0600) and cosign.pub
export COSIGN_PASSWORD=… # the key's password, read by cosign only
Signatures are stored next to the image, in the Sigstore bundle format, as
referrers of the signed manifest. Nothing is sent to the public
transparency log: Piceli gives cosign a signing config without Rekor or a
timestamp authority, so verification uses the public key alone. Give your
clients cosign.pub; they verify with:
cosign verify --key cosign.pub --insecure-ignore-tlog=true \
registry.example/shop/api@sha256:<index digest>
(--insecure-ignore-tlog only says that there is no log entry to check; the
signature itself is verified.) An admission policy (Sigstore
policy-controller, Kyverno verifyImages) can require the same key.
Keyless signing (an OIDC identity and the public log) is not built in: run
cosign sign --recursive registry.example/shop/api@sha256:<index digest>
yourself after publishing if you want it.
Errors¶
Code |
Meaning |
|---|---|
|
No platform, a repeated or unsupported one, or one the spec does not allow |
|
Bad |
|
|
|
The version tag names another image (use a new version or |
|
An SBOM or provenance file differs from the build receipt |
|
What the registry serves differs from what was pushed |
|
Bad |
|
The |
|
The target does not serve what was copied, or the copy stopped |
|
Docker config credentials could not be read |
|
Signing could not run |
piceli explain <code> prints the cause and the fix of each.