NodeLocalRegistry¶
An OCI registry that one node pulls from, with no registry configuration on the node.
NodeLocalRegistry runs the distribution
registry with the host network and binds it to the node loopback
(127.0.0.1:<port>). containerd allows plain HTTP to a registry on
127.0.0.1/localhost, so the kubelet on that node pulls
127.0.0.1:<port>/<repository>@sha256:… without registries.yaml, certs.d or
TLS, and the registry is not reachable from any other host. Images are pushed
through kubectl port-forward.
The design, the verification on kind and the maintenance procedures are in Node-local registry.
Generated objects¶
Object |
Name |
Notes |
|---|---|---|
ConfigMap |
|
The complete registry |
PersistentVolumeClaim |
|
|
Deployment |
|
1 replica, |
garbage_collection() returns a separate NodeLocalRegistryGarbageCollection
deployable (a Job). It is not part of get(), because garbage collection is a
maintenance step, not a steady state.
Properties¶
node_name(required): thekubernetes.io/hostnameof the node that runs the registry and pulls from it.name: base name of the objects (defaultregistry, at most 55 characters).port: loopback port (default5000, 1024–65535).image: registry image pinned by digest. The default isdocker.io/library/registry:3.1.1@sha256:325b4b29…a6e0(multi-arch index). An image without@sha256:<64 hex>is rejected.storage,storage_class: size and class of the retained PVC.host_path: use this node directory instead of a PVC. With a non-root user, an init container (root, onlyCAP_CHOWN) hands the directory to that user, becausefsGroupdoes not apply to hostPath volumes.read_only: maintenance mode. Pulls work; pushes and deletes return405.stopped: zero replicas (used for garbage collection).run_as_user: UID, GID andfsGroup(default65532).Nonekeeps the image user (root).cpu_request,memory_request,memory_limit: defaults10m,32Mi,256Mi.upload_purge_age: incomplete uploads older than this are purged (default168h).labels: extra labels for every object.
Security: the container runs as non-root with a read-only root filesystem,
allowPrivilegeEscalation: false, all capabilities dropped and the
RuntimeDefault seccomp profile. Probes are httpGet to 127.0.0.1:<port>/v2/
(the kubelet shares the node network namespace with a host-network pod).
Methods¶
pull_reference(repository, digest):127.0.0.1:<port>/<repository>@<digest>. The module-leveltemplates.pull_reference(repository, digest, port=5000)does the same without a template.garbage_collection(name=None, delete_untagged=True, dry_run=False, cleanup_after_seconds=3600): the garbage-collection Job for this registry.resource_intents(namespace): the manifests asResourceIntentobjects.component(namespace, component_name="registry", dependencies=()): aDeploymentComponentfor apiceli releasecomposition.
Example¶
from piceli.k8s import templates
registry = templates.NodeLocalRegistry(node_name="worker-1", storage="20Gi")
# workloads on worker-1 pull by digest from the node loopback
image = registry.pull_reference(
"team/api", "sha256:4f1c…"
) # 127.0.0.1:5000/team/api@sha256:4f1c…
# garbage collection (see the guide for the procedure)
gc = registry.garbage_collection()
In a piceli release composition function:
def build(ctx):
registry = templates.NodeLocalRegistry(
node_name=ctx.nodes["primary"].name, image=ctx.image("registry")
)
return DeploymentComposition(
(
registry.component(ctx.namespace),
DeploymentComponent("app", (app_intent,), dependencies=("registry",)),
)
)
A complete composition and release.toml are in examples/registry/.