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
- func Info() api.KindInfo
- type Adapter
- func (a *Adapter) Apply(ctx context.Context, p api.BundlePlan) (api.BundleHandle, error)
- func (a *Adapter) ApplyEdge(context.Context, api.EdgePlan) error
- func (a *Adapter) Capabilities(ctx context.Context) (api.RuntimeCapabilities, error)
- func (a *Adapter) Capacity(ctx context.Context) (api.Capacity, error)
- func (a *Adapter) Category() api.Category
- func (a *Adapter) Configure(_ context.Context, raw json.RawMessage) error
- func (a *Adapter) CreateVolume(ctx context.Context, req api.VolumeRequest) (api.VolumeHandle, error)
- func (a *Adapter) Destroy(ctx context.Context, ref api.BundleRef, opts api.DestroyOptions) error
- func (a *Adapter) DestroyVolume(ctx context.Context, h api.VolumeHandle) error
- func (a *Adapter) EdgeVolumes(context.Context) ([]api.VolumeHandle, error)
- func (a *Adapter) Edges(context.Context) ([]string, error)
- func (a *Adapter) Exec(ctx context.Context, ref api.WorkloadRef, req api.ExecRequest) (api.ExecSession, error)
- func (a *Adapter) HasImage(context.Context, string) (bool, error)
- func (a *Adapter) HealthCheck(ctx context.Context) error
- func (a *Adapter) ImportImage(context.Context, io.Reader) (string, error)
- func (a *Adapter) InUse(ctx context.Context) (api.InUse, error)
- func (a *Adapter) Kind() string
- func (a *Adapter) LargestFitFor(ctx context.Context, bundleID string) (*api.Fit, error)
- func (a *Adapter) Logs(ctx context.Context, ref api.WorkloadRef, opts api.LogOptions) (io.ReadCloser, error)
- func (a *Adapter) Observe(ctx context.Context, ref api.BundleRef) (api.ObservedBundle, error)
- func (a *Adapter) ObserveEdge(context.Context, string) (api.EdgeState, error)
- func (a *Adapter) RemoveEdge(context.Context, string) error
- func (a *Adapter) RestoreVolume(ctx context.Context, h api.VolumeHandle, src io.Reader) error
- func (a *Adapter) Run(ctx context.Context, ref api.WorkloadRef, req api.RunRequest) error
- func (a *Adapter) SnapshotVolume(ctx context.Context, h api.VolumeHandle, dst io.Writer) error
- func (a *Adapter) Stop(ctx context.Context, ref api.BundleRef) error
- func (a *Adapter) Trial(ctx context.Context, req api.TrialRequest) (api.TrialResult, error)
- func (a *Adapter) Upstream(ctx context.Context, ref api.WorkloadRef, port int) (api.Upstream, error)
- func (a *Adapter) Usage(ctx context.Context, ref api.BundleRef) (api.BundleUsage, error)
- func (a *Adapter) WatchBundles(context.Context, func(api.BundleEvent)) error
- type Config
- type Credentials
Constants ¶
const Kind = "incus"
Kind is the adapter's kind string.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter runs each app in an Incus VM.
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) Capabilities ¶
Capabilities reports what this adapter can do (R-254).
func (*Adapter) Capacity ¶
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) Configure ¶
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 ¶
Destroy deletes the app's VM. Its volumes stay unless KeepVolumes is false (R-204).
func (*Adapter) DestroyVolume ¶
DestroyVolume deletes a volume, detaching it from a VM first: the VM stays, without that storage, until its next Apply.
func (*Adapter) EdgeVolumes ¶
func (*Adapter) Exec ¶
func (a *Adapter) Exec(ctx context.Context, ref api.WorkloadRef, req api.ExecRequest) (api.ExecSession, error)
func (*Adapter) HasImage ¶
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 ¶
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 (*Adapter) InUse ¶
InUse is what the running Pando VMs are using now, summed: memory as Incus reports it, CPU over one second.
func (*Adapter) LargestFitFor ¶
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 ¶
Observe reports what exists, and never starts or changes anything (R-148).
func (*Adapter) ObserveEdge ¶
func (*Adapter) RestoreVolume ¶
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) Run ¶ added in v0.17.0
func (a *Adapter) Run(ctx context.Context, ref api.WorkloadRef, req api.RunRequest) error
Run runs a command through the Docker adapter inside the app's VM (R-423). A stopped VM has nothing running in it, which Run reports as NotFound.
func (*Adapter) SnapshotVolume ¶
SnapshotVolume streams the volume's contents to dst as a tar archive.
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 ¶
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 ¶
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.
Source Files
¶
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. |