operator

package
v0.20.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ComponentNet      = "net"
	ComponentMachina  = "machina"
	ComponentMetalman = "metalman"
)

Component name identifiers. These mirror each component's Name() and are used by the legacy reaper (migrate.go) to gate per-component migration.

View Source
const CRDBootstrapTimeout = 4 * time.Minute

CRDBootstrapTimeout bounds the complete CRD bootstrap, including manifest applies and waiting for every CRD to be served by the apiserver. The operator health server only binds after bootstrap, so the startupProbe budget in deploy/unbounded-operator/04-deployment.yaml.tmpl must exceed this timeout.

View Source
const FieldOwner = component.FieldOwner

FieldOwner is the server-side apply field manager the operator uses. It is re-exported from the component package for callers within this package.

Variables

View Source
var DefaultNamespace = component.DefaultNamespace

DefaultNamespace is the namespace the operator installs components into.

View Source
var LegacyNamespaces = []string{legacyKubeNamespace, legacyNetNamespace}

LegacyNamespaces are the pre-consolidation namespaces components used before everything moved to the unified namespace.

View Source
var RequiredCRDNames = [...]string{
	"machines.unbounded-cloud.io",
	"machineoperations.unbounded-cloud.io",
	"sites.unbounded-cloud.io",
	"machineconfigurations.unbounded-cloud.io",
	"machineoperationcredentials.unbounded-cloud.io",
	"machineconfigurationversions.unbounded-cloud.io",
	"sitenodeslices.net.unbounded-cloud.io",
	"gatewaypools.net.unbounded-cloud.io",
	"gatewaypoolnodes.net.unbounded-cloud.io",
	"sitegatewaypoolassignments.net.unbounded-cloud.io",
	"sitepeerings.net.unbounded-cloud.io",
	"gatewaypoolpeerings.net.unbounded-cloud.io",
	"clustercaches.racer.unbounded-cloud.io",
}

RequiredCRDNames is the complete set of CRDs owned and bootstrapped by the unbounded-operator.

Functions

func BootstrapCRDs

func BootstrapCRDs(ctx context.Context, c client.Client) error

BootstrapCRDs server-side applies every CustomResourceDefinition embedded in the machina, net, and Racer manifests and waits for each to become Established. It is idempotent and must run before the manager starts, because typed informers cannot sync until their CRDs are served.

func DefaultRegistry

func DefaultRegistry() *component.Registry

DefaultRegistry returns the built-in component registry: the cluster singletons followed by the metalman per-Site component. The slice order is the stable Site status condition order (cluster first, then site).

Types

type CRDReconciler added in v0.9.0

type CRDReconciler struct {
	client.Client
	// contains filtered or unexported fields
}

CRDReconciler repairs deletion or drift of the CRDs owned by the operator. Startup bootstrap remains responsible for making the API available before the manager starts; this controller handles day-2 changes without polling.

func (*CRDReconciler) Reconcile added in v0.9.0

