Documentation
¶
Overview ¶
Package embedded runs containers on Armada's own containerd instance (ADR 0011). Release builds carry containerd, runc, the CNI plugins, and tini in the binary; this file pins exactly which upstream artifacts.
Index ¶
- Constants
- Variables
- func Bundled() []byte
- func CheckHost() error
- func ContainerdConfig(p Paths) string
- func DefaultHistoryBytes(dir string) int64
- func DisableIPv6(link string) error
- func Exec(p Paths, pack []byte, binDir string) error
- func IPv6Off(link string) (bool, error)
- func InstalledPack(root string) string
- func LogPath(dir, id string) (string, error)
- func Pack(arch string, versions map[string]string, files map[string][]byte) ([]byte, error)
- func PackID(pack []byte) string
- func PruneLogs(dir string, retention time.Duration, maxBytes int64, now time.Time) error
- func ReadLogs(ctx context.Context, dir, id string, opts runtime.LogOptions) (runtime.LogStream, error)
- func RemoveLogs(dir, id string) error
- func SearchLogs(ctx context.Context, dir string, q runtime.LogQuery) ([]runtime.LogRecord, string, error)
- func TailLogs(ctx context.Context, dir, target string, maxBytes int64, now time.Time) (runtime.LogTail, error)
- func UseBinDir(root, dir string) error
- func WriteLogMeta(dir, id string, m LogMeta) error
- func WriteLogs(dir, id string, stdout, stderr io.Reader) error
- type Artifact
- type LogMeta
- type Manifest
- type Paths
- func (p Paths) Bin() string
- func (p Paths) Bundle() string
- func (p Paths) CNI() string
- func (p Paths) Config() string
- func (p Paths) Containers() string
- func (p Paths) FIFO() string
- func (p Paths) Logs() string
- func (p Paths) NetNS() string
- func (p Paths) Root() string
- func (p Paths) Sandboxes() string
- func (p Paths) Socket() string
- func (p Paths) State() string
Constants ¶
const ( BinContainerd = "containerd" BinShim = "containerd-shim-runc-v2" BinRunc = "runc" BinTini = "tini" // BinLogger is Armada's own log writer (logger/), built from source // rather than pinned here; packs without it use `armadad runtime-log`. BinLogger = "armada-log" // BinArmadaShim supervises containers without containerd (shim/, // ADR 0046), built from source like armada-log. BinArmadaShim = "armada-shim" DirCNI = "cni" )
Names of the bundled files the runtime uses.
const BridgeName = "armada0"
BridgeName is the per-node container bridge.
const ( // DefaultLogRetention is how long history is kept unless the cluster // says otherwise. DefaultLogRetention = 7 * 24 * time.Hour )
const Namespace = "armada"
Namespace is the containerd namespace holding Armada's containers.
Variables ¶
var DefaultSubnet = netip.MustParsePrefix("10.121.0.0/24")
DefaultSubnet is the container bridge subnet unless configured otherwise.
var Lock = []Artifact{ { Name: "containerd", Version: "2.4.2", URL: "https://github.com/containerd/containerd/releases/download/v2.4.2/containerd-static-2.4.2-linux-{arch}.tar.gz", SHA256: map[string]string{ "amd64": "da656542e754c699a0f438eab925e6ffdbd6346a4428e659f83dc058f04dcffe", "arm64": "37b84b9534533672528141b9d815f58621a2fe5deee2daa84317800255756689", }, Files: map[string]string{ "bin/containerd": "containerd", "bin/containerd-shim-runc-v2": "containerd-shim-runc-v2", }, }, { Name: "runc", Version: "1.5.2", URL: "https://github.com/opencontainers/runc/releases/download/v1.5.2/runc.{arch}", SHA256: map[string]string{ "amd64": "599f6f94ff8c5057241eff0d54c3c74f95c34935b6457b33fe545defc61e9488", "arm64": "d10ecae898361832a059be2089bab92d158aec54661b18ed7346ed79628b46b0", }, }, { Name: "cni-plugins", Version: "1.9.1", URL: "https://github.com/containernetworking/plugins/releases/download/v1.9.1/cni-plugins-linux-{arch}-v1.9.1.tgz", SHA256: map[string]string{ "amd64": "b98f74a0f8522f0a83867178729c1aa70f2158f90c45a2ca8fa791db1c76b303", "arm64": "56171987d3947707c3563db2f4001bccaf50fd63468611b9f3cbecb1375ee7ec", }, Files: map[string]string{ "./bridge": "cni/bridge", "./host-local": "cni/host-local", "./loopback": "cni/loopback", "./portmap": "cni/portmap", "./firewall": "cni/firewall", }, }, { Name: "tini", Version: "0.19.0", URL: "https://github.com/krallin/tini/releases/download/v0.19.0/tini-static-{arch}", SHA256: map[string]string{ "amd64": "c5b0666b4cb676901f90dfcb37106783c5fe2077b04590973b885950611b30ee", "arm64": "eae1d3aa50c48fb23b8cbdf4e369d0910dfc538566bfd09df89a774aa84a48b9", }, }, }
Lock lists every artifact in the bundle.
Functions ¶
func Bundled ¶
func Bundled() []byte
Bundled returns the pack compiled into this binary, or nil if it was built without the bundle tag.
func CheckHost ¶
func CheckHost() error
CheckHost verifies what the embedded runtime needs from the kernel.
func ContainerdConfig ¶
ContainerdConfig renders containerd's configuration (format 4): its own root, state, and socket, nothing imported from the host's /etc/containerd, no listeners besides the socket.
func DefaultHistoryBytes ¶
DefaultHistoryBytes is the history size when the cluster sets none: 10% of the file system holding dir, between 64 MiB and 5 GiB.
func DisableIPv6 ¶
DisableIPv6 turns IPv6 off on the bridge link. Containers get only IPv4 addresses, and the space isolation firewall filters only IPv4: with IPv6 on, the bridge would have a link-local address through which every container reaches the host's IPv6 listeners (T13). A kernel without IPv6 has nothing to turn off.
func Exec ¶
Exec prepares the bundle and configuration and replaces the current process with containerd, so systemd supervises containerd directly. pack is the embedded bundle; without one, binDir (development) must hold the binaries.
func InstalledPack ¶
InstalledPack returns the ID of the pack root/current points at ("dev" for development binaries, "" when none was installed yet).
func Pack ¶
Pack builds a pack (gzipped tar, manifest first) from files, which maps bundle names to their contents.
func PruneLogs ¶
PruneLogs removes history older than retention, then the oldest files until it holds at most maxBytes, and meta files of removed containers with no history left.
func ReadLogs ¶
func ReadLogs(ctx context.Context, dir, id string, opts runtime.LogOptions) (runtime.LogStream, error)
ReadLogs returns a container's stored output, oldest first; Tail keeps only the last lines, Follow keeps reading new output until the stream is closed or ctx ends.
func RemoveLogs ¶
RemoveLogs moves a removed container's log files into history, oldest first, or deletes them when it keeps none (ADR 0043).
func SearchLogs ¶
func SearchLogs(ctx context.Context, dir string, q runtime.LogQuery) ([]runtime.LogRecord, string, error)
SearchLogs searches the history and live logs of q.App's containers (ADR 0043): the newest q.Limit entries in the window, oldest first. Files are read newest first, so a search cut short by its budget keeps the latest output.
func TailLogs ¶
func TailLogs(ctx context.Context, dir, target string, maxBytes int64, now time.Time) (runtime.LogTail, error)
TailLogs reads the output of app containers written since the last committed tail for target, at most about maxBytes (ADR 0044). Containers created before target was first used start at the end of their output. When a container's file is gone (pruned while the destination was unreachable), it goes on from the time of the last entry sent.
func UseBinDir ¶
UseBinDir points root/current at binaries in dir instead of an extracted pack (development builds without the bundle tag).
func WriteLogMeta ¶
WriteLogMeta records whose container id is, so its output is kept in history when it rotates out or the container is removed.
Types ¶
type Artifact ¶
type Artifact struct {
Name string
Version string
// URL has {arch} replaced by amd64 or arm64.
URL string
SHA256 map[string]string // by arch
// Files maps a path inside the downloaded gzipped tar to its name in the
// bundle. An empty map means the download is the file itself, named
// Name.
Files map[string]string
}
Artifact is one upstream download that contributes files to the bundle.
When bumping a version: verify the upstream signature first (runc and tini publish GPG signatures; containerd and the CNI plugins publish checksums with the release), then record the SHA-256 here. The hash, not the URL, is what the bundle trusts.
type LogMeta ¶
type LogMeta struct {
App string `json:"app"`
Replica string `json:"replica"`
Revision string `json:"revision,omitempty"`
Container string `json:"container,omitempty"`
Created time.Time `json:"created"`
}
LogMeta says which container a log history belongs to.
type Manifest ¶
type Manifest struct {
Arch string `json:"arch"`
Versions map[string]string `json:"versions"`
Files map[string]string `json:"files"` // name -> sha256
}
Manifest describes a pack.
func Install ¶
Install extracts pack under root (created 0700) unless an identical, intact copy is there already, points root/current at it, and returns the directory holding the binaries (always root/current/bin, a stable path that keeps working across upgrades). Every file is checked against the pack's manifest on every call.
type Paths ¶
type Paths struct {
DataDir string // Armada's data directory, e.g. /var/lib/armada
RunDir string // e.g. /run/armada
}
Paths locates everything the embedded runtime keeps on disk.
func (Paths) CNI ¶
CNI holds IPAM state and the plugin cache; on tmpfs because network namespaces do not survive a reboot either.
func (Paths) Containers ¶
Containers holds per-container files (resolv.conf, hosts, hostname).
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Command mkbundle downloads the artifacts pinned in embedded.Lock, checks their SHA-256, and writes the runtime pack that release builds embed.
|
Command mkbundle downloads the artifacts pinned in embedded.Lock, checks their SHA-256, and writes the runtime pack that release builds embed. |