registrypush

package
v0.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package registrypush pushes a local Docker archive into the in-cluster registry without exposing it publicly. It runs a short-lived helper Pod in a workload namespace, streams the archive to it with a transfer token, and rewrites push targets between the public, ingress and cluster registry hosts.

Index

Constants

View Source
const (
	HelperLabelKey   = "app.kubernetes.io/name"
	HelperLabelValue = "registry-push-helper"
)

HelperLabelKey and HelperLabelValue mark trusted publication helper pods. The registry NetworkPolicy admits only labeled pods to the backend port and grants them the egress needed for image transfer and token exchange.

View Source
const TransferTokenHeader = "X-Registry-Push-Transfer-Token" // #nosec G101 -- HTTP header name, not credential material.

TransferTokenHeader is the HTTP header carrying one-time registry push tar tokens.

Variables

This section is empty.

Functions

func CopyReaderToTempFile

func CopyReaderToTempFile(r io.Reader) (string, error)

CopyReaderToTempFile writes r to a temporary docker archive file and returns its path.

func EnsureHelperNamespace

func EnsureHelperNamespace(ctx context.Context, client kubernetes.Interface, namespace string) error

EnsureHelperNamespace verifies the helper namespace exists.

func ParsePortOrDefault

func ParsePortOrDefault(value string, def int) int

ParsePortOrDefault parses a service port string or returns def.

func PushDockerArchive

func PushDockerArchive(ctx context.Context, client kubernetes.Interface, restConfig *rest.Config, tarPath, target string, cfg Config) (retErr error)

PushDockerArchive pushes a docker save tar to target using a short-lived skopeo helper pod inside the cluster.

func ResolveHelperNamespace

func ResolveHelperNamespace(ctx context.Context, client kubernetes.Interface, preferred string) (string, error)

ResolveHelperNamespace keeps native-auth helpers with their publisher Secret. The live registry configuration is authoritative, including after activation.

func RewritePushTarget

func RewritePushTarget(target string, hosts Hosts) string

RewritePushTarget replaces the registry host in target when it matches a bundled internal registry hostname. Targets already using cluster DNS or external registries are returned unchanged.

Types

type Config

type Config struct {
	// AuthSecretName optionally selects a Docker config Secret in the trusted helper namespace.
	AuthSecretName  string
	HelperNamespace string
	SkopeoImage     string
	HelperTimeout   time.Duration
	Hosts           Hosts
	// TarFetchURL, when set, skips exec-based tar copy and runs a one-shot helper
	// pod that downloads the archive from this URL before invoking skopeo.
	TarFetchURL string
	// TarFetchToken is sent as X-Registry-Push-Transfer-Token when fetching TarFetchURL.
	TarFetchToken string
}

Config controls in-cluster registry push helper behavior.

type Hosts

type Hosts struct {
	InternalHostnames []string
	ServiceName       string
	ServiceNamespace  string
	ServicePort       int
}

Hosts identifies bundled registry hostnames that should be rewritten to an in-cluster service DNS name for skopeo pushes from inside the cluster.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL