Documentation
¶
Overview ¶
Package containerd implements runtime.Driver on the containerd instance that Armada embeds (ADR 0011).
Index ¶
- func BridgeOf(subnet netip.Prefix) (runtime.Bridge, error)
- type Config
- type Driver
- func (d *Driver) AgentStart(context.Context) error
- func (d *Driver) Bridge(ctx context.Context) (runtime.Bridge, error)
- func (d *Driver) CanMountVolumes() bool
- func (d *Driver) CanRunMembers() bool
- func (d *Driver) Close() error
- func (d *Driver) DialContainer(ctx context.Context, id, network, address string) (net.Conn, error)
- func (d *Driver) DialSandbox(ctx context.Context, id, network, address string) (net.Conn, error)
- func (d *Driver) EnsureSandbox(ctx context.Context, id string) (runtime.Sandbox, error)
- func (d *Driver) Exec(ctx context.Context, id string, cmd []string) (string, int, error)
- func (d *Driver) ExecApp(ctx context.Context, id string, opts runtime.ExecOptions) (int, error)
- func (d *Driver) Inspect(ctx context.Context, id string) (runtime.Container, error)
- func (d *Driver) List(ctx context.Context, labels map[string]string) ([]runtime.Container, error)
- func (d *Driver) ListSandboxes(context.Context) ([]runtime.Sandbox, error)
- func (d *Driver) Logs(ctx context.Context, id string, opts runtime.LogOptions) (runtime.LogStream, error)
- func (d *Driver) Ping(ctx context.Context) error
- func (d *Driver) PruneImages(ctx context.Context, keep []string, grace time.Duration) ([]string, error)
- func (d *Driver) PruneLogs(_ context.Context, retention time.Duration, maxBytes int64) error
- func (d *Driver) Pull(ctx context.Context, image string, auth *runtime.RegistryAuth) (runtime.Image, error)
- func (d *Driver) ReleaseNetwork(ctx context.Context, id string) error
- func (d *Driver) Remove(ctx context.Context, id string) error
- func (d *Driver) RemoveSandbox(ctx context.Context, id string) error
- func (d *Driver) Run(ctx context.Context, s runtime.ContainerSpec) (_ string, err error)
- func (d *Driver) RunSystem(ctx context.Context, s runtime.SystemSpec) (_ string, err error)
- func (d *Driver) SearchLogs(ctx context.Context, q runtime.LogQuery) ([]runtime.LogRecord, string, error)
- func (d *Driver) Signal(ctx context.Context, id, signal string) error
- func (d *Driver) Stats(ctx context.Context, id string) (runtime.Stats, error)
- func (d *Driver) Stop(ctx context.Context, id string, grace time.Duration) error
- func (d *Driver) TailLogs(ctx context.Context, target string, maxBytes int64) (runtime.LogTail, error)
- type SELinuxState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
Paths embedded.Paths
Subnet netip.Prefix // container bridge subnet; zero means DefaultSubnet
// MTU of the bridge and container interfaces; 0 leaves the kernel's
// default (1500). The cluster network sets it from the uplink
// (ADR 0025).
MTU int
// Self is the armada binary the shim runs to store container output;
// empty means the running executable.
Self string
// Supervisor runs containers without containerd, through the
// agent's own image store and armada-shim (ADR 0046).
Supervisor bool
// ShimBin overrides the pack's armada-shim (tests).
ShimBin string
}
Config configures the driver.
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver runs containers on the embedded containerd.
func (*Driver) AgentStart ¶
AgentStart loads Armada's AppArmor profile, so containers already running when the agent starts (after an upgrade) get its current rules without waiting for a new container; the next container tries again after a failure. Doctor and other commands that ping the runtime leave the loaded profile alone.
func (*Driver) CanMountVolumes ¶
CanMountVolumes implements runtime volume support (ADR 0023).
func (*Driver) CanRunMembers ¶
CanRunMembers implements runtime support for init containers and sidecars (ADR 0038).
func (*Driver) DialContainer ¶
DialContainer dials address from the network namespace of the running container id (ADR 0034). The socket is created on a thread switched into that namespace and keeps it afterwards, so the connection has exactly the container's routes and firewall. Only IP addresses are dialled: a name would be resolved, and a second address tried, on other threads.
func (*Driver) DialSandbox ¶
DialSandbox dials address from the sandbox's namespace, as DialContainer does from a container's: only IP addresses, over TCP or UDP.
func (*Driver) EnsureSandbox ¶
EnsureSandbox makes a network sandbox (ADR 0040): a network namespace pinned at <run dir>/sandboxes/<id>, attached to the container bridge by the same plugins as a container, so it gets an address of the node's subnet, the default route through the gateway, and the plugins' firewall rules, but holds no process. An existing sandbox is returned as it is; one half made, as an agent killed while making it leaves, is made again.
func (*Driver) ExecApp ¶
ExecApp runs a command in a running app container (ADR 0015). The process is the container's own process spec with other arguments, so it keeps the container's user, capabilities, no-new-privileges, seccomp profile, SELinux label, and namespaces.
func (*Driver) ListSandboxes ¶
ListSandboxes returns every sandbox whose namespace is pinned, with its address; one whose address is unknown is listed without, so that the agent removes or remakes it.
func (*Driver) Logs ¶
func (d *Driver) Logs(ctx context.Context, id string, opts runtime.LogOptions) (runtime.LogStream, error)
Logs returns the container's stored output.
func (*Driver) PruneImages ¶
func (d *Driver) PruneImages(ctx context.Context, keep []string, grace time.Duration) ([]string, error)
PruneImages removes images no container of this namespace uses (Armada's own containers included), that keep does not name, and that were neither pulled nor updated within grace. Images that share a digest with a kept or used image stay too: a tag and its digest name the same content.
func (*Driver) Pull ¶
func (d *Driver) Pull(ctx context.Context, image string, auth *runtime.RegistryAuth) (runtime.Image, error)
Pull fetches an image and returns its digest-pinned reference. A digest-pinned image already on the node is used without contacting the registry only when the same credentials, or none, fetched it before (pullLabel); otherwise the registry is asked once whether these credentials may read it, so an app cannot run another space's private image by naming its digest.
func (*Driver) ReleaseNetwork ¶
ReleaseNetwork frees the address of a stopped container kept for its logs. Its network namespace is the mark: once that is gone nothing is left to free, and Remove releasing again is harmless.
func (*Driver) Remove ¶
Remove kills and deletes a container with its network, files, and logs, and a replica's container with its init containers and sidecars first: they live in its network namespace.
func (*Driver) RemoveSandbox ¶
RemoveSandbox releases the sandbox's address and firewall rules and removes its namespace.
func (*Driver) SearchLogs ¶
func (d *Driver) SearchLogs(ctx context.Context, q runtime.LogQuery) ([]runtime.LogRecord, string, error)
SearchLogs searches the node's log history and live logs (ADR 0043).
func (*Driver) Stats ¶
Stats samples a container's cgroup (v2, which Armada requires) through its task's metrics. Memory is the cgroup's usage without inactive page cache, which the kernel reclaims before it kills anything.
A replica's container counts its init containers and sidecars too (ADR 0038): what it reserves covers them all.
type SELinuxState ¶
type SELinuxState int
SELinuxState is the SELinux support of a host.
const ( // SELinuxDisabled means SELinux is off; there is nothing to label. SELinuxDisabled SELinuxState = iota // SELinuxConfined means containers run as container_t with their own // categories. SELinuxConfined // SELinuxNoPolicy means SELinux is on but the policy has no container // types, so containers run with the runtime's own label. SELinuxNoPolicy )
func SELinux ¶
func SELinux() SELinuxState
SELinux reports whether containers can be confined by SELinux on this host.