Documentation
¶
Overview ¶
Package noneops is the composition root for the none isolation backend. The backend package cannot import the phase packages that install and configure the node stack, so this package resolves the goal state for a host-native node, binds the phases to it and injects them into none.Backend as hooks.
Layout of a none node. The agent owns /opt/unbounded/node: each installed version is a directory holding bin and libexec, and a current symlink selects the active one. Everything else is at the same host path the nspawn machine sees (/etc/containerd, /var/lib/kubelet, /opt/cni, /run/containerd), so unbounded-net-node, gantry and their charts do not change per mode.
Slot. A none node has no blue/green slot. Its applied config is recorded for the slot kube1, under the none mode's own name (none-kube1-applied-config.json, see goalstates.AppliedConfigName), which agents that predate the mode never read. The NodeRoot slot is the version directory name, which is what Upgrade flips.
Index ¶
- Constants
- func IsNotEmpty(err error) bool
- func LoadKernelModules(log *slog.Logger, run none.Runner) *kernelModules
- func Present() bool
- func VersionFor(r *goalstates.RootFS) string
- type Node
- func (n *Node) Backend() (*none.Backend, error)
- func (n *Node) Commit() error
- func (n *Node) Configure(ctx context.Context) (containerdChanged, kubeletChanged bool, err error)
- func (n *Node) GoalState() (*goalstates.MachineGoalState, error)
- func (n *Node) Prepare(ctx context.Context) (isolation.NodeRoot, error)
- func (n *Node) Provision(ctx context.Context) error
- func (n *Node) PruneVersions() error
- func (n *Node) RecoverUpgrade(ctx context.Context) error
- func (n *Node) Restart(ctx context.Context) error
- func (n *Node) Running(ctx context.Context) (bool, error)
- func (n *Node) Start(ctx context.Context, wasRunning, containerdChanged, kubeletChanged bool) error
- func (n *Node) Upgrade(ctx context.Context) (err error)
- func (n *Node) Version() (string, error)
- type Overrides
- type Params
- type Teardown
Constants ¶
const LaunchCheckCommand = "allocation-launch-check"
LaunchCheckCommand is the agent command the kubelet's allocation launch check runs on an allocation host.
const ModulesLoadPath = "/etc/modules-load.d/unbounded-kubernetes.conf"
ModulesLoadPath is where the node's kernel modules are listed for boot. The nspawn machine lists them inside its rootfs; a host-native node needs them on the host, and the agent-specific name never collides with a distro file. A teardown for any mode that wrote it through LoadKernelModules removes it.
const Slot = goalstates.NSpawnMachineKube1
Slot is the slot name a none node records its applied config under.
Variables ¶
This section is empty.
Functions ¶
func IsNotEmpty ¶
IsNotEmpty reports whether err says a directory could not be removed because it still has entries.
func LoadKernelModules ¶
LoadKernelModules returns a task that lists the node's kernel modules for boot and loads them now. The sysctls the host phase applies (bridge-nf-call) need br_netfilter loaded first.
func Present ¶
func Present() bool
Present is the package level form of Teardown.Present for the real host.
func VersionFor ¶
func VersionFor(r *goalstates.RootFS) string
VersionFor names the version directory for a rootfs goal state: the Kubernetes version plus a digest of everything else that decides which binaries are installed, so changing only the containerd or CNI version, the architecture or a download override yields a new directory while an unchanged configuration reuses the installed one.
Types ¶
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node is a none node bound to one configuration.
func New ¶
New returns a Node. Goal state resolution is deferred to first use so that operations that never need it (Stop, Status) work without a configuration.
func (*Node) Commit ¶
Commit ends a successful upgrade once the caller has persisted the applied config: the saved configuration is dropped, then the journal. A crash in between leaves a journal without a snapshot, which RecoverUpgrade finishes.
func (*Node) Configure ¶
Configure writes the node configuration at its host paths and prepares the shared LocalDNS network. It reports whether containerd or kubelet configuration differed from what was on disk, so a reapply against a running node restarts only what changed.
func (*Node) GoalState ¶
func (n *Node) GoalState() (*goalstates.MachineGoalState, error)
GoalState is the resolved goal state with the host-native overrides applied.
func (*Node) Provision ¶
Provision installs the version, writes the units and points the current link at it. Bootstrap uses it for the first install, where there is no previous version to keep running.
func (*Node) PruneVersions ¶
PruneVersions removes every installed version except the active one. It runs after an upgrade succeeds, mirroring the removal of the old nspawn machine.
func (*Node) RecoverUpgrade ¶
RecoverUpgrade finishes an upgrade a crash interrupted. The daemon calls it at startup with the applied config, which is the configuration the node ran before the upgrade unless the upgrade had already succeeded and been persisted. Which of the two it is is decided from the configuration itself: the journal records a digest of the configuration the upgrade applied, and only an applied config with that digest, on the version the upgrade switched to, is a finished upgrade. The version name is not enough, because a repave that changes only configuration keeps it. A finished upgrade is committed, and its stack started if it is not running, since the agent may have stopped after it stopped the stack. Otherwise the node is rolled back: the stack is stopped, its pods ended, the link pointed at the version the journal recorded, the units written for this configuration, the saved configuration restored, host networking set up again, and the stack started. It does nothing when no upgrade was in progress.
func (*Node) Restart ¶
Restart restarts the node stack in place (soft reboot): LocalDNS, containerd, then kubelet, waiting for LocalDNS after it restarts and for kubelet to be active at the end. The host is not rebooted.
func (*Node) Start ¶
Start brings the stack up and waits for kubelet to bootstrap. When the stack was already running and its configuration changed, the changed service is restarted, containerd first.
func (*Node) Upgrade ¶
Upgrade installs this configuration's version beside the active one, writes the new configuration, and switches over: stop the stack, end its pods, clean host networking and the CNI configuration and state as repave does, flip the current link, start, and wait for kubelet. If the new version does not come up the link is flipped back and the previous version is started again with the units, configuration and host networking of Params.Previous. The caller has already drained the node and removed it from the cluster, as for an nspawn repave.
Configuration lives at the same host paths for every version, so the files the stacks share are saved before anything is written (see confsnap) and put back on every failure. Before anything changes an upgrade journal records the version the node runs, so a crash in the middle is finished at the next start by RecoverUpgrade. On success the journal and the saved configuration are kept until the caller has persisted the applied config and calls Commit; a failed upgrade removes them itself.
type Overrides ¶
type Overrides struct {
// Layout is the agent-owned directory. The zero value is the default.
Layout none.Layout
// SystemdDir is where units are written. Empty means /etc/systemd/system.
SystemdDir string
// Run executes host commands. Nil uses the real host.
Run none.Runner
// Proc is the procfs Destroy scans for container shims. Empty means /proc.
Proc string
// CgroupRoot is the cgroup v2 mount Destroy kills the pods' cgroups under.
// Empty means /sys/fs/cgroup when Proc is also empty, and none otherwise.
CgroupRoot string
// Download replaces the artifact installers. Nil downloads for real.
Download func(ctx context.Context) error
// SetupGPU replaces the host GPU setup that runs before the stack starts.
SetupGPU func(ctx context.Context) error
// WaitKubelet overrides the kubelet readiness wait. Nil uses the phase the
// nspawn mode uses.
WaitKubelet func(ctx context.Context) error
// ImageArchiveDir is the host directory staged container image archives
// are imported from after containerd starts. Empty means
// goalstates.ContainerImageArchiveHostDir.
ImageArchiveDir string
}
Overrides are the none-specific seams of Params.
type Params ¶
type Params struct {
Log *slog.Logger
// Config is the agent configuration goal states are resolved from.
Config *config.AgentConfig
// Downloads optionally overrides artifact download sources.
Downloads *goalstates.DownloadOverrides
// GoalState, when set, is used instead of resolving one. Bootstrap passes
// the goal state it has already resolved so GPU and device discovery happens
// once.
GoalState *goalstates.MachineGoalState
// Previous is the configuration the node runs with before an Upgrade: the
// applied config. A rollback restores its units and host networking, so the
// previous version starts on what it ran with. PreviousGoalState, when set,
// is used instead of resolving Previous. With neither, a rollback uses this
// configuration's.
Previous *config.AgentConfig
PreviousGoalState *goalstates.MachineGoalState
// Overrides and Hooks are left zero in production, which is the real host.
// Tests set them to run a node against a temporary tree and a fake host.
Overrides
hostnode.Hooks
}
Params bind a Node to one agent configuration.
type Teardown ¶
type Teardown struct {
Log *slog.Logger
// Layout, SystemdDir and Run are as in Params.
Layout none.Layout
SystemdDir string
Run none.Runner
// Root prefixes every host path the teardown removes outside the layout and
// systemd directory. Empty is the real host; tests use a temporary tree.
Root string
// MountInfo is the mount table. Empty means /proc/self/mountinfo.
MountInfo string
// Proc is the procfs scanned for container shims. Empty means /proc.
Proc string
// CgroupRoot is the cgroup v2 mount the pods' cgroups are killed under.
// Empty means /sys/fs/cgroup when Proc is also empty, and none otherwise.
CgroupRoot string
}
Teardown removes a none node. Its tasks slot into the same positions in the reset order as the nspawn machine tasks they correspond to: stop, then config, then the node itself, with the host-global cleanup the caller owns in between and after. The reset runs it only on a host where Present finds the node's traces, so what it removes at the shared paths is what the agent wrote there: the bootstrap refused a host that had a kubelet or containerd of its own.
func (*Teardown) Destroy ¶
Destroy returns the task that removes the node: units, drop-ins and versions through the backend (which also ends container shims), then the node's data directories after unmounting whatever pods left mounted below them.
func (*Teardown) Present ¶
Present reports whether the host has any trace of a none node: the layout directory or an agent-owned unit. Reset uses it to choose the none teardown even after the applied config is gone.
func (*Teardown) RemoveConfig ¶
RemoveConfig returns the task that removes the configuration the agent wrote at the shared host paths.