Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ EGG_IMAGE_REGISTRY ?= localhost:5000
# in the manifest rewrites in `deploy`.
EGG_IMAGE_PREFIX := $(if $(EGG_IMAGE_REGISTRY),$(EGG_IMAGE_REGISTRY)/,)

# The full egg image set, and the subset published via the registry. The
# sandbox image is EXCLUDED from the registry subset by default: it bakes in
# private repo content (node_modules/.venv/anything repositories.yaml
# build_commands produce), so it never goes near a registry — even the
# loopback-only local one — unless the operator opts in by adding
# egg-sandbox to EGG_REGISTRY_IMAGES. Excluded images publish through the
# save+import path instead (slower for the big sandbox image, but entirely
# store-to-store on this host). push-egg-images.sh independently refuses any
# non-loopback registry, so opting in still cannot publish off-host.
# The full egg image set, and the subset published via the registry (all of
# them by default). The registry is loopback-only — the egg images (the
# sandbox especially) bake in private repo content, and the privacy controls
# are that setup-local-registry.sh only ever creates a 127.0.0.1-bound
# registry and push-egg-images.sh refuses any non-loopback registry with no
# override, so nothing can be published off-host. To keep an image off the
# registry entirely, remove it from EGG_REGISTRY_IMAGES; excluded images
# publish through the save+import path instead (slower, but entirely
# store-to-store on this host, no registry involved).
EGG_ALL_IMAGES := egg-gateway egg-orchestrator egg-sandbox egg-litellm
EGG_REGISTRY_IMAGES ?= egg-gateway egg-orchestrator egg-litellm
EGG_REGISTRY_IMAGES ?= $(EGG_ALL_IMAGES)
# Images the registry path does NOT cover (imported via k3s-import instead).
EGG_IMPORT_IMAGES := $(filter-out $(EGG_REGISTRY_IMAGES),$(EGG_ALL_IMAGES))
# Per-image manifest prefix: registry-qualified only when registry mode is on
Expand Down Expand Up @@ -507,8 +507,8 @@ lint-yaml-fix: sync-venv-if-uv
# Tag set for one image: bare names always (k3s-import + local tooling),
# registry-qualified names only when registry mode is on AND the image is in
# the registry subset (what `k3s-push` pushes and `deploy` rewrites the
# manifests to). Non-subset images (the sandbox, by default) never even get
# a registry-qualified tag.
# manifests to). Images excluded from the subset never even get a
# registry-qualified tag.
define image_tags
-t $(1):latest -t $(1):$(EGG_IMAGE_TAG) $(if $(call reg_prefix,$(1)),-t $(call reg_prefix,$(1))$(1):latest -t $(call reg_prefix,$(1))$(1):$(EGG_IMAGE_TAG))
endef
Expand Down Expand Up @@ -724,12 +724,12 @@ deploy: sudo-keepalive check-egg-images-present ## Deploy egg to k3s
redeploy: sudo-keepalive build k3s-publish deploy ## Rebuild, publish images, and redeploy in one step

