Documentation
¶
Index ¶
- func Listen(endpoint string) (net.Listener, error)
- func NewFrameReader(r io.Reader) *frameReader
- func NewFrameWriter(w io.Writer) *frameWriter
- type AuthParams
- type BuildParams
- type Client
- func (c *Client) Attach(_ context.Context, id string, out io.Writer) error
- func (c *Client) Close() error
- func (c *Client) DNSList(_ context.Context, network string) ([]DNSRecord, error)
- func (c *Client) DNSResolve(_ context.Context, name, network string) (DNSRecord, error)
- func (c *Client) DNSResolveAll(_ context.Context, name, network string) ([]DNSRecord, error)
- func (c *Client) DaemonVersion(_ context.Context) (string, error)
- func (c *Client) Get(_ context.Context, id string) (VMInfo, error)
- func (c *Client) ImageBuild(_ context.Context, p BuildParams, contextTar io.Reader) (ImageManifestResult, error)
- func (c *Client) ImageGet(_ context.Context, ref string) (ImageManifestResult, error)
- func (c *Client) ImageList(_ context.Context) ([]ImageManifestResult, error)
- func (c *Client) ImageRemove(_ context.Context, ref string) error
- func (c *Client) Inspect(_ context.Context, id string) (VMDetail, error)
- func (c *Client) Kill(_ context.Context, id string) error
- func (c *Client) List(_ context.Context) ([]VMInfo, error)
- func (c *Client) Logs(_ context.Context, id string) (LogsResponse, error)
- func (c *Client) NetworkAllocateIP(_ context.Context, networkName string) (string, error)
- func (c *Client) NetworkCreate(_ context.Context, name, subnet, driver string) (NetworkInfo, error)
- func (c *Client) NetworkGet(_ context.Context, name string) (NetworkInfo, error)
- func (c *Client) NetworkList(_ context.Context) ([]NetworkInfo, error)
- func (c *Client) NetworkReleaseIP(_ context.Context, networkName, ip string) error
- func (c *Client) NetworkRemove(_ context.Context, name string) error
- func (c *Client) NodeList(_ context.Context) (NodeListResponse, error)
- func (c *Client) Remove(_ context.Context, id string) error
- func (c *Client) Run(_ context.Context, p RunParams) (VMInfo, error)
- func (c *Client) ServiceGet(_ context.Context, name string) (ServiceInfoResult, error)
- func (c *Client) ServiceList(_ context.Context) ([]ServiceInfoResult, error)
- func (c *Client) ServiceRemove(_ context.Context, name string) error
- func (c *Client) ServiceRun(_ context.Context, p ServiceRunParams) (ServiceInfoResult, error)
- func (c *Client) ServiceScale(_ context.Context, name string, desiredReplicas int) (ServiceInfoResult, error)
- func (c *Client) ServiceUpdate(_ context.Context, name, image string, healthTimeout int) (ServiceInfoResult, error)
- func (c *Client) Shutdown(_ context.Context) error
- func (c *Client) Signal(_ context.Context, id, sig string) error
- func (c *Client) Stats(_ context.Context, id string) (VMStatsResponse, error)
- func (c *Client) Stop(_ context.Context, id string, force bool) error
- type DNSRecord
- type DNSResolveParams
- type HealthCheckSpec
- type IDParams
- type ImageManifestResult
- type LogsResponse
- type NetworkConnectParams
- type NetworkCreateParams
- type NetworkInfo
- type NodeListResponse
- type NodeRow
- type PortMapSpec
- type RPCError
- type Request
- type Response
- type RestartSpec
- type RunParams
- type ServiceInfoResult
- type ServiceRunParams
- type ServiceScaleParams
- type ServiceUpdateParams
- type SignalParams
- type StopParams
- type VMDetail
- type VMInfo
- type VMStatsResponse
- type VolumeMountSpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Listen ¶
Listen binds a net.Listener for the given endpoint, clearing a stale Unix socket file first. Used by the server to accept connections.
func NewFrameReader ¶
func NewFrameWriter ¶
Types ¶
type AuthParams ¶
type AuthParams struct {
Token string `json:"token"`
}
AuthParams is the payload of the Auth.Hello handshake. When the daemon is configured with a token, the first request on every connection must be Auth.Hello carrying the matching token before any other method is accepted.
type BuildParams ¶
type BuildParams struct {
Name string `json:"name"`
Tag string `json:"tag,omitempty"`
// Program is the guest path (within the context tar) of the main ELF
// binary. All other tar entries are treated as additional image files.
Program string `json:"program"`
// ProgramPath, when set, is the in-image guest path at which the program is
// placed and executed (e.g. "usr/local/postgresql/bin/postgres"). Empty runs
// the program flat at /program. Used by lang="raw" builds so binaries
// resolve their installation prefix and $ORIGIN-relative libraries.
ProgramPath string `json:"program_path,omitempty"`
Memory string `json:"memory,omitempty"`
CPUs int `json:"cpus,omitempty"`
Entrypoint string `json:"entrypoint,omitempty"`
Args []string `json:"args,omitempty"`
Env map[string]string `json:"env,omitempty"`
Port int `json:"port,omitempty"`
// Ports holds default host:guest port-publish specs (from [run] ports in
// unikernel.toml), baked into the image manifest for run-time inheritance.
Ports []string `json:"ports,omitempty"`
// DiskSize sets the minimum image size passed to mkfs (e.g. "512M", "1G").
// Use when the default content-based size leaves insufficient free space
// for runtime writes (e.g. database temp tablespaces, log files).
DiskSize string `json:"disk_size,omitempty"`
}
BuildParams are the parameters for Image.Build. Immediately after sending this request the client streams the build context — a tar archive of the program binary plus any package/source files — as length-prefixed frames terminated by a zero-length frame. The daemon unpacks it into its own Linux filesystem, runs mkfs there, and stores the resulting image in its store.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client connects to a jerboad server over a Unix socket or TCP.
func Dial ¶
Dial connects to the jerboad server at endpoint. The endpoint may carry a scheme (unix:// or tcp://); a bare value is treated as a Unix socket path. The auth token is read from the JERBOA_AUTH_TOKEN environment variable.
func DialWithToken ¶
DialWithToken connects like Dial and, when token is non-empty, performs the Auth.Hello handshake before returning. The same token is reused for any secondary connection the client opens (e.g. ImageBuild).
func (*Client) Attach ¶
Attach connects to a VM's serial console and streams output to stdout. It blocks until the VM stops or the connection is closed. This method takes over the connection for raw reading; do not use the client for other calls after Attach.
func (*Client) DNSResolve ¶
DNSResolve resolves a VM name to an IP address inside an optional network.
func (*Client) DNSResolveAll ¶
DNSResolveAll resolves all DNS records matching a name (round-robin).
func (*Client) DaemonVersion ¶
DaemonVersion returns the version string reported by the running daemon.
func (*Client) ImageBuild ¶
func (c *Client) ImageBuild(_ context.Context, p BuildParams, contextTar io.Reader) (ImageManifestResult, error)
ImageBuild sends an Image.Build request and streams the build context to the daemon, which assembles the disk image with mkfs on its own filesystem and stores it. contextTar is an uncompressed tar archive containing the program binary (at p.Program) plus any package or source files.
Build uses a dedicated connection (the daemon consumes the streamed context and closes that connection), leaving the client's persistent connection free for concurrent calls.
func (*Client) ImageList ¶
func (c *Client) ImageList(_ context.Context) ([]ImageManifestResult, error)
ImageList returns the images held in the daemon's store.
func (*Client) ImageRemove ¶
ImageRemove deletes a name:tag (or sha) reference from the daemon's store.
func (*Client) NetworkAllocateIP ¶
NetworkAllocateIP allocates an IP address from the network's subnet.
func (*Client) NetworkCreate ¶
NetworkCreate creates a new network.
func (*Client) NetworkGet ¶
NetworkGet returns a single network by name.
func (*Client) NetworkList ¶
func (c *Client) NetworkList(_ context.Context) ([]NetworkInfo, error)
NetworkList returns all networks.
func (*Client) NetworkReleaseIP ¶
NetworkReleaseIP releases an allocated IP address back to the network.
func (*Client) NetworkRemove ¶
NetworkRemove deletes a network by name.
func (*Client) NodeList ¶
func (c *Client) NodeList(_ context.Context) (NodeListResponse, error)
NodeList returns cluster member information.
func (*Client) ServiceGet ¶
ServiceGet returns a single service by name.
func (*Client) ServiceList ¶
func (c *Client) ServiceList(_ context.Context) ([]ServiceInfoResult, error)
ServiceList returns all services.
func (*Client) ServiceRemove ¶
ServiceRemove stops all replicas of a service and deletes it.
func (*Client) ServiceRun ¶
func (c *Client) ServiceRun(_ context.Context, p ServiceRunParams) (ServiceInfoResult, error)
ServiceRun creates and starts a service with the given parameters.
func (*Client) ServiceScale ¶
func (c *Client) ServiceScale(_ context.Context, name string, desiredReplicas int) (ServiceInfoResult, error)
ServiceScale adjusts the number of replicas for a service.
func (*Client) ServiceUpdate ¶
func (c *Client) ServiceUpdate(_ context.Context, name, image string, healthTimeout int) (ServiceInfoResult, error)
ServiceUpdate performs a rolling update of a service to a new image. healthTimeout is the maximum seconds to wait for new replicas to become healthy before removing old ones. Zero means no waiting.
type DNSRecord ¶
type DNSRecord struct {
Name string `json:"name"`
Network string `json:"network"`
IP string `json:"ip"`
VMID string `json:"vm_id"`
}
DNSRecord is the serialisable representation of an internal DNS record.
type DNSResolveParams ¶
type DNSResolveParams struct {
Name string `json:"name"`
Network string `json:"network,omitempty"`
}
DNSResolveParams are the parameters for DNS.Resolve.
type HealthCheckSpec ¶
type HealthCheckSpec struct {
Type string `json:"type"`
Port int `json:"port,omitempty"`
Path string `json:"path,omitempty"`
Interval int `json:"interval_seconds,omitempty"`
Timeout int `json:"timeout_seconds,omitempty"`
Retries int `json:"retries,omitempty"`
}
HealthCheckSpec is the wire representation of a health check configuration.
type IDParams ¶
type IDParams struct {
ID string `json:"id"`
}
IDParams carries a single VM identifier.
type ImageManifestResult ¶
type ImageManifestResult struct {
Name string `json:"name"`
Tag string `json:"tag"`
DiskDigest string `json:"disk_digest"`
DiskSize int64 `json:"disk_size"`
Created string `json:"created"`
}
ImageManifestResult is the wire representation of a built image manifest.
type LogsResponse ¶
LogsResponse carries the captured serial console output for a VM.
type NetworkConnectParams ¶
type NetworkConnectParams struct {
Network string `json:"network"`
VMID string `json:"vm_id"`
IP string `json:"ip,omitempty"`
}
NetworkConnectParams connects a VM to a network.
type NetworkCreateParams ¶
type NetworkCreateParams struct {
Name string `json:"name"`
Subnet string `json:"subnet,omitempty"`
Driver string `json:"driver,omitempty"`
}
NetworkCreateParams are the parameters for Network.Create.
type NetworkInfo ¶
type NetworkInfo struct {
Name string `json:"name"`
Driver string `json:"driver"`
Subnet string `json:"subnet"`
Gateway string `json:"gateway"`
Bridge string `json:"bridge"`
CreatedAt string `json:"created_at"`
}
NetworkInfo is the serialisable representation of a network.
type NodeListResponse ¶
type NodeListResponse struct {
Nodes []NodeRow `json:"nodes"`
}
NodeListResponse carries cluster member information.
type NodeRow ¶
type NodeRow struct {
ID string `json:"id"`
Addr string `json:"addr"`
Status string `json:"status"`
VMCount int `json:"vm_count"`
CPUCap int `json:"cpu_capacity"`
MemCap int64 `json:"mem_capacity_bytes"`
LastSeen string `json:"last_seen"`
}
NodeRow is the wire representation of a cluster member.
type PortMapSpec ¶
type PortMapSpec struct {
HostPort uint16 `json:"host_port"`
GuestPort uint16 `json:"guest_port"`
Protocol string `json:"protocol"`
}
PortMapSpec is the wire representation of a host-to-guest port mapping.
func ParsePortMap ¶
func ParsePortMap(s string) (PortMapSpec, error)
ParsePortMap parses a single "host:guest[/tcp|udp]" port spec. The protocol defaults to tcp.
func ParsePortMaps ¶
func ParsePortMaps(specs []string) ([]PortMapSpec, error)
ParsePortMaps parses a list of "host:guest[/tcp|udp]" specs into wire port maps. It is a client-side helper so the CLI can build RunParams without importing the daemon's vm package.
type Request ¶
type Request struct {
JSONRPC string `json:"jsonrpc"`
ID int64 `json:"id"`
Method string `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
}
Request is a JSON-RPC 2.0 request envelope.
type Response ¶
type Response struct {
JSONRPC string `json:"jsonrpc"`
ID int64 `json:"id"`
Result json.RawMessage `json:"result,omitempty"`
Error *RPCError `json:"error,omitempty"`
}
Response is a JSON-RPC 2.0 response envelope.
type RestartSpec ¶
type RestartSpec struct {
Policy string `json:"policy"`
MaxRetries int `json:"max_retries,omitempty"`
}
RestartSpec is the wire representation of a restart policy.
type RunParams ¶
type RunParams struct {
// Image is a name:tag (or sha) reference resolved against the daemon's
// image store. When set it takes precedence over ImagePath.
Image string `json:"image,omitempty"`
// ImagePath is a direct path to a bootable disk image on the daemon's
// filesystem. Used for file-based runs when Image is empty.
ImagePath string `json:"image_path"`
Memory string `json:"memory"`
CPUs int `json:"cpus"`
NetworkName string `json:"network_name,omitempty"`
PortMaps []PortMapSpec `json:"port_maps,omitempty"`
Env []string `json:"env,omitempty"`
Name string `json:"name,omitempty"`
AutoRemove bool `json:"auto_remove,omitempty"`
Volumes []VolumeMountSpec `json:"volumes,omitempty"`
Attach bool `json:"attach,omitempty"`
IPAddress string `json:"ip_address,omitempty"`
GatewayIP string `json:"gateway_ip,omitempty"`
BridgeName string `json:"bridge_name,omitempty"`
SubnetMask string `json:"subnet_mask,omitempty"`
HealthCheck *HealthCheckSpec `json:"health_check,omitempty"`
Restart *RestartSpec `json:"restart,omitempty"`
MemoryMax int64 `json:"memory_max,omitempty"`
DiskIOPS uint64 `json:"disk_iops,omitempty"`
DiskBPS int64 `json:"disk_bps,omitempty"`
}
RunParams are the parameters for the VM.Run method.
type ServiceInfoResult ¶
type ServiceInfoResult struct {
Name string `json:"name"`
Image string `json:"image"`
DesiredReplicas int `json:"desired_replicas"`
ReadyReplicas int `json:"ready_replicas"`
Strategy string `json:"strategy"`
Health string `json:"health"`
Env []string `json:"env,omitempty"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
ReplicaIDs []string `json:"replica_ids"`
}
ServiceInfoResult is the result for Service.Get and Service.List.
type ServiceRunParams ¶
type ServiceRunParams struct {
Name string `json:"name"`
Image string `json:"image"`
Replicas int `json:"replicas"`
Memory string `json:"memory,omitempty"`
CPUs int `json:"cpus,omitempty"`
Env []string `json:"env,omitempty"`
NetworkName string `json:"network_name,omitempty"`
PortMaps []PortMapSpec `json:"port_maps,omitempty"`
HealthCheck *HealthCheckSpec `json:"health_check,omitempty"`
Restart *RestartSpec `json:"restart,omitempty"`
Strategy string `json:"strategy,omitempty"`
HealthTimeout int `json:"health_timeout,omitempty"`
}
ServiceRunParams are the parameters for Service.Run.
type ServiceScaleParams ¶
type ServiceScaleParams struct {
Name string `json:"name"`
DesiredReplicas int `json:"desired_replicas"`
}
ServiceScaleParams are the parameters for Service.Scale.
type ServiceUpdateParams ¶
type ServiceUpdateParams struct {
Name string `json:"name"`
Image string `json:"image"`
HealthTimeout int `json:"health_timeout,omitempty"`
}
ServiceUpdateParams are the parameters for Service.Update (rolling update).
type SignalParams ¶
type SignalParams struct {
// ID is the VM identifier.
ID string `json:"id"`
// Signal is the signal name (e.g. "SIGTERM") or number string (e.g. "15").
Signal string `json:"signal"`
}
SignalParams are the parameters for VM.Signal.
type StopParams ¶
type StopParams struct {
// ID is the VM identifier.
ID string `json:"id"`
// Force skips graceful shutdown and sends SIGKILL immediately.
Force bool `json:"force,omitempty"`
}
StopParams are the parameters for VM.Stop.
type VMDetail ¶
type VMDetail struct {
ID string `json:"id"`
State string `json:"state"`
Image string `json:"image"`
Name string `json:"name,omitempty"`
Memory string `json:"memory"`
CPUs int `json:"cpus"`
Ports []PortMapSpec `json:"ports,omitempty"`
Env []string `json:"env,omitempty"`
Volumes []VolumeMountSpec `json:"volumes,omitempty"`
IPAddress string `json:"ip_address,omitempty"`
GatewayIP string `json:"gateway_ip,omitempty"`
CreatedAt string `json:"created_at"`
StartedAt *string `json:"started_at,omitempty"`
StoppedAt *string `json:"stopped_at,omitempty"`
DaemonRecovered bool `json:"daemon_recovered,omitempty"`
Health string `json:"health,omitempty"`
RestartCount int `json:"restart_count,omitempty"`
RestartPolicy string `json:"restart_policy,omitempty"`
DiskIOPS uint64 `json:"disk_iops,omitempty"`
DiskBPS int64 `json:"disk_bps,omitempty"`
}
VMDetail is the full serialisable representation of a VM.
type VMInfo ¶
type VMInfo struct {
ID string `json:"id"`
State string `json:"state"`
Image string `json:"image"`
Name string `json:"name,omitempty"`
Health string `json:"health,omitempty"`
}
VMInfo is the compact serialisable representation of a VM.
type VMStatsResponse ¶
type VMStatsResponse struct {
ID string `json:"id"`
State string `json:"state"`
CPUPct float64 `json:"cpu_pct"`
MemBytes int64 `json:"mem_bytes"`
DiskBytes int64 `json:"disk_bytes,omitempty"`
NetRxBytes int64 `json:"net_rx_bytes"`
NetTxBytes int64 `json:"net_tx_bytes"`
Timestamp string `json:"timestamp"`
Source string `json:"source"`
}
VMStatsResponse carries runtime resource usage for a VM.
type VolumeMountSpec ¶
type VolumeMountSpec struct {
DiskPath string `json:"disk_path"`
GuestPath string `json:"guest_path"`
ReadOnly bool `json:"read_only,omitempty"`
// Label is the volume's TFS filesystem label (its name). The daemon formats
// the volume with this label and injects "Label:GuestPath" into the guest's
// mount config (QEMU fw_cfg opt/uni/mounts or Firecracker boot args) so the
// kernel mounts the matching volume at GuestPath.
Label string `json:"label,omitempty"`
}
VolumeMountSpec is the wire representation of a volume mount.