Documentation ¶
Overview ¶
SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors. Licensed under the BSD-3-Clause License (the "License"). You may not use this file expect in compliance with the License.
SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors. Licensed under the BSD-3-Clause License (the "License"). You may not use this file expect in compliance with the License.
SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors. Licensed under the BSD-3-Clause License (the "License"). You may not use this file except in compliance with the License.
Index ¶
- Constants
- Variables
- func AddToScheme(scheme *runtime.Scheme) error
- func AddToSchemeWithGV(scheme *runtime.Scheme, schemeGroupVersion schema.GroupVersion) error
- type Machine
- type MachineList
- type MachinePort
- type MachinePorts
- type MachineService
- type MachineServiceHandler
- func (client *MachineServiceHandler) Create(ctx context.Context, req *Machine) (*Machine, error)
- func (client *MachineServiceHandler) Delete(ctx context.Context, req *Machine) (*Machine, error)
- func (client *MachineServiceHandler) Get(ctx context.Context, req *Machine) (*Machine, error)
- func (client *MachineServiceHandler) List(ctx context.Context, req *MachineList) (*MachineList, error)
- func (client *MachineServiceHandler) Logs(ctx context.Context, req *Machine) (chan string, chan error, error)
- func (client *MachineServiceHandler) Pause(ctx context.Context, req *Machine) (*Machine, error)
- func (client *MachineServiceHandler) Start(ctx context.Context, req *Machine) (*Machine, error)
- func (client *MachineServiceHandler) Stop(ctx context.Context, req *Machine) (*Machine, error)
- func (client *MachineServiceHandler) Update(ctx context.Context, req *Machine) (*Machine, error)
- func (client *MachineServiceHandler) Watch(ctx context.Context, req *Machine) (chan *Machine, chan error, error)
- type MachineSpec
- type MachineState
- type MachineStatus
Constants ¶
const ( MachineStateUnknown = MachineState("unknown") MachineStateCreated = MachineState("created") MachineStateFailed = MachineState("failed") MachineStateRestarting = MachineState("restarting") MachineStateRunning = MachineState("running") MachineStatePaused = MachineState("paused") MachineStateSuspended = MachineState("suspended") MachineStateExited = MachineState("exited") MachineStateErrored = MachineState("errored") )
const DefaultProtocol = corev1.ProtocolTCP
const Version = "v1alpha1"
Variables ¶
var SchemeGroupVersion = schema.GroupVersion{ Group: machine.GroupName, Version: Version, }
Functions ¶
func AddToScheme ¶
func AddToSchemeWithGV ¶
func AddToSchemeWithGV(scheme *runtime.Scheme, schemeGroupVersion schema.GroupVersion) error
Types ¶
type Machine ¶
type Machine = zip.Object[MachineSpec, MachineStatus]
Machine is the mutable API object that represents a machine instance.
type MachineList ¶
type MachineList = zip.ObjectList[MachineSpec, MachineStatus]
MachineList is the mutable API object that represents a list of machine instances.
type MachinePort ¶
type MachinePort struct { // If specified, this must be an IANA_SVC_NAME and unique within the host. // Each named port on the host must have a unique name. Name for the port that // can be referred to by services. Name string `json:"name,omitempty"` // Number of port to expose on the host. If specified, this must be a valid // port number, 0 < x < 65536. HostPort int32 `json:"hostPort,omitempty"` // Number of port to expose on the machine's IP address. This must be a valid // port number, 0 < x < 65536. MachinePort int32 `json:"machinePort"` // Protocol for port. Must be UDP or TCP. Defaults to "TCP". Protocol corev1.Protocol `json:"protocol,omitempty"` // What host IP to bind the external port to. HostIP string `json:"hostIP,omitempty"` // MAC address of the port. MacAddress string `json:"macAddress,omitempty"` }
MachinePort represents a network port in a single container.
func ParsePort ¶
func ParsePort(s string) ([]MachinePort, error)
ParsePort parses a string representation of a MachinePort and returns the instantiated structure. The input structure uses nerdctl's implementation which in itself follows the traditional "docker-like" syntax often used in a CLI-context with the `-p` flag.
type MachinePorts ¶
type MachinePorts []MachinePort
MachinePorts is a slice of MachinePort
func (MachinePorts) String ¶
func (ports MachinePorts) String() string
String implements fmt.Stringer and outputs MachinePorts in human-readable format.
type MachineService ¶
type MachineService interface { Create(context.Context, *Machine) (*Machine, error) Start(context.Context, *Machine) (*Machine, error) Pause(context.Context, *Machine) (*Machine, error) Stop(context.Context, *Machine) (*Machine, error) Update(context.Context, *Machine) (*Machine, error) Delete(context.Context, *Machine) (*Machine, error) Get(context.Context, *Machine) (*Machine, error) List(context.Context, *MachineList) (*MachineList, error) Watch(context.Context, *Machine) (chan *Machine, chan error, error) Logs(context.Context, *Machine) (chan string, chan error, error) }
MachineService is the interface of available methods which can be performed by an implementing machine platform driver.
func NewMachineServiceHandler ¶
func NewMachineServiceHandler(ctx context.Context, impl MachineService, opts ...zip.ClientOption) (MachineService, error)
NewMachineServiceHandler returns a service based on an inline API client which essentially wraps the specific call, enabling pre- and post- call hooks. This is useful for wrapping the command with decorators, for example, a cache, error handlers, etc. Simultaneously, it enables access to the service via inline code without having to make invocations to an external handler.
type MachineServiceHandler ¶
type MachineServiceHandler struct {
// contains filtered or unexported fields
}
MachineServiceHandler provides a Zip API Object Framework service for the machine.
func (*MachineServiceHandler) List ¶
func (client *MachineServiceHandler) List(ctx context.Context, req *MachineList) (*MachineList, error)
List implements MachineService
func (*MachineServiceHandler) Logs ¶
func (client *MachineServiceHandler) Logs(ctx context.Context, req *Machine) (chan string, chan error, error)
Logs implements MachineService
type MachineSpec ¶
type MachineSpec struct { // Architecture of the machine instance. Architecture string `json:"arch,omitempty"` // Platform of the machine instance. Platform string `json:"plat,omitempty"` // Kernel represents the Kernel string `json:"kernel,omitempty"` // Rootfs the fully-qualified path to the target root file system. This can // be device path, a mount-path, initramdisk. Rootfs string `json:"rootfs,omitempty"` // Kernel arguments are runtime arguments which are provided directly to the // kernel and not for the application. KernelArgs []string `json:"kernelArgs,omitempty"` // Application arguments are runtime arguments provided to the application and // not the kernel. ApplicationArgs []string `json:"args,omitempty"` // Ports lists the ports and their mappings Ports MachinePorts `json:"ports,omitempty"` // Networks associated with this machine. Networks []networkv1alpha1.NetworkSpec `json:"networks,omitempty"` // Volumes associated with this machine. Volumes []volumev1alpha1.Volume `json:"volumes,omitempty"` // Resources describes the compute resources (requests and limits) required by // this machine. Resources corev1.ResourceRequirements `json:"resources,omitempty"` // Emulation indicates whether to use VMM emulation. Emulation bool `json:"emulation,omitempty"` }
MachineSpec contains the desired behavior of the Machine.
type MachineStatus ¶
type MachineStatus struct { // State is the current state of the machine instance. State MachineState `json:"state"` // Pid of the machine instance (if applicable). Pid int32 `json:"pid,omitempty"` // The fully-qualified path to the kernel image of the machine instance. KernelPath string `json:"kernelPath,omitempty"` // The fully-qualified path to the initramfs file of the machine instance. InitrdPath string `json:"initrdPath,omitempty"` // ExitCode is the ... ExitCode int `json:"exitCode,omitempty"` // StartedAt represents when the machine was started. StartedAt time.Time `json:"startedAt,omitempty"` // ExitedAt represents when the machine fully shutdown ExitedAt time.Time `json:"exitedAt,omitempty"` // StateDir contains the path of the state of the machine. StateDir string `json:"stateDir,omitempty"` // LogFile is the in-host path to the log file of the machine. LogFile string `json:"logFile,omitempty"` // PlatformConfig is platform-specific attributes which are populated by the // underlying machine service implementation. PlatformConfig interface{} `json:"platformConfig,omitempty"` }
MachineStatus contains the complete status of the machine instance.