Help us shape the future of Go! Take the 2026 Go Developer Survey

incus

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: AGPL-3.0 Imports: 35 Imported by: 0

Documentation

Overview

Package incus runs each app in its own Incus virtual machine (notes-incus-runtime.md).

The adapter owns the VM: its size, its one NIC and the ACL on it, its volumes, and where Incus placed it. Inside the VM, Podman runs the app's workloads, and the existing Docker adapter drives it through Podman's Docker-compatible API, reached through the Incus API rather than the network. Pando's proxy reaches a workload through the forwarding agent each VM runs (O-45), so nothing about the proxy or routing changes (R-023).

Like every adapter it does not authorize, audit or touch Pando's state (R-027). Which VM is which app's is recorded on the VM, in its user.pando.bundle key, and read back.

Index

Constants

View Source
const Kind = "incus"

Kind is the adapter's kind string.

Variables

This section is empty.

Functions

func Info

func Info() api.KindInfo

Info describes this kind of adapter for the forms that configure one (api.KindInfo, R-261).

Types

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

Adapter runs each app in an Incus VM.

func New

func New() *Adapter

New builds an unconfigured adapter.

func (*Adapter) Apply

func (a *Adapter) Apply(ctx context.Context, p api.BundlePlan) (api.BundleHandle, error)

Apply converges the app's VM, then what runs in it, toward the plan.

func (*Adapter) ApplyEdge

func (a *Adapter) ApplyEdge(context.Context, api.EdgePlan) error

func (*Adapter) Capabilities

func (a *Adapter) Capabilities(ctx context.Context) (api.RuntimeCapabilities, error)

Capabilities reports what this adapter can do (R-254).

func (*Adapter) Capacity

func (a *Adapter) Capacity(ctx context.Context) (api.Capacity, error)

Capacity is reported from Incus's own resources, never from the host (R-243): the members VMs may be placed on, their CPU threads and memory, and what the running instances the adapter can see are limited to.

func (*Adapter) Category

func (a *Adapter) Category() api.Category

func (*Adapter) Configure

func (a *Adapter) Configure(_ context.Context, raw json.RawMessage) error

Configure reads the settings and credentials and opens the Incus API. Over a unix socket nothing is contacted; a server that is down is reported by HealthCheck, not by refusing to configure.

func (*Adapter) CreateVolume

func (a *Adapter) CreateVolume(ctx context.Context, req api.VolumeRequest) (api.VolumeHandle, error)

func (*Adapter) Destroy

func (a *Adapter) Destroy(ctx context.Context, ref api.BundleRef, opts api.DestroyOptions) error

Destroy deletes the app's VM. Its volumes stay unless KeepVolumes is false (R-204).

func (*Adapter) DestroyVolume

func (a *Adapter) DestroyVolume(ctx context.Context, h api.VolumeHandle) error

DestroyVolume deletes a volume, detaching it from a VM first: the VM stays, without that storage, until its next Apply.

func (*Adapter) EdgeVolumes

func (a *Adapter) EdgeVolumes(context.Context) ([]api.VolumeHandle, error)

func (*Adapter) Edges

func (a *Adapter) Edges(context.Context) ([]string, error)

func (*Adapter) Exec

func (*Adapter) HasImage

func (a *Adapter) HasImage(context.Context, string) (bool, error)

ImportImage is not offered (ImageDelivery is registry only). HasImage is true: this runtime runs images from a registry, which is where they stay, and imports none of its own.

func (*Adapter) HealthCheck

func (a *Adapter) HealthCheck(ctx context.Context) error

HealthCheck asks Incus whether everything the adapter relies on is there. It changes nothing: the ACL and the guest image are made by Apply.

func (*Adapter) ImportImage

func (a *Adapter) ImportImage(context.Context, io.Reader) (string, error)

func (*Adapter) InUse

func (a *Adapter) InUse(ctx context.Context) (api.InUse, error)

InUse is what the running Pando VMs are using now, summed: memory as Incus reports it, CPU over one second.

func (*Adapter) Kind

func (a *Adapter) Kind() string

func (*Adapter) LargestFitFor

func (a *Adapter) LargestFitFor(ctx context.Context, bundleID string) (*api.Fit, error)

LargestFitFor is LargestFit, counting the bundle's own VM as free where it runs, so a redeploy that fits where it is is never refused (R-242).

func (*Adapter) Logs

func (a *Adapter) Logs(ctx context.Context, ref api.WorkloadRef, opts api.LogOptions) (io.ReadCloser, error)

func (*Adapter) Observe

func (a *Adapter) Observe(ctx context.Context, ref api.BundleRef) (api.ObservedBundle, error)

Observe reports what exists, and never starts or changes anything (R-148).

func (*Adapter) ObserveEdge

func (a *Adapter) ObserveEdge(context.Context, string) (api.EdgeState, error)

func (*Adapter) RemoveEdge

func (a *Adapter) RemoveEdge(context.Context, string) error

func (*Adapter) RestoreVolume

func (a *Adapter) RestoreVolume(ctx context.Context, h api.VolumeHandle, src io.Reader) error

RestoreVolume replaces the volume's contents with an archive.

Destructive by design, as on Docker: the volume is emptied first, because a restore merged into what was there matches neither the backup nor the previous state.

func (*Adapter) SnapshotVolume

func (a *Adapter) SnapshotVolume(ctx context.Context, h api.VolumeHandle, dst io.Writer) error

SnapshotVolume streams the volume's contents to dst as a tar archive.

func (*Adapter) Stop

func (a *Adapter) Stop(ctx context.Context, ref api.BundleRef) error

Stop stops the app's VM: a stopped app holds no CPU or memory (R-242).

