Documentation
¶
Overview ¶
Package vm runs microVMs on this node: the bridge they share, and one Firecracker process per instance.
Each VM runs in its own transient systemd unit (jokku-vm-<id>), not as a child of the jokku daemon, so restarting or updating jokku leaves apps running. The unit's output is the guest's serial console, so app logs land in the journal tagged with JOKKU_APP and JOKKU_PROCESS.
Index ¶
- Constants
- func CheckTCP(addr string) bool
- func HostDNS() []string
- type Host
- func (h *Host) Attached(ctx context.Context) (map[string]bool, error)
- func (h *Host) Available() error
- func (h *Host) CheckTCP(addr string) bool
- func (h *Host) CreateVolume(ctx context.Context, path string, sizeMB int) error
- func (h *Host) EnsureNetwork(ctx context.Context) error
- func (h *Host) GrowVolume(ctx context.Context, path string, sizeMB int) error
- func (h *Host) Remove(ctx context.Context, id string) error
- func (h *Host) Session(ctx context.Context, id string) (io.ReadWriteCloser, string, error)
- func (h *Host) Start(ctx context.Context, s Spec) error
- func (h *Host) Stop(ctx context.Context, id string, grace time.Duration) error
- func (h *Host) Units(ctx context.Context) (map[string]string, error)
- func (h *Host) Usage(ctx context.Context, ids []string) (map[string]Usage, error)
- type NoVMs
- func (n *NoVMs) Attached(context.Context) (map[string]bool, error)
- func (n *NoVMs) Available() error
- func (n *NoVMs) CheckTCP(string) bool
- func (n *NoVMs) CreateVolume(context.Context, string, int) error
- func (n *NoVMs) EnsureNetwork(ctx context.Context) error
- func (n *NoVMs) GrowVolume(context.Context, string, int) error
- func (n *NoVMs) Remove(context.Context, string) error
- func (n *NoVMs) Session(context.Context, string) (io.ReadWriteCloser, string, error)
- func (n *NoVMs) Start(context.Context, Spec) error
- func (n *NoVMs) Stop(context.Context, string, time.Duration) error
- func (n *NoVMs) Units(context.Context) (map[string]string, error)
- func (n *NoVMs) Usage(context.Context, []string) (map[string]Usage, error)
- type Spec
- type Usage
- type Volume
Constants ¶
const MaxVolumes = 16
MaxVolumes is how many volumes one instance can mount.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Host ¶
type Host struct {
DataDir string // /var/lib/jokku
Bridge string // jokku0
Gateway netip.Prefix // this node's address and subnet, e.g. 10.210.1.1/24
Cluster netip.Prefix // the whole cluster network, e.g. 10.210.0.0/16
}
Host manages the microVMs on this node.
func (*Host) CreateVolume ¶
CreateVolume makes an empty ext4 disk image of sizeMB, sparse so only what is written uses space. Unlike the scratch disk it has a journal: a volume must survive the VM or the host stopping abruptly.
func (*Host) EnsureNetwork ¶
EnsureNetwork creates the bridge VMs attach to, with NAT for outbound traffic. It is idempotent and runs at every daemon start.
func (*Host) GrowVolume ¶
GrowVolume enlarges a volume's disk image and its filesystem. The image must not be attached to a VM.
func (*Host) Remove ¶
Remove deletes a stopped instance's network device and files. Its volumes are kept.
func (*Host) Session ¶
Session connects to a running VM's guest agent, returning the connection and the token the guest expects.
func (*Host) Start ¶
Start boots an instance. A restarted instance keeps its writable layer, as a restarted container does.
func (*Host) Stop ¶
Stop asks the guest to shut down (SIGTERM to the app) and waits up to grace before stopping the VM outright.
func (*Host) Units ¶
Units returns the state of every VM unit on this node, keyed by instance ID: active, activating, deactivating, failed. Missing means not running.
func (*Host) Usage ¶
Usage reads CPU time and memory for running VMs in one systemctl call.
Memory is the anonymous memory of the VM's unit, not its MemoryCurrent: that also counts the host's page cache for the VM's disks (every block it reads or writes passes through it), which can be well over the VM's size and is the host's to reclaim, not the VM's.
type NoVMs ¶
type NoVMs struct {
Reason string // why apps don't run here
Device string // e.g. jokku0
Address netip.Prefix // the mesh address, in its subnet
}
NoVMs is the runtime of a node that runs no microVMs: an edge, which only routes traffic. Its one job is the node's mesh address, which sits on a dummy interface (where a VM host has its bridge) as the source of its traffic over the mesh.
type Spec ¶
type Spec struct {
ID string
App string
Process string // web.1
Artifact string // rootfs image
IP string
CPUs int
MemoryMB int
Volumes []Volume
Guest guest.Config
}
Spec is everything needed to boot one instance.