package generate

import "github.com/containerd/nri/pkg/runtime-tools/generate"

Index

Types

type Generator

type Generator struct {
	*generate.Generator
	// contains filtered or unexported fields
}

Generator extends a stock runtime-tools Generator and extends it with a few functions for handling NRI container adjustment.

func SpecGenerator

func SpecGenerator(gg *generate.Generator, opts ...GeneratorOption) *Generator

SpecGenerator returns a wrapped OCI Spec Generator.

func (*Generator) AddCreateContainerHook

func (g *Generator) AddCreateContainerHook(hook rspec.Hook)

AddCreateContainerHook adds a hooks new CreateContainer hooks.

func (*Generator) AddCreateRuntimeHook

func (g *Generator) AddCreateRuntimeHook(hook rspec.Hook)

AddCreateRuntimeHook adds a hooks new CreateRuntime hooks.

func (*Generator) AddStartContainerHook

func (g *Generator) AddStartContainerHook(hook rspec.Hook)

AddStartContainerHook adds a hooks new StartContainer hooks.

func (*Generator) Adjust

func (g *Generator) Adjust(adjust *nri.ContainerAdjustment) error

Adjust adjusts all aspects of the OCI Spec that NRI knows/cares about.

func (*Generator) AdjustAnnotations

func (g *Generator) AdjustAnnotations(annotations map[string]string) error

AdjustAnnotations adjusts the annotations in the OCI Spec.

func (*Generator) AdjustBlockIOClass

func (g *Generator) AdjustBlockIOClass(blockIOClass *string) error

AdjustBlockIOClass adjusts the block I/O class in the OCI Spec.

func (*Generator) AdjustCgroupsPath

func (g *Generator) AdjustCgroupsPath(path string)

AdjustCgroupsPath adjusts the cgroup pseudofs path in the OCI Spec.

func (*Generator) AdjustDevices

func (g *Generator) AdjustDevices(devices []*nri.LinuxDevice)

AdjustDevices adjusts the (Linux) devices in the OCI Spec.

func (*Generator) AdjustEnv

func (g *Generator) AdjustEnv(env []*nri.KeyValue)

AdjustEnv adjusts the environment of the OCI Spec.

func (*Generator) AdjustHooks

func (g *Generator) AdjustHooks(hooks *nri.Hooks)

AdjustHooks adjusts the OCI hooks in the OCI Spec.

func (*Generator) AdjustMounts

func (g *Generator) AdjustMounts(mounts []*nri.Mount) error

AdjustMounts adjusts the mounts in the OCI Spec.

func (*Generator) AdjustOomScoreAdj

func (g *Generator) AdjustOomScoreAdj(score *nri.OptionalInt)

AdjustOomScoreAdj adjusts the kernel's Out-Of-Memory (OOM) killer score for the container. This may override kubelet's settings for OOM score.

func (*Generator) AdjustRdtClass

func (g *Generator) AdjustRdtClass(rdtClass *string) error

AdjustRdtClass adjusts the RDT class in the OCI Spec.

func (*Generator) AdjustResources

func (g *Generator) AdjustResources(r *nri.LinuxResources) error

AdjustResources adjusts the (Linux) resources in the OCI Spec.

func (*Generator) AdjustRlimits

func (g *Generator) AdjustRlimits(rlimits []*nri.POSIXRlimit) error

func (*Generator) ClearLinuxIntelRdt

func (g *Generator) ClearLinuxIntelRdt()

ClearLinuxIntelRdt clears RDT CLOS.

func (*Generator) ClearLinuxResourcesBlockIO

func (g *Generator) ClearLinuxResourcesBlockIO()

ClearLinuxResourcesBlockIO clears Block I/O settings.

func (*Generator) InjectCDIDevices

func (g *Generator) InjectCDIDevices(devices []*nri.CDIDevice) error

InjectCDIDevices injects the requested CDI devices into the OCI Spec. Devices are given by their fully qualified CDI device names. The actual device injection is done using a runtime-specific CDI injection function, set using the WithCDIDeviceInjector option.

func (*Generator) SetLinuxIntelRdt

func (g *Generator) SetLinuxIntelRdt(rdt *rspec.LinuxIntelRdt)

SetLinuxIntelRdt sets RDT CLOS.

func (*Generator) SetLinuxResourcesBlockIO

func (g *Generator) SetLinuxResourcesBlockIO(blockIO *rspec.LinuxBlockIO)

SetLinuxResourcesBlockIO sets Block I/O settings.

type GeneratorOption

type GeneratorOption func(*Generator)

GeneratorOption is an option for Generator().

func WithAnnotationFilter

func WithAnnotationFilter(fn func(map[string]string) (map[string]string, error)) GeneratorOption

WithAnnotationFilter provides an option for filtering or rejecting annotations.

func WithBlockIOResolver

func WithBlockIOResolver(fn func(string) (*rspec.LinuxBlockIO, error)) GeneratorOption

WithBlockIOResolver specifies a function for resolving Block I/O classes by name.

func WithCDIDeviceInjector

func WithCDIDeviceInjector(fn func(*rspec.Spec, []string) error) GeneratorOption

WithCDIDeviceInjector specifies a runtime-specific function to use for CDI device resolution and injection into an OCI Spec.

func WithLabelFilter

func WithLabelFilter(fn func(map[string]string) (map[string]string, error)) GeneratorOption

WithLabelFilter provides an option for filtering or rejecting labels.

func WithRdtResolver

func WithRdtResolver(fn func(string) (*rspec.LinuxIntelRdt, error)) GeneratorOption

WithRdtResolver specifies a function for resolving RDT classes by name.

func WithResourceChecker

func WithResourceChecker(fn func(*rspec.LinuxResources) error) GeneratorOption

WithResourceChecker specifies a function to perform final resource adjustment.

Source Files

generate.go helpers_linux.go

Version
v0.9.0 (latest)
Published
Dec 12, 2024
Platform
linux/amd64
Imports
9 packages
Last checked
2 months ago

Tools for package owners.