nri

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(cfg *config.Config) (*local, error)

New creates an instance of the NRI interface with the given configuration.

func SetDomain

func SetDomain(d Domain)

SetDomain registers the domain with NRI.

Types

type API

type API interface {
	// IsEnabled returns true if the NRI interface is enabled and initialized.
	IsEnabled() bool

	// Start start the NRI interface, allowing external NRI plugins to
	// connect, register, and hook themselves into the lifecycle events
	// of pods and containers.
	Start() error

	// Stop stops the NRI interface.
	Stop()

	// RunPodSandbox relays pod creation events to NRI.
	RunPodSandbox(context.Context, PodSandbox) error

	// StopPodSandbox relays pod shutdown events to NRI.
	StopPodSandbox(context.Context, PodSandbox) error

	// RemovePodSandbox relays pod removal events to NRI.
	RemovePodSandbox(context.Context, PodSandbox) error

	// CreateContainer relays container creation requests to NRI.
	CreateContainer(context.Context, PodSandbox, Container) (*nri.ContainerAdjustment, error)

	// PostCreateContainer relays successful container creation events to NRI.
	PostCreateContainer(context.Context, PodSandbox, Container) error

	// StartContainer relays container start request notifications to NRI.
	StartContainer(context.Context, PodSandbox, Container) error

	// PostStartContainer relays successful container startup events to NRI.
	PostStartContainer(context.Context, PodSandbox, Container) error

	// UpdateContainer relays container update requests to NRI.
	UpdateContainer(context.Context, PodSandbox, Container, *nri.LinuxResources) (*nri.LinuxResources, error)

	// PostUpdateContainer relays successful container update events to NRI.
	PostUpdateContainer(context.Context, PodSandbox, Container) error

	// StopContainer relays container stop requests to NRI.
	StopContainer(context.Context, PodSandbox, Container) error

	// StopContainer relays container removal events to NRI.
	RemoveContainer(context.Context, PodSandbox, Container) error
}

API provides an API for interfacing NRI from the rest of cri-o. It is agnostic to the internal representation of pods and containers. A corresponding Domain interface provides the abstraction for those functions where such knowledge is necessary. server.Server registers this Domain interface for us.

Since we only deal with CRI pods and containers in cri-o, this split to two separate interfaces is artificial. The reason we have it is to keep the NRI adaptation structurally as close to other runtimes as possible, with the aim to lower the overall mental cost of maintaining the runtime adaptations.

type Container

type Container interface {
	GetDomain() string

	GetPodSandboxID() string
	GetID() string
	GetName() string
	GetState() nri.ContainerState
	GetLabels() map[string]string
	GetAnnotations() map[string]string
	GetArgs() []string
	GetEnv() []string
	GetMounts() []*nri.Mount
	GetHooks() *nri.Hooks
	GetLinuxContainer() LinuxContainer

	GetSpec() *specs.Spec
}

Container interface for interacting with NRI.

type Domain

type Domain interface {
	// GetName() returns the name of the domain.
	GetName() string

	// ListPodSandboxes list all pods.
	ListPodSandboxes() []PodSandbox

	// ListContainer list all containers.
	ListContainers() []Container

	// GetPodSandbox returns the pod for the given ID.
	GetPodSandbox(string) (PodSandbox, bool)

	// GetContainer returns the container for the given ID.
	GetContainer(string) (Container, bool)

	// UpdateContainer applies an NRI container update request.
	UpdateContainer(context.Context, *nri.ContainerUpdate) error

	// EvictContainer evicts the requested container.
	EvictContainer(context.Context, *nri.ContainerEviction) error
}

Domain implements the functions the generic NRI interface needs to deal with the internal implementation details of pods and containers.

type LinuxContainer

type LinuxContainer interface {
	GetLinuxNamespaces() []*nri.LinuxNamespace
	GetLinuxDevices() []*nri.LinuxDevice
	GetLinuxResources() *nri.LinuxResources
	GetOOMScoreAdj() *int
	GetCgroupsPath() string
}

type LinuxPodSandbox

type LinuxPodSandbox interface {
	GetLinuxNamespaces() []*nri.LinuxNamespace
	GetPodLinuxOverhead() *nri.LinuxResources
	GetPodLinuxResources() *nri.LinuxResources
	GetCgroupParent() string
	GetCgroupsPath() string
	GetLinuxResources() *nri.LinuxResources
}

type PodSandbox

type PodSandbox interface {
	GetDomain() string

	GetID() string
	GetName() string
	GetUID() string
	GetNamespace() string
	GetLabels() map[string]string
	GetAnnotations() map[string]string
	GetRuntimeHandler() string
	GetLinuxPodSandbox() LinuxPodSandbox

	GetPid() uint32
}

PodSandbox interface for interacting with NRI.

type State

type State int
const (
	Created State = iota + 1
	Running
	Stopped
	Removed
)

Jump to

Keyboard shortcuts

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