v1alpha1

package
v0.8.6-100-g47448999 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: BSD-3-Clause Imports: 13 Imported by: 1

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

View Source
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")
)
View Source
const DefaultProtocol = corev1.ProtocolTCP
View Source
const Version = "v1alpha1"

Variables

View Source
var SchemeGroupVersion = schema.GroupVersion{
	Group:   machine.GroupName,
	Version: Version,
}

Functions

func AddToScheme

func AddToScheme(scheme *runtime.Scheme) error

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) Create

func (client *MachineServiceHandler) Create(ctx context.Context, req *Machine) (*Machine, error)

Create implements MachineService

func (*MachineServiceHandler) Delete

func (client *MachineServiceHandler) Delete(ctx context.Context, req *Machine) (*Machine, error)

Delete implements MachineService

func (*MachineServiceHandler) Get

func (client *MachineServiceHandler) Get(ctx context.Context, req *Machine) (*Machine, error)

Get implements MachineService

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

func (*MachineServiceHandler) Pause

func (client *MachineServiceHandler) Pause(ctx context.Context, req *Machine) (*Machine, error)

Pause implements MachineService

func (*MachineServiceHandler) Start

func (client *MachineServiceHandler) Start(ctx context.Context, req *Machine) (*Machine, error)

Start implements MachineService

func (*MachineServiceHandler) Stop

func (client *MachineServiceHandler) Stop(ctx context.Context, req *Machine) (*Machine, error)

Stop implements MachineService

func (*MachineServiceHandler) Update

func (client *MachineServiceHandler) Update(ctx context.Context, req *Machine) (*Machine, error)

Update implements MachineService

func (*MachineServiceHandler) Watch

func (client *MachineServiceHandler) Watch(ctx context.Context, req *Machine) (chan *Machine, chan error, error)

Watch 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"`

	// Environment variables associated with this machine
	Env map[string]string `json:"env,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 MachineState

type MachineState string

MachineState indicates the state of the machine.

func (MachineState) String

func (ms MachineState) String() string

String implements fmt.Stringer

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.

Jump to

Keyboard shortcuts

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