Skip to content

Support remote images with images load subcommand#22

Merged
solsson merged 1 commit into
mainfrom
images-cache-support-remote
May 11, 2026
Merged

Support remote images with images load subcommand#22
solsson merged 1 commit into
mainfrom
images-cache-support-remote

Conversation

@solsson
Copy link
Copy Markdown
Contributor

@solsson solsson commented May 11, 2026

No description provided.

…present

`y-cluster images load` accepts:

  ./...  /...  ~/...      treat as local path
                          - file: an already-tarred OCI archive
                          - directory: an OCI v1 layout (tar
                            streamed on the fly, equivalent to
                            tar -cf - -C <dir> . | images load -)
  -                       stdin (an OCI archive)
  <anything else>         remote image reference

For remote refs the default flow resolves the digest, checks the
cluster's k8s.io namespace, no-ops if already indexed, otherwise
pulls into the y-cluster shared cache (idempotent on digest, dedup
across cluster targets) and streams to ctr image import. The
skip-if-present check saves the SSH/docker-exec byte transfer on
re-deploys -- the biggest cost on the qemu backend.

--cache=false opts out of the persistent cache: pull into a
tempdir, load, throw the tempdir away. Rejected for path / stdin
input where the caller already owns the bytes.

Internal surface added:

- pkg/images.Export(ctx, ref, dir, logger) -- pull a ref to an
  exact dir (sibling to Cache which writes to a derived path
  under the shared cache root).
- pkg/images.ResolveDigest(ctx, ref) -- digest resolution without
  pulling blobs; digest input is offline-safe, tag input HEADs.
- pkg/images.TarOCIDir(dir, w) / TarOCIDirReader(dir) -- stream
  the USTAR archive ctr image import accepts.
- pkg/images.PresentInCluster(ctx, lr, digestRef) -- matches the
  digest column in ctr image list, ignoring ref-name differences
  (mirrors, retag) so the cluster-side dedup is content-keyed.
- pkg/cache.ImageLayout(flagOverride, digest) -- single source of
  truth for "where does a given digest's layout live", so a
  future cache-backend swap (e.g. embedded registry:3 in 2.0)
  touches one helper, not every caller.
- Cache now logs "image cached" at info level on write success,
  symmetric with "pulling image" / "image already cached" --
  one info entry per network pull, one per cache hit, one per
  import. Grep-friendly for sideload scripts.

Tests:
- pkg/images: Export round-trip via random.Image + httptest
  registry (asserts returned digestRef matches img.Digest()
  exactly, not just shape); digest-pinned input preserved
  verbatim with no extra HEAD (verifiable in registry request
  trace); ResolveDigest digest pass-through + tag HEAD error;
  registry.k8s.io/pause:3.10 network test (-short skips).
- pkg/images: TarOCIDir streamer end-to-end (random.Image ->
  Export -> TarOCIDir -> tar.Reader) confirms every required
  OCI layout entry reaches the archive; empty-dir + missing-dir
  + pipe-close cases.
- pkg/images: PresentInCluster digest-match policy isolated.
- cmd/y-cluster: TestIsPathArg pins the dispatch rule against
  every reference shape we ship; --cache=false rejection for
  stdin and path input is asserted before any kubeconfig is
  consulted (so misuse errors don't get masked by a missing
  context).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@solsson solsson merged commit 5129b0c into main May 11, 2026
11 checks passed
solsson pushed a commit to Yolean/ystack that referenced this pull request May 12, 2026
Bumps host bin (bin/y-bin.runner.yaml) and the in-cluster
y-kustomize Deployment image across four consecutive y-cluster
releases:

- v0.4.2: `images load` accepts remote refs (Yolean/y-cluster#22)
- v0.4.3: fix `images load` for digest-only refs (Yolean/y-cluster#23)
- v0.4.4: `images list --context=<ctx>` subcommand
  (Yolean/y-cluster#24) and tunable Gateway API resource requests
  (Yolean/y-cluster#25)
- v0.4.5: re-fix digest-only image tagging and gateway resource
  requests (Yolean/y-cluster#26)

Image digest verified via `crane digest ghcr.io/yolean/y-cluster:v0.4.5`.
sha256 sums copied from v0.4.5's checksums.txt.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant