pullsecret

package
v0.1.89 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package pullsecret provides helpers for combining the HostedCluster pull secret with an additional, provider-supplied credential used to reach the registry hosting the control plane release image.

This exists to support running a hosted control plane from a private release image (for example a CVE-remediation build referenced by HostedCluster.spec.controlPlaneRelease) without exposing that credential to the data plane. The merged credentials are only ever held in memory at the point of a registry call; they are never written back into the cluster's pull-secret Secret, which HCCO propagates to the guest cluster and its nodes.

Scope: release payload lookups only

The credential authenticates the in-process registry calls that operators make to read the control plane release payload and the metadata of images listed in it: resolving the payload, its component image references, and labels on the control plane operator image. It is not handed to the kubelet. Control plane Pods keep pulling their images with the cluster pull secret and whatever credentials the management cluster nodes already have, so when the component images themselves live in the private registry the management cluster must be able to pull them independently, for example through a node-level credential or a registry mirror configured on the management cluster.

Index

Constants

View Source
const (
	// ControlPlaneReleaseSecretName is the well-known name of the Secret, in the
	// hypershift-operator's own namespace, holding additional credentials for the
	// registry that hosts the control plane release image. The hypershift-operator
	// syncs a copy of it into each affected control plane namespace under
	// SyncedControlPlaneReleaseSecretName.
	//
	// The Secret is expected to be of type kubernetes.io/dockerconfigjson. Its
	// absence is the normal case and is never an error.
	ControlPlaneReleaseSecretName = "control-plane-release-pull-secret"

	// SyncedControlPlaneReleaseSecretName is the name of the copy the
	// hypershift-operator keeps in the control plane namespace, where the control
	// plane operator, HCCO and other management-side controllers read it.
	//
	// It deliberately differs from ControlPlaneReleaseSecretName. Secrets referenced
	// from HostedCluster.spec.configuration are copied into the same namespace under
	// their original names, so a name shared with the source would let a tenant
	// Secret and the provider credential overwrite each other. Ownership is also
	// tracked with ManagedByLabel, so a Secret this package did not create under the
	// same name is never read, overwritten or deleted.
	SyncedControlPlaneReleaseSecretName = "hypershift-control-plane-release-pull-secret"

	// ManagedByLabel marks the synced copy as owned by the hypershift-operator. The
	// sync only updates or deletes Secrets carrying it, and readers in the control
	// plane namespace reject a Secret without it.
	ManagedByLabel = "hypershift.openshift.io/control-plane-release-pull-secret"

	// VeleroExcludeFromBackupLabel keeps the synced copy out of OADP/Velero
	// backups of the control plane namespace. The provider credential belongs to
	// the management cluster it was configured on; after a restore, the
	// hypershift-operator on the destination recreates the copy from its own
	// ControlPlaneReleaseSecretName.
	VeleroExcludeFromBackupLabel = "velero.io/exclude-from-backup"
)

Variables

This section is empty.

Functions

func ForControlPlaneRelease

func ForControlPlaneRelease(ctx context.Context, c client.Reader, operatorNamespace string, base []byte) ([]byte, error)

ForControlPlaneRelease returns base merged with the provider's control plane release pull secret, ControlPlaneReleaseSecretName in operatorNamespace.

When that Secret does not exist, base is returned unchanged. Callers should only invoke this for lookups of the control plane release image; passing the result to a data plane lookup would widen the credentials available to it.

func ForHostedCluster

func ForHostedCluster(ctx context.Context, c client.Reader, hc *hyperv1.HostedCluster, operatorNamespace string, base []byte) ([]byte, error)

ForHostedCluster returns the credentials the hypershift-operator should use when resolving hc's control plane release image. The additional credential is read from the operator's own namespace.

When hc does not pin a distinct control plane release, base is returned unchanged: the release being resolved is then the data plane release, which must not gain access to the additional credential.

func ForHostedClusterInNamespace

func ForHostedClusterInNamespace(ctx context.Context, c client.Reader, hc *hyperv1.HostedCluster, controlPlaneNamespace string, base []byte) ([]byte, error)

ForHostedClusterInNamespace is like ForHostedCluster but reads the synced copy of the additional credential from controlPlaneNamespace.

Callers pass the control plane namespace explicitly rather than deriving it from hc, because some callers (AutoNode) hand in a synthetic HostedCluster whose namespace already is the control plane namespace.

Use this from controllers that only run once the control plane namespace exists. The hypershift-operator's own HostedCluster reconcile must use ForHostedCluster instead, because it resolves the control plane operator image before that namespace has been created.

func ForHostedControlPlane

func ForHostedControlPlane(ctx context.Context, c client.Reader, hcp *hyperv1.HostedControlPlane, base []byte) ([]byte, error)

ForHostedControlPlane returns the credentials an in-namespace control plane component should use when resolving hcp's control plane release image. The additional credential is read from the synced copy in the control plane namespace.

When hcp does not pin a distinct control plane release, base is returned unchanged.

func IsManagedCopy

func IsManagedCopy(secret *corev1.Secret) bool

IsManagedCopy reports whether secret is a control plane release pull secret copy created by the hypershift-operator.

func Merge

func Merge(base, additional []byte) ([]byte, error)

Merge returns dockerconfigjson bytes containing the union of the auths in base and additional. On conflict the entry from additional wins.

If additional is empty, base is returned unchanged.

Why additional wins, unlike the global pull secret controller

globalps merges the other way round: the cluster's own credentials win, so a user supplied secret cannot override them. Its documentation suggests working around a collision by adding a repository scoped entry such as "quay.io/org/repo" alongside the host entry "quay.io".

That workaround does not work here. The registry client this credential is handed to resolves credentials per registry *host*: the docker auth handler calls CredentialStore.Basic with the registry endpoint, so a repository scoped key is never matched and is silently ignored. Verified against a private repository on a host that also had a host level entry:

repository scoped key only   -> unauthorized
host entry + repository key  -> unauthorized (host entry is the only one consulted)
host entry carrying the credential -> succeeds

So the only way to reach a private repository on a registry that already appears in the cluster pull secret is for the additional credential to replace the host entry. Keeping base precedence would make this package a no-op for exactly the case it exists to serve, for example a remediation repository hosted on quay.io.

Equivalent keys

The registry credential store normalizes auth keys before indexing them: a missing scheme is assumed to be https, the scheme is dropped, and a leading /v1/ or /v2/ path is ignored. "registry.example.com" and "https://registry.example.com/v1/" therefore name the same entry, and when both survive a merge the store holds two credentials for one key and picks between them in map iteration order. Merge compares keys in that normalized form, so an additional entry replaces every base entry that the store would treat as the same.

Scope of the override

The override is narrow: these bytes are used only to resolve the control plane release image and the component images listed in that payload, they are never persisted, and the data plane continues to resolve its own release with the unmodified cluster pull secret. The trade-off to be aware of is that for the duration of a control plane release lookup, the provider credential is used for every image on that host, including any component image the payload references there.

The auth entries are handled as opaque values rather than being decoded into credentialprovider.DockerConfigJSON, because that type does not round-trip the "auth" field.

Types

This section is empty.

Jump to

Keyboard shortcuts

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