# Publish dispatch (issue #2999): in registry mode, push the registry subset
# (layer-incremental — the fast path) and save+import the rest (the sandbox,
# unless opted in via EGG_REGISTRY_IMAGES); without a registry — or with an
# empty registry subset (EGG_REGISTRY_IMAGES="") — save+import everything.
# (layer-incremental — the fast path; all images by default) and save+import
# any images excluded from EGG_REGISTRY_IMAGES; without a registry — or with
# an empty registry subset (EGG_REGISTRY_IMAGES="") — save+import everything.
k3s-publish: sudo-keepalive
@if [ -n "$(EGG_IMAGE_REGISTRY)" ] && [ -n "$(strip $(EGG_REGISTRY_IMAGES))" ]; then \
$(MAKE) --no-print-directory k3s-push; \
$(MAKE) --no-print-directory k3s-push || exit 1; \
if [ -n "$(strip $(EGG_IMPORT_IMAGES))" ]; then \
$(MAKE) --no-print-directory k3s-import K3S_IMPORT_IMAGES="$(EGG_IMPORT_IMAGES)"; \
fi; \
Expand Down Expand Up @@ -799,13 +799,13 @@ sudo-keepalive:
# would only mismatch if :$(EGG_IMAGE_TAG) is also absent (the inner grep
# guard skips when it is already present).
# NOTE (#2999): k3s-import is the save+import publish path. The default
# `make redeploy` flow uses it only for the images excluded from the registry
# subset (the sandbox, which must not be pushed to any registry by default —
# see EGG_REGISTRY_IMAGES above); with EGG_IMAGE_REGISTRY= (empty) it covers
# everything, e.g. for CI. K3S_IMPORT_IMAGES narrows the image set
# (k3s-publish passes the registry-subset complement). It deals in BARE
# image names (egg-sandbox:<tag>), matching what `deploy` writes into the
# manifests for non-registry images.
# `make redeploy` flow uses it only for images excluded from the registry
# subset (none by default — see EGG_REGISTRY_IMAGES above); with
# EGG_IMAGE_REGISTRY= (empty) it covers everything, e.g. for CI.
# K3S_IMPORT_IMAGES narrows the image set (k3s-publish passes the
# registry-subset complement). It deals in BARE image names
# (egg-sandbox:<tag>), matching what `deploy` writes into the manifests for
# non-registry images.
K3S_IMPORT_IMAGES ?= $(EGG_ALL_IMAGES)
k3s-import: SHELL := /bin/bash
k3s-import: sudo-keepalive ## Import built images into k3s (registry-excluded set)
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/local-quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ egg --public # start sandbox session

`make registry-setup` is a one-time host step (also run by `make k3s-setup`): it starts a `registry:2` container **bound to 127.0.0.1 only** (nothing is published off-host) and points k3s's containerd at it via `/etc/rancher/k3s/registries.yaml`. `make build` builds the Docker images. `make k3s-push` publishes the registry-subset images through the registry — `docker push` and the containerd pull are both layer-aware, so after the first publish a code-only rebuild moves tens of MB instead of full images (issue #2999). `make deploy` applies the Kustomize manifests — it is idempotent and can be re-run after code changes to update the running deployment. `make deploy` also performs a pre-flight check: it aborts before touching the cluster if the images for the current tag were never published, directing you to run `make redeploy` instead.

By default the registry subset is `egg-gateway egg-orchestrator egg-litellm` (`EGG_REGISTRY_IMAGES`). The **sandbox image is excluded**: it bakes in private repo content (prebuilt `node_modules`/`.venv` from `repositories.yaml` build commands), so it is never pushed to any registry — even the loopback one — unless you opt in by adding `egg-sandbox` to `EGG_REGISTRY_IMAGES`; it publishes via `docker save` + `ctr import` instead (store-to-store on this host, no registry involved). Opting in makes sandbox publishes layer-incremental too, and `push-egg-images.sh` hard-refuses non-loopback registries either way.
All four images ride the registry by default (`EGG_REGISTRY_IMAGES`). The egg images — the sandbox especially — bake in private repo content (prebuilt `node_modules`/`.venv` from `repositories.yaml` build commands), so the privacy controls are structural: `make registry-setup` only ever creates a `127.0.0.1`-bound registry, and `push-egg-images.sh` hard-refuses any non-loopback registry with no override — nothing can be published off-host. To keep an image off the registry entirely, remove it from `EGG_REGISTRY_IMAGES`; it then publishes via `docker save` + `ctr import` instead (store-to-store on this host, no registry involved, at the cost of full-image serialization per change).

In practice you rarely run these individually — `make redeploy` chains build → publish → deploy. To run without the local registry entirely (e.g. an ephemeral CI host), set `EGG_IMAGE_REGISTRY=` (empty); every image then goes through `make k3s-import`.

