containerd

package
v0.1.0-alpha.41 Latest Latest
Warning

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

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

Documentation

Overview

Package containerd implements runtime.Driver on the containerd instance that Armada embeds (ADR 0011).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BridgeOf

func BridgeOf(subnet netip.Prefix) (runtime.Bridge, error)

BridgeOf returns the bridge network for subnet: the gateway is the subnet's first address.

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 New

func New(cfg Config) (*Driver, error)

New connects to the embedded containerd. It does not wait for it to be up; Ping does.

func (*Driver) AgentStart

func (d *Driver) AgentStart(context.Context) error

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) Bridge

func (d *Driver) Bridge(ctx context.Context) (runtime.Bridge, error)

Bridge reports the container network.

func (*Driver) CanMountVolumes

func (d *Driver) CanMountVolumes() bool

CanMountVolumes implements runtime volume support (ADR 0023).

func (*Driver) CanRunMembers

func (d *Driver) CanRunMembers() bool

CanRunMembers implements runtime support for init containers and sidecars (ADR 0038).

func (*Driver) Close

func (d *Driver) Close() error

Close releases the connection.

func (*Driver) DialContainer

func (d *Driver) DialContainer(ctx context.Context, id, network, address string) (net.Conn, error)

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

func (d *Driver) DialSandbox(ctx context.Context, id, network, address string) (net.Conn, error)

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

func (d *Driver) EnsureSandbox(ctx context.Context, id string) (runtime.Sandbox, error)

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) Exec

func (d *Driver) Exec(ctx context.Context, id string, cmd []string) (string, int, error)

Exec runs cmd in a running container and returns its combined output.

func (*Driver) ExecApp

func (d *Driver) ExecApp(ctx context.Context, id string, opts runtime.ExecOptions) (int, error)

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) Inspect

func (d *Driver) Inspect(ctx context.Context, id string) (runtime.Container, error)

Inspect returns one container's state.

func (*Driver) List

func (d *Driver) List(ctx context.Context, labels map[string]string) ([]runtime.Container, error)

List returns containers carrying all given labels.

func (*Driver) ListSandboxes

func (d *Driver) ListSandboxes(context.Context) ([]runtime.Sandbox, error)

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) Ping

func (d *Driver) Ping(ctx context.Context) error

Ping verifies containerd answers and the bridge exists.

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) PruneLogs

func (d *Driver) PruneLogs(_ context.Context, retention time.Duration, maxBytes int64) error

PruneLogs bounds the node's log history (ADR 0043).

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

func (d *Driver) ReleaseNetwork(ctx context.Context, id string) error

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

func (d *Driver) Remove(ctx context.Context, id string) error

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

func (d *Driver) RemoveSandbox(ctx context.Context, id string) error

RemoveSandbox releases the sandbox's address and firewall rules and removes its namespace.

func (*Driver) Run

func (d *Driver) Run(ctx context.Context, s runtime.ContainerSpec) (_ string, err error)

Run creates and starts an app container with Armada's security defaults.

func (*Driver) RunSystem

func (d *Driver) RunSystem(ctx context.Context, s runtime.SystemSpec) (_ string, err error)

RunSystem creates and starts an infrastructure container.

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) Signal

func (d *Driver) Signal(ctx context.Context, id, signal string) error

Signal sends a signal to the container's main process.

func (*Driver) Stats

func (d *Driver) Stats(ctx context.Context, id string) (runtime.Stats, error)

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.

func (*Driver) Stop

func (d *Driver) Stop(ctx context.Context, id string, grace time.Duration) error

Stop sends SIGTERM to the container's init and SIGKILL after grace. The stopped task is kept so its exit code stays visible until Remove. A replica's sidecars stop after its own container (ADR 0038), so a proxy or log shipper in front of it outlives it.

func (*Driver) TailLogs

func (d *Driver) TailLogs(ctx context.Context, target string, maxBytes int64) (runtime.LogTail, error)

TailLogs reads app output not yet sent to target (ADR 0044).

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.

Jump to

Keyboard shortcuts

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