runtime

package
v0.6.0-alpha.6 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2020 License: MPL-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package runtime defines interfaces for accessing runtime specific settings, and state.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrLocked indicates that the sequencer is currently locked, and processing
	// another sequence.
	ErrLocked = errors.New("locked")

	// ErrReboot indicates that a task is requesting a reboot.
	ErrReboot = errors.New("reboot")

	// ErrInvalidSequenceData indicates that the sequencer got data the wrong
	// data type for a sequence.
	ErrInvalidSequenceData = errors.New("invalid sequence data")

	// ErrUndefinedRuntime indicates that the sequencer's runtime is not defined.
	ErrUndefinedRuntime = errors.New("undefined runtime")
)

Functions

This section is empty.

Types

type APIServer

type APIServer interface {
	Image() string
	ExtraArgs() map[string]string
}

APIServer defines the requirements for a config that pertains to apiserver related options.

type AdminKubeconfig

type AdminKubeconfig interface {
	CertLifetime() time.Duration
}

AdminKubeconfig defines settings for admin kubeconfig.

type Bond

type Bond struct {
	Interfaces      []string `yaml:"interfaces"`
	ARPIPTarget     []string `yaml:"arpIPTarget"`
	Mode            string   `yaml:"mode"`
	HashPolicy      string   `yaml:"xmitHashPolicy"`
	LACPRate        string   `yaml:"lacpRate"`
	ADActorSystem   string   `yaml:"adActorSystem"`
	ARPValidate     string   `yaml:"arpValidate"`
	ARPAllTargets   string   `yaml:"arpAllTargets"`
	Primary         string   `yaml:"primary"`
	PrimaryReselect string   `yaml:"primaryReselect"`
	FailOverMac     string   `yaml:"failOverMac"`
	ADSelect        string   `yaml:"adSelect"`
	MIIMon          uint32   `yaml:"miimon"`
	UpDelay         uint32   `yaml:"updelay"`
	DownDelay       uint32   `yaml:"downdelay"`
	ARPInterval     uint32   `yaml:"arpInterval"`
	ResendIGMP      uint32   `yaml:"resendIgmp"`
	MinLinks        uint32   `yaml:"minLinks"`
	LPInterval      uint32   `yaml:"lpInterval"`
	PacketsPerSlave uint32   `yaml:"packetsPerSlave"`
	NumPeerNotif    uint8    `yaml:"numPeerNotif"`
	TLBDynamicLB    uint8    `yaml:"tlbDynamicLb"`
	AllSlavesActive uint8    `yaml:"allSlavesActive"`
	UseCarrier      bool     `yaml:"useCarrier"`
	ADActorSysPrio  uint16   `yaml:"adActorSysPrio"`
	ADUserPortKey   uint16   `yaml:"adUserPortKey"`
	PeerNotifyDelay uint32   `yaml:"peerNotifyDelay"`
}

Bond contains the various options for configuring a bonded interface.

type CNI

type CNI interface {
	Name() string
	URLs() []string
}

CNI defines the requirements for a config that pertains to Kubernetes cni.

type ClusterConfig

type ClusterConfig interface {
	Name() string
	APIServer() APIServer
	ControllerManager() ControllerManager
	Proxy() Proxy
	Scheduler() Scheduler
	Endpoint() *url.URL
	Token() Token
	CertSANs() []string
	SetCertSANs([]string)
	CA() *x509.PEMEncodedCertificateAndKey
	AESCBCEncryptionSecret() string
	Config(MachineType) (string, error)
	Etcd() Etcd
	Network() ClusterNetwork
	LocalAPIServerPort() int
	PodCheckpointer() PodCheckpointer
	CoreDNS() CoreDNS
	ExtraManifestURLs() []string
	ExtraManifestHeaderMap() map[string]string
	AdminKubeconfig() AdminKubeconfig
}

ClusterConfig defines the requirements for a config that pertains to cluster related options.

type ClusterNetwork

type ClusterNetwork interface {
	CNI() CNI
	PodCIDR() string
	ServiceCIDR() string
	DNSDomain() string
}

ClusterNetwork defines the requirements for a config that pertains to cluster network options.

type ClusterState

