Documentation
¶
Overview ¶
Package yurthub installs, routes and manages OpenYurt YurtHub in a Flex worker.
Index ¶
- Variables
- func ResetHost(ctx context.Context, worker Worker) error
- func ResetHostTask(log *slog.Logger) phases.Task
- type Config
- type Operations
- func (o *Operations) Cleanup(context.Context) error
- func (o *Operations) Converge(ctx context.Context) error
- func (o *Operations) Prepare(ctx context.Context) error
- func (o *Operations) Restore(ctx context.Context) error
- func (o *Operations) Route(ctx context.Context) error
- func (o *Operations) Stop(ctx context.Context) error
- func (o *Operations) Verify(ctx context.Context) error
- type Reconciler
- type Worker
Constants ¶
This section is empty.
Variables ¶
var ErrPackageDownload = errors.New("could not download a valid hub package")
ErrPackageDownload means no valid pinned Hub package could be downloaded, for example because packages.microsoft.com is unreachable or a proxy altered it.
var ErrUnsupportedWorker = errors.New("hub is not available for this worker")
ErrUnsupportedWorker means no pinned Hub package matches the worker image's OS or architecture. Callers log it and keep the node on the direct API path; it is not retried as a failure.
Functions ¶
Types ¶
type Config ¶
type Config struct {
Log *slog.Logger
Worker Worker
NodeName string
NodePool string // Flex agent pool name, used as the apps.openyurt.io/nodepool label
ServerURL string // direct HTTPS API server URL
Nodes typedcorev1.NodeInterface
}
Config identifies the worker and node a set of Hub operations acts on.
type Operations ¶
type Operations struct {
// contains filtered or unexported fields
}
Operations implements Hub transition steps for one worker. Each step is idempotent because the engine can repeat a step after a crash.
func NewOperations ¶
func NewOperations(cfg Config) (*Operations, error)
NewOperations validates inputs once so no step can render unsafe arguments.
func (*Operations) Cleanup ¶
func (o *Operations) Cleanup(context.Context) error
Cleanup has nothing to undo: with filters off, Hub never changed what pods see.
func (*Operations) Converge ¶
func (o *Operations) Converge(ctx context.Context) error
Converge brings an enabled Hub's binary, arguments and unit up to this agent and restarts Hub only if they differ from what it was last started with; otherwise it checks readiness. It never touches kubelet or Node metadata.
func (*Operations) Prepare ¶
func (o *Operations) Prepare(ctx context.Context) error
Prepare checks local prerequisites, renders configuration and starts Hub without touching kubelet routing. If Hub is already running (for example a retry while its serving CSR is pending), it is restarted only when the files it would load differ from what the agent last started it with.
func (*Operations) Restore ¶
func (o *Operations) Restore(ctx context.Context) error
Restore returns kubelet to the direct API server and proves the live process uses it before anything stops Hub.
func (*Operations) Route ¶
func (o *Operations) Route(ctx context.Context) error
Route switches kubelet to Hub. The direct kubeconfig stays in place. It first converges Hub's files and checks Hub is ready and forwards a kubelet request: a crash, retry or agent upgrade can resume at Route long after Prepare ran.
func (*Operations) Stop ¶
func (o *Operations) Stop(ctx context.Context) error
Stop disables Hub, deletes its cache and removes a dummy interface left by an older agent. A missing unit (enable failed before staging) counts as stopped if systemd agrees. The interface is removed only if this agent configured Hub.
type Reconciler ¶
type Reconciler struct {
// contains filtered or unexported fields
}
Reconciler runs the active worker's transition engine on every Machine read; RP changes DT intent without changing the Machine ETag. After a failure it waits (1 minute, doubling to 15) so Node events don't repeat 2-minute readiness waits on the shared queue; a changed intent or worker runs immediately. Only the serialized daemon queue calls it, so retry state needs no lock.
func NewReconciler ¶
func NewReconciler(log *slog.Logger, nodeName, nodePool, serverURL string, nodes typedcorev1.NodeInterface, heartbeat time.Duration) *Reconciler
NewReconciler builds a DT reconciler using the node client. Calls must be serialized with other worker lifecycle operations.