func (*Adapter) Trial

func (a *Adapter) Trial(ctx context.Context, req api.TrialRequest) (api.TrialResult, error)

Trial runs in a throwaway VM, deleted afterwards, with the Docker adapter's Trial inside it (R-097): the trial is in the app's isolation class, and port and write observation work as on Docker.

func (*Adapter) Upstream

func (a *Adapter) Upstream(ctx context.Context, ref api.WorkloadRef, port int) (api.Upstream, error)

Upstream is the workload's address as the Docker adapter in its VM answers, dialed through that VM's agent (O-45, R-023). The proxy decides the request before it calls Dial; the agent only carries it.

Answered from memory when the VM's address is known: this runs on every proxied request.

func (*Adapter) Usage

func (a *Adapter) Usage(ctx context.Context, ref api.BundleRef) (api.BundleUsage, error)

Usage is the Docker adapter's reading inside the VM (R-245); the VM's own overhead is not an app's usage. A stopped VM's workloads use nothing.

func (*Adapter) WatchBundles

func (a *Adapter) WatchBundles(context.Context, func(api.BundleEvent)) error

WatchBundles is not offered (SupportsBundleEvents is false).

type Config

type Config struct {
	// Address is the Incus API: unix:///var/lib/incus/unix.socket, or
	// https://host:8443 with the tls_client credential.
	Address string `json:"address,omitempty"`

	// ServerCertificate is the Incus server's certificate as PEM, for an
	// https:// address. Not a secret; required, because an unverified server
	// would be handed the client certificate, which is root on the cluster.
	ServerCertificate string `json:"server_certificate,omitempty"`

	// Project is the Incus project everything the adapter makes is in.
	Project string `json:"project,omitempty"`

	// Network is the Incus network each VM's one NIC is on (R-026). It must
	// be routable from Pando's host: the proxy reaches each VM's agent on it.
	Network string `json:"network,omitempty"`

	// ProxySources are the addresses Pando's proxy connects from, as CIDRs
	// separated by commas or spaces. The only sources each VM admits.
	ProxySources string `json:"proxy_sources,omitempty"`

	// StoragePool is the pool for root disks and volumes. Empty is the
	// project's default profile's root pool.
	StoragePool string `json:"storage_pool,omitempty"`

	// Target pins every VM to one cluster member, or to a cluster group as
	// "@group". Empty leaves placement to Incus (R-256).
	Target string `json:"target,omitempty"`

	// Profiles are applied to each VM, comma-separated. Empty is none: a
	// default profile usually carries a NIC onto the LAN.
	Profiles string `json:"profiles,omitempty"`

	// AgentImage is the image of Pando each VM's forwarding agent and each
	// restricted app's egress gateway run. Required: a VM has no other way to
	// get Pando's binary.
	AgentImage string `json:"agent_image,omitempty"`

	// AgentPort is the port each VM's agent listens on. Zero is 7443.
	AgentPort int `json:"agent_port,omitempty"`

	// GuestImage is an Incus image alias or fingerprint to start VMs from,
	// instead of the one the adapter prepares. It must have Podman serving
	// its Docker-compatible API on /run/podman/podman.sock, and socat.
	GuestImage string `json:"guest_image,omitempty"`

	// RootSizeBytes is each VM's root disk. Zero is 20 GiB.
	RootSizeBytes int64 `json:"root_size_bytes,omitempty"`

	// VolumeSizeBytes is the size of each app volume, unless the app asks
	// for more. Zero is 10 GiB. Incus needs one where a project limits disk.
	VolumeSizeBytes int64 `json:"volume_size_bytes,omitempty"`

	// GuestOverheadBytes is the memory each VM has beyond its workloads'
	// limits, for the guest kernel, Podman and the agent. Zero is 512 MiB.
	GuestOverheadBytes int64 `json:"guest_overhead_bytes,omitempty"`

	// DefaultCPUs and DefaultMemoryBytes size a VM whose workloads set no
	// limits. Zero is 1 CPU and 1 GiB.
	DefaultCPUs        int   `json:"default_cpus,omitempty"`
	DefaultMemoryBytes int64 `json:"default_memory_bytes,omitempty"`

	// NetworkPool and NetworkBlockBits are the Docker adapter's settings of
	// the same names, applied inside every VM.
	NetworkPool      string `json:"network_pool,omitempty"`
	NetworkBlockBits int    `json:"network_block_bits,omitempty"`

	// TotalCPUMillis and TotalMemoryBytes cap the capacity reported, for an
	// operator giving Pando part of a cluster that runs other things.
	TotalCPUMillis   int   `json:"total_cpu_millis,omitempty"`
	TotalMemoryBytes int64 `json:"total_memory_bytes,omitempty"`

	// Credentials arrive from the encrypted adapter_credentials store and are
	// held in memory only (R-190).
	Credentials Credentials `json:"credentials"`
}

Config is the adapter's configuration (notes-incus-runtime.md, Settings).

type Credentials

type Credentials struct {
	// TLSClient is the client certificate and its key, as PEM, for an
	// https:// address.
	TLSClient string `json:"tls_client,omitempty"`

	// AgentAuthority is the agents' certificate authority, as from
	// `pando host-agent new-authority`.
	AgentAuthority string `json:"agent_authority"`
}

Credentials are the adapter's secrets.

Directories

Path Synopsis
Package incusapi is the part of the Incus REST API the Incus runtime uses: the types, with Incus's own JSON names, and a client for them.
Package incusapi is the part of the Incus REST API the Incus runtime uses: the types, with Incus's own JSON names, and a client for them.

Jump to

Keyboard shortcuts

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