type ClusterState interface{}

ClusterState defines the cluster state.

type Configurator

type Configurator interface {
	Version() string
	Debug() bool
	Persist() bool
	Machine() MachineConfig
	Cluster() ClusterConfig
	Validate(Mode) error
	String() (string, error)
	Bytes() ([]byte, error)
}

Configurator defines the configuration interface.

type ConfiguratorBundle

type ConfiguratorBundle interface {
	Init() Configurator
	ControlPlane() Configurator
	Join() Configurator
	TalosConfig() *config.Config
}

ConfiguratorBundle defines the configuration bundle interface.

type Controller

type Controller interface {
	Runtime() Runtime
	Sequencer() Sequencer
	Run(Sequence, interface{}, ...ControllerOption) error
}

Controller represents the controller responsible for managing the execution of sequences.

type ControllerManager

type ControllerManager interface {
	Image() string
	ExtraArgs() map[string]string
}

ControllerManager defines the requirements for a config that pertains to controller manager related options.

type ControllerOption added in v0.6.0

type ControllerOption func(o *ControllerOptions) error

ControllerOption represents an option setter.

func WithForce added in v0.6.0

func WithForce() ControllerOption

WithForce sets the force option to true.

type ControllerOptions added in v0.6.0

type ControllerOptions struct {
	Force bool
}

ControllerOptions represents the options for a controller.

func DefaultControllerOptions added in v0.6.0

func DefaultControllerOptions() ControllerOptions

DefaultControllerOptions returns the default controller options.

type CoreDNS

type CoreDNS interface {
	Image() string
}

CoreDNS defines the requirements for a config that pertains to bootkube coredns options.

type Device

type Device struct {
	Interface string  `yaml:"interface"`
	CIDR      string  `yaml:"cidr"`
	Routes    []Route `yaml:"routes"`
	Bond      *Bond   `yaml:"bond"`
	Vlans     []*Vlan `yaml:"vlans"`
	MTU       int     `yaml:"mtu"`
	DHCP      bool    `yaml:"dhcp"`
	Ignore    bool    `yaml:"ignore"`
	Dummy     bool    `yaml:"dummy"`
}

Device represents a network interface.

type Disk

type Disk struct {
	Device     string      `yaml:"device,omitempty"`
	Partitions []Partition `yaml:"partitions,omitempty"`
}

Disk represents the options available for partitioning, formatting, and mounting extra disks.

type Env

type Env = map[string]string

Env represents a set of environment variables.

type Etcd

type Etcd interface {
	Image() string
	CA() *x509.PEMEncodedCertificateAndKey
	ExtraArgs() map[string]string
}

Etcd defines the requirements for a config that pertains to etcd related options.

type Event added in v0.6.0

type Event struct {
	TypeURL string
	ID      xid.ID
	Payload proto.Message
}

Event is what is sent on the wire.

func (*Event) ToMachineEvent added in v0.6.0

func (event *Event) ToMachineEvent() (*machine.Event, error)

ToMachineEvent serializes Event as proto message machine.Event.

type EventFatalSequencerError

type EventFatalSequencerError struct {
	Error    error
	Sequence Sequence
}

EventFatalSequencerError represents a fatal sequencer error.

type EventSequenceStart

type EventSequenceStart struct {
	Sequence Sequence
}

EventSequenceStart represents the sequence start event.

type EventStream

type EventStream interface {
	Watcher
	Publisher
}

EventStream defines the runtime event stream.

type ExtraHost

type ExtraHost struct {
	IP      string   `yaml:"ip"`
	Aliases []string `yaml:"aliases"`
}

ExtraHost represents a host entry in /etc/hosts.

type File

type File struct {
	Content     string      `yaml:"content"`
	Permissions os.FileMode `yaml:"permissions"`
	Path        string      `yaml:"path"`
	Op          string      `yaml:"op"`
}

File represents a file to write to disk.

type Install

type Install interface {
	Image() string
	Disk() string
	ExtraKernelArgs() []string
	Zero() bool
	Force() bool
	WithBootloader() bool
}

Install defines the requirements for a config that pertains to install related options.

type Kubelet