Expand Down
11 changes: 5 additions & 6 deletions scripts/check-egg-images-present.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
# leaves the running cluster broken until the operator runs `make redeploy`.
#
# Publishing is split (issue #2999): the registry-subset images (args 3+,
# from EGG_REGISTRY_IMAGES — by default everything except the private-content
# egg-sandbox) are pulled by the cluster from the loopback registry, so the
# registry's HTTP API is their source of truth. The remaining images are
# save+imported, so k3s's containerd is theirs. With no registry (arg 2
# empty, e.g. CI) every image is checked in containerd — the pre-registry
# behavior, unchanged.
# from EGG_REGISTRY_IMAGES — all egg images by default) are pulled by the
# cluster from the loopback registry, so the registry's HTTP API is their
# source of truth. Any images excluded from the subset are save+imported, so
# k3s's containerd is theirs. With no registry (arg 2 empty, e.g. CI) every
# image is checked in containerd — the pre-registry behavior, unchanged.
#
set -euo pipefail

Expand Down
6 changes: 3 additions & 3 deletions scripts/push-egg-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ usage="usage: $0 <egg-image-tag> <registry-host:port> <image>..."
TAG="$1"
REGISTRY="$2"
shift 2
# The image list comes from the caller (EGG_REGISTRY_IMAGES in the Makefile);
# by default that EXCLUDES egg-sandbox — it bakes in private repo content and
# must not be pushed to any registry unless the operator opts in there.
# The image list comes from the caller (EGG_REGISTRY_IMAGES in the Makefile,
# all egg images by default; operators can exclude images there to keep them
# off the registry entirely).
IMAGES=("$@")

# Privacy guard: refuse to push anywhere but the loopback registry. The
Expand Down
21 changes: 16 additions & 5 deletions scripts/reap-stale-egg-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# Four scopes (issue #2999):
# - containerd (always): remove stale egg refs via crictl rmi. An image's
# authoritative ref form depends on its publish path: registry-subset
# images (args 3+) are authoritative as <registry>/<image>:<tag>, while
# save+import images (the sandbox, by default) are authoritative as
# images (args 3+, all of them by default) are authoritative as
# <registry>/<image>:<tag>, while save+import images are authoritative as
# docker.io/library/<image>:<tag>. Refs in the non-authoritative form for
# their image -- e.g. bare leftovers from before the registry flow -- are
# stale by definition (the digest guard below still protects
Expand Down Expand Up @@ -57,9 +57,9 @@ shift
# check-egg-images-present.sh.
IMAGES=(egg-gateway egg-orchestrator egg-sandbox egg-litellm)

# Args 3+ name the registry-subset images (EGG_REGISTRY_IMAGES — by default
# everything but the private-content egg-sandbox). An image's AUTHORITATIVE
# containerd ref is <registry>/<image>:<tag> when it is in the subset and
# Args 3+ name the registry-subset images (EGG_REGISTRY_IMAGES — all egg
# images by default). An image's AUTHORITATIVE containerd ref is
# <registry>/<image>:<tag> when it is in the subset and
# docker.io/library/<image>:<tag> when it is not (save+import path). With no
# registry the subset is forced empty — every image is bare, the
# pre-registry behavior, unchanged.
Expand Down Expand Up @@ -335,3 +335,14 @@ if docker exec egg-registry registry garbage-collect --delete-untagged \
else
echo "==> registry reap: deleted ${reg_removed} stale tag manifest(s); garbage-collect FAILED (non-fatal)." >&2
fi

# Restart the registry to drop its in-memory blob-descriptor cache. GC runs
# as a SEPARATE process (docker exec) and deletes blob files behind the
# serving process's back; the stock registry:2 config caches blob existence
# in memory, so without a restart the next `docker push` is told "Layer
# already exists" for a blob whose file GC just removed, the layer never
# re-uploads, and the subsequent containerd pull dies with
# "short read: ... unexpected EOF". Observed live on the first #3101
# deploy. The restart takes ~1s; a pod pull racing it just retries.
docker restart egg-registry >/dev/null 2>&1 ||
echo "==> registry reap: restart of egg-registry failed -- run 'docker restart egg-registry' before the next push." >&2
Loading
Loading