func (r *CRDReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

func (*CRDReconciler) SetupWithManager added in v0.9.0

func (r *CRDReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager watches only operator-owned CRDs. Startup bootstrap ensures they exist before the informer starts, so the initial add events reconcile the complete set and later update/delete events repair day-2 drift.

type Config

type Config = component.Config

Config carries operator-level settings handed to components.

type LegacyReaper

type LegacyReaper struct {
	client.Client

	// APIReader bypasses the manager cache for migration inventory, copy
	// sources, target existence checks, and safety gates. Every one of those
	// reads targets a legacy namespace, which is outside the operator's scoped
	// cache, so they must not go through it.
	//
	// It falls back to Client when nil, which exists only for unit tests that
	// construct the reaper directly against a fake client. SetupWithManager
	// rejects a nil APIReader so that fallback can never be reached in a
	// running operator.
	APIReader client.Reader

	// TargetNamespace is the unified namespace components are consolidated into.
	TargetNamespace string

	// LegacyNamespaces is the set of pre-consolidation namespaces to drain.
	LegacyNamespaces []string

	// SkipSecretNames are regenerable secrets that must not be copied (e.g. the
	// net controller serving cert, which is reissued on startup).
	SkipSecretNames map[string]struct{}

	// CopyConfigMaps are operator-owned ConfigMaps to carry across by name.
	CopyConfigMaps []string

	// APIServerEndpoint overrides the endpoint in migrated Machina config while
	// preserving every other legacy setting.
	APIServerEndpoint string

	// Interval is the requeue period while waiting for target workloads to
	// become healthy.
	Interval time.Duration

	// Recorder, when set, receives Events for notable migration actions (for
	// example a legacy namespace that still holds non-operator workloads at
	// delete time). Optional; nil disables Event emission.
	Recorder events.EventRecorder
}

LegacyReaper migrates operator-owned state out of the legacy split namespaces into the unified namespace, translates the pre-redesign net-group Sites into the machina-group Sites the operator reconciles, and then deletes the operator-owned resources (and the now-empty legacy namespaces) left behind.

func (*LegacyReaper) NeedLeaderElection

func (*LegacyReaper) NeedLeaderElection() bool

NeedLeaderElection ensures the reaper only runs on the elected leader.

func (*LegacyReaper) RunToCompletion

func (r *LegacyReaper) RunToCompletion(ctx context.Context) error

RunToCompletion performs idempotent translate-migrate-reap passes until every legacy namespace is drained and deleted, the context is canceled, or an unexpected error occurs. It returns nil only once fully reaped.

func (*LegacyReaper) SetupWithManager

func (r *LegacyReaper) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager registers the reaper as a leader-elected manager runnable.

A nil APIReader is refused rather than tolerated. liveReader falls back to the cached client, which is fine in a unit test constructing the reaper directly, and is not fine under a manager: the operator scopes its cache to its own namespace, and every read the reaper makes is aimed at a legacy namespace outside it. Those reads would fail, and they would fail deep inside a migration that deletes things. Failing at startup instead is the difference between a pod that will not start and a pod that half-migrates a cluster.

func (*LegacyReaper) Start

func (r *LegacyReaper) Start(ctx context.Context) error

Start runs the migrate-then-reap loop until everything is drained or the context is canceled (manager shutdown). It is the manager.Runnable entry point; context cancellation is a clean stop, not an error.

type SiteReconciler

type SiteReconciler struct {
	client.Client
	Scheme *runtime.Scheme
	Config Config

	// Namespace is the namespace components are reconciled into. When empty it
	// falls back to component.DefaultNamespace so the operator follows the
	// namespace it is installed in.
	Namespace string

	// Registry is the set of components to reconcile. When nil it defaults to
	// DefaultRegistry.
	Registry *component.Registry

	// APIReader reads straight from the apiserver, bypassing the manager cache.
	// Components use it through Env.LiveReader for the readiness questions the
	// cache answers badly: it lags the apiserver by however long a watch event
	// takes to arrive, and every kind read through it establishes an informer.
	// SetupWithManager refuses a nil APIReader so a running operator never
	// falls back.
	APIReader client.Reader

	// Recorder, when set, receives Events for override state changes. Optional
	// so unit tests can construct a reconciler without one.
	Recorder events.EventRecorder
	// contains filtered or unexported fields
}

SiteReconciler reconciles the registered components for every Site. It drives a component.Registry: cluster components (net, machina) run on every pass, and per-Site components (metalman) run when a Site is present. Adding a component is a matter of implementing component.ClusterComponent or component.SiteComponent and adding it to the registry; this loop, the status conditions, ordering, and the Site-less pass are all registry-driven.

func (*SiteReconciler) Reconcile

func (r *SiteReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

func (*SiteReconciler) SetupWithManager

func (r *SiteReconciler) SetupWithManager(mgr ctrl.Manager) error

Directories

Path Synopsis
Package component defines the extension contract for the unbounded operator.
Package component defines the extension contract for the unbounded operator.
components
gantry
Package gantry implements the gantry peer-to-peer OCI distribution cluster component.
Package gantry implements the gantry peer-to-peer OCI distribution cluster component.
machina
Package machina implements the machina controller cluster component.
Package machina implements the machina controller cluster component.
metalman
Package metalman implements the per-Site metalman PXE controller component.
Package metalman implements the per-Site metalman PXE controller component.
net
Package net implements the unbounded-net cluster component.
Package net implements the unbounded-net cluster component.
racer
Package racer installs the Racer dataplane on demand from ClusterCaches.
Package racer installs the Racer dataplane on demand from ClusterCaches.
tokenrefresher
Package tokenrefresher implements the bootstrap token refresher singleton.
Package tokenrefresher implements the bootstrap token refresher singleton.
Package override implements user-supplied customization of the Deployments and DaemonSets the operator generates.
Package override implements user-supplied customization of the Deployments and DaemonSets the operator generates.

Jump to

Keyboard shortcuts

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