type Kubelet interface {
	Image() string
	ExtraArgs() map[string]string
	ExtraMounts() []specs.Mount
}

Kubelet defines the requirements for a config that pertains to kubelet related options.

type LogHandler added in v0.6.0

type LogHandler interface {
	Writer() (io.WriteCloser, error)
	Reader(opt ...LogOption) (io.ReadCloser, error)
}

LogHandler provides interface to access particular log file.

type LogOption added in v0.6.0

type LogOption func(*LogOptions) error

LogOption provides functional options for LogHandler.Reader.

func WithFollow added in v0.6.0

func WithFollow() LogOption

WithFollow enables follow mode for the logs.

func WithTailLines added in v0.6.0

func WithTailLines(lines int) LogOption

WithTailLines starts log reading from lines from the tail of the log.

type LogOptions added in v0.6.0

type LogOptions struct {
	Follow    bool
	TailLines *int
}

LogOptions for LogHandler.Reader.

type LoggingManager added in v0.6.0

type LoggingManager interface {
	ServiceLog(service string) LogHandler
}

LoggingManager provides unified interface to publish and consume logs.

type Machine

type Machine interface {
	State() MachineState
	Config() MachineConfig
}

Machine defines the runtime parameters.

type MachineConfig

type MachineConfig interface {
	Install() Install
	Security() Security
	Network() MachineNetwork
	Disks() []Disk
	Time() Time
	Env() Env
	Files() ([]File, error)
	Type() MachineType
	Kubelet() Kubelet
	Sysctls() map[string]string
	Registries() Registries
}

MachineConfig defines the requirements for a config that pertains to machine related options.

type MachineNetwork

type MachineNetwork interface {
	Hostname() string
	SetHostname(string)
	Resolvers() []string
	Devices() []Device
	ExtraHosts() []ExtraHost
}

MachineNetwork defines the requirements for a config that pertains to network related options.

type MachineState

type MachineState interface {
	Disk() *probe.ProbedBlockDevice
	Close() error
	Installed() bool
}

MachineState defines the machined state.

type MachineType

type MachineType int

MachineType represents a machine type.

const (
	// MachineTypeInit represents a bootstrap node.
	MachineTypeInit MachineType = iota
	// MachineTypeControlPlane represents a control plane node.
	MachineTypeControlPlane
	// MachineTypeJoin represents a worker node.
	MachineTypeJoin
)

func ParseMachineType

func ParseMachineType(t string) (MachineType, error)

ParseMachineType parses string constant as Type.

func (MachineType) String

func (t MachineType) String() string

String returns the string representation of Type.

type Mode

type Mode int

Mode is a runtime mode.

const (
	// ModeCloud is the cloud runtime mode.
	ModeCloud Mode = iota
	// ModeContainer is the container runtime mode.
	ModeContainer
	// ModeMetal is the metal runtime mode.
	ModeMetal
)

func ParseMode

func ParseMode(s string) (mod Mode, err error)

ParseMode returns a `Mode` that matches the specified string.

func (Mode) String

func (m Mode) String() string

String returns the string representation of a Mode.

type Partition

type Partition struct {
	Size       uint   `yaml:"size,omitempty"`
	MountPoint string `yaml:"mountpoint,omitempty"`
}

Partition represents the options for a device partition.

type Phase

type Phase struct {
	Name  string
	Tasks []TaskSetupFunc
}

Phase represents a collection of tasks to be performed concurrently.

type Platform

type Platform interface {
	Name() string
	Configuration() ([]byte, error)
	Hostname() ([]byte, error)
	Mode() Mode
	ExternalIPs() ([]net.IP, error)
	KernelArgs() procfs.Parameters
}

Platform defines the requirements for a platform.

type PodCheckpointer

type PodCheckpointer interface {
	Image() string
}

PodCheckpointer defines the requirements for a config that pertains to bootkube pod-checkpointer options.

type Proxy

type Proxy interface {
	Image() string

	// Mode indicates the proxy mode for kube-proxy.  By default, this is `iptables`.  Other options include `ipvs`.
	Mode() string

	// ExtraArgs describe an additional set of arguments to be supplied to the execution of `kube-proxy`
	ExtraArgs() map[string]string
}

