operator

package
v0.2.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FieldOwner = "unbounded-operator"

	ComponentNet      = "net"
	ComponentMachina  = "machina"
	ComponentMetalman = "metalman"
	ComponentStorage  = "storage"
)
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.

Variables

View Source
var DefaultNamespace = unbounded.SystemNamespace()

DefaultNamespace is the namespace the operator installs components into. It follows the operator's own namespace (unbounded.SystemNamespace()).

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",
}

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 and net manifests and waits for each to become Established. It is idempotent (safe to run on every operator start) and must run before the manager starts, because the typed Site informer cannot sync until the Site CRD is served.

Types

type CRDMaintainer

type CRDMaintainer struct {
	Client    client.Client
	Interval  time.Duration
	Bootstrap func(context.Context, client.Client) error
}

CRDMaintainer periodically reapplies the operator-owned CRDs using an uncached client. Maintenance failures are logged and retried on the next interval; they never stop the manager. CRDs that are already established stay served by the apiserver regardless of the operator's liveness, so stopping on maintenance failures would needlessly take down the Site reconciler and the migration reaper for what is typically a transient apiserver blip.

func (*CRDMaintainer) NeedLeaderElection

func (*CRDMaintainer) NeedLeaderElection() bool

NeedLeaderElection ensures only the elected operator replica maintains CRDs.

func (*CRDMaintainer) Start

func (m *CRDMaintainer) Start(ctx context.Context) error

Start runs CRD maintenance until the manager stops (context cancellation). Maintenance failures are logged and retried on the next interval; they do not stop the manager.

type Config

type Config struct {
	// MetalmanImage is the image for the synthesized per-site metalman
	// Deployment. It is stamped to the operator's version by the operator
	// Deployment; the other components carry their version-matched image in
	// the embedded release manifests.
	MetalmanImage string

	// APIServerEndpoint is injected into the machina controller config.
	APIServerEndpoint string
}

type LegacyReaper

type LegacyReaper struct {
	client.Client
	// APIReader bypasses the manager cache for migration inventory, copy sources,
	// target existence checks, and safety gates. It falls back to Client for
	// direct construction in unit tests.
	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 cancelled, 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.

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 cancelled (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 DefaultNamespace so the operator follows the namespace it
	// is installed in (see cmd/unbounded-operator --namespace).
	Namespace string
}

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

Jump to

Keyboard shortcuts

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