Proxy defines the requirements for a config that pertains to the kube-proxy options.

type Publisher

type Publisher interface {
	Publish(proto.Message)
}

Publisher defines a runtime event publisher.

type Registries

type Registries interface {
	// Mirror config by registry host (first part of image reference).
	Mirrors() map[string]RegistryMirrorConfig
	// Registry config (auth, TLS) by hostname.
	Config() map[string]RegistryConfig
	// ExtraFiles generates TOML config for containerd CRI plugin.
	ExtraFiles() ([]File, error)
}

Registries defines the configuration for image fetching.

type RegistryAuthConfig

type RegistryAuthConfig struct {
	//   description: |
	//     Optional registry authentication.
	//     The meaning of each field is the same with the corresponding field in .docker/config.json.
	Username string `yaml:"username"`
	//   description: |
	//     Optional registry authentication.
	//     The meaning of each field is the same with the corresponding field in .docker/config.json.
	Password string `yaml:"password"`
	//   description: |
	//     Optional registry authentication.
	//     The meaning of each field is the same with the corresponding field in .docker/config.json.
	Auth string `yaml:"auth"`
	//   description: |
	//     Optional registry authentication.
	//     The meaning of each field is the same with the corresponding field in .docker/config.json.
	IdentityToken string `yaml:"identityToken"`
}

RegistryAuthConfig specifies authentication configuration for a registry.

type RegistryConfig

type RegistryConfig struct {
	TLS  *RegistryTLSConfig  `yaml:"tls,omitempty"`
	Auth *RegistryAuthConfig `yaml:"auth,omitempty"`
}

RegistryConfig specifies auth & TLS config per registry.

type RegistryMirrorConfig

type RegistryMirrorConfig struct {
	//   description: |
	//     List of endpoints (URLs) for registry mirrors to use.
	//     Endpoint configures HTTP/HTTPS access mode, host name,
	//     port and path (if path is not set, it defaults to `/v2`).
	Endpoints []string `yaml:"endpoints"`
}

RegistryMirrorConfig represents mirror configuration for a registry.

type RegistryTLSConfig

type RegistryTLSConfig struct {
	//   description: |
	//     Enable mutual TLS authentication with the registry.
	//     Client certificate and key should be base64-encoded.
	//   examples:
	//     - |
	//       clientIdentity:
	//         crt: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJIekNCMHF...
	//         key: LS0tLS1CRUdJTiBFRDI1NTE5IFBSSVZBVEUgS0VZLS0tLS0KTUM...
	ClientIdentity *x509.PEMEncodedCertificateAndKey `yaml:"clientIdentity,omitempty"`
	//   description: |
	//     CA registry certificate to add the list of trusted certificates.
	//     Certificate should be base64-encoded.
	CA []byte `yaml:"ca,omitempty"`
	//   description: |
	//     Skip TLS server certificate verification (not recommended).
	InsecureSkipVerify bool `yaml:"insecureSkipVerify,omitempty"`
}

RegistryTLSConfig specifies TLS config for HTTPS registries.

func (*RegistryTLSConfig) GetTLSConfig

func (cfg *RegistryTLSConfig) GetTLSConfig() (*tls.Config, error)

GetTLSConfig prepares TLS configuration for connection.

type Route

type Route struct {
	Network string `yaml:"network"`
	Gateway string `yaml:"gateway"`
}

Route represents a network route.

type Runtime

type Runtime interface {
	Config() Configurator
	SetConfig([]byte) error
	State() State
	Events() EventStream
	Logging() LoggingManager
}

Runtime defines the runtime parameters.

type Scheduler

type Scheduler interface {
	Image() string
	ExtraArgs() map[string]string
}

Scheduler defines the requirements for a config that pertains to scheduler related options.

type Security

type Security interface {
	CA() *x509.PEMEncodedCertificateAndKey
	Token() string
	CertSANs() []string
	SetCertSANs([]string)
}

Security defines the requirements for a config that pertains to security related options.

type Sequence

type Sequence int

Sequence represents a sequence type.

const (
	// SequenceBoot is the boot sequence.
	SequenceBoot Sequence = iota
	// SequenceBootstrap is the boot sequence.
	SequenceBootstrap
	// SequenceInitialize is the initialize sequence.
	SequenceInitialize
	// SequenceInstall is the install sequence.
	SequenceInstall
	// SequenceShutdown is the shutdown sequence.
	SequenceShutdown
	// SequenceUpgrade is the upgrade sequence.
	SequenceUpgrade
	// SequenceReset is the reset sequence.
	SequenceReset
	// SequenceReboot is the reboot sequence.
	SequenceReboot
	// SequenceRecover is the recover sequence.
	SequenceRecover
	// SequenceNoop is the noop sequence.
	SequenceNoop
)

func ParseSequence

func ParseSequence(s string) (seq Sequence, err error)

ParseSequence returns a `Sequence` that matches the specified string.

nolint: gocyclo

func (Sequence) String

func (s Sequence) String() string

String returns the string representation of a `Sequence`.

type Sequencer

type Sequencer interface {
	Boot(Runtime) []Phase
	Bootstrap(Runtime) []Phase
	Initialize(Runtime) []Phase
	Install(Runtime) []Phase
	Reboot(Runtime) []Phase
	Recover(Runtime, *machine.RecoverRequest) []Phase
	Reset(Runtime, *machine.ResetRequest) []Phase
	Shutdown(Runtime) []Phase
	Upgrade(Runtime, *machine.UpgradeRequest) []Phase
}

Sequencer describes the set of sequences required for the lifecycle management of the operating system.

type State

type State interface {
	Platform() Platform
	Machine() MachineState
	Cluster() ClusterState
}

State defines the state.

type TaskExecutionFunc

type TaskExecutionFunc func(context.Context, *log.Logger, Runtime) error

TaskExecutionFunc defines the function that a task will execute for a specific runtime mode.

type TaskSetupFunc

type TaskSetupFunc func(seq Sequence, data interface{}) (TaskExecutionFunc, string)

TaskSetupFunc defines the function that a task will execute for a specific runtime mode.

type Time

type Time interface {
	Servers() []string
}

Time defines the requirements for a config that pertains to time related options.

type Token

type Token interface {
	ID() string
	Secret() string
}

Token defines the requirements for a config that pertains to Kubernetes bootstrap token.

type Vlan

type Vlan struct {
	CIDR   string  `ỳaml:"cidr"`
	Routes []Route `yaml:"routes"`
	DHCP   bool    `yaml:"dhcp"`
	ID     uint16  `yaml:"vlanId"`
}

Vlan represents vlan settings for a device.

type WatchFunc

type WatchFunc func(<-chan Event)

WatchFunc defines the watcher callback function.

type WatchOptionFunc added in v0.6.0

type WatchOptionFunc func(opts *WatchOptions) error

WatchOptionFunc defines the options for the watcher.

func WithTailDuration added in v0.6.0

func WithTailDuration(dur time.Duration) WatchOptionFunc

WithTailDuration sets up Watcher to return events with timestamp >= (now - tailDuration).

func WithTailEvents added in v0.6.0

func WithTailEvents(number int) WatchOptionFunc

WithTailEvents sets up Watcher to return specified number of past events.

If number is negative, all the available past events are returned.

func WithTailID added in v0.6.0

func WithTailID(id xid.ID) WatchOptionFunc

WithTailID sets up Watcher to return events with ID > TailID.

type WatchOptions added in v0.6.0

type WatchOptions struct {
	// Return that many past events.
	//
	// If TailEvents is negative, return all the events available.
	TailEvents int
	// Start at ID > specified.
	TailID xid.ID
	// Start at timestamp Now() - TailDuration.
	TailDuration time.Duration
}

WatchOptions defines options for the watch call.

Only one of TailEvents, TailID or TailDuration should be non-zero.

type Watcher

type Watcher interface {
	Watch(WatchFunc, ...WatchOptionFunc) error
}

Watcher defines a runtime event watcher.

Directories

Path Synopsis
Package logging provides implementations of runtime.LoggingManager.
Package logging provides implementations of runtime.LoggingManager.
Package v1alpha1 implements a `Runtime`.
Package v1alpha1 implements a `Runtime`.

Jump to

Keyboard shortcuts

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