generate

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: Apache-2.0 Imports: 9 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// UnlimitedPidsLimit indicates unlimited Linux PIDs limit.
	UnlimitedPidsLimit = -1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

type Generator struct {
	UnderlyingGenerator
	Config *rspec.Spec
	// 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 UnderlyingGenerator, 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) AddLinuxNetDevice added in v0.11.0

func (g *Generator) AddLinuxNetDevice(hostDev string, device *nri.LinuxNetDevice)

AddLinuxNetDevice adds a new Linux net device.

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) AdjustArgs added in v0.10.0

func (g *Generator) AdjustArgs(args []string)

AdjustArgs adjusts the process arguments 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) AdjustIOPriority added in v0.10.0

func (g *Generator) AdjustIOPriority(ioprio *nri.LinuxIOPriority)

AdjustIOPriority adjusts the IO priority of the container.

func (*Generator) AdjustLinuxNetDevices added in v0.11.0

func (g *Generator) AdjustLinuxNetDevices(devices map[string]*nri.LinuxNetDevice) error

AdjustLinuxNetDevices adjusts the linux net devices in the OCI Spec.

func (*Generator) AdjustLinuxScheduler added in v0.11.0

func (g *Generator) AdjustLinuxScheduler(sch *nri.LinuxScheduler)

AdjustLinuxScheduler adjusts linux scheduling policy parameters.

func (*Generator) AdjustMounts

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

AdjustMounts adjusts the mounts in the OCI Spec.

func (*Generator) AdjustNamespaces added in v0.10.0

func (g *Generator) AdjustNamespaces(namespaces []*nri.LinuxNamespace) error

AdjustNamespaces adds or replaces namespaces in the OCI Spec.

func (*Generator) AdjustOomScoreAdj added in v0.7.0

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) AdjustRdt added in v0.11.0

func (g *Generator) AdjustRdt(r *nri.LinuxRdt)

AdjustRdt adjusts the intelRdt object in the OCI Spec.

func (*Generator) AdjustRdtClass

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

AdjustRdtClass adjusts the RDT class in the OCI Spec.

func (*Generator) AdjustRdtClosID added in v0.11.0

func (g *Generator) AdjustRdtClosID(value *string)

AdjustRdtClosID adjusts the RDT CLOS id in the OCI Spec.

func (*Generator) AdjustRdtEnableMonitoring added in v0.11.0

func (g *Generator) AdjustRdtEnableMonitoring(value *bool)

AdjustRdtEnableMonitoring adjusts the RDT monitoring in the OCI Spec.

func (*Generator) AdjustRdtSchemata added in v0.11.0

func (g *Generator) AdjustRdtSchemata(value *[]string)

AdjustRdtSchemata adjusts the RDT schemata 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 added in v0.4.0

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

AdjustRlimits adjusts the (Linux) POSIX resource limits in the OCI Spec.

func (*Generator) AdjustSeccompPolicy added in v0.10.0

func (g *Generator) AdjustSeccompPolicy(policy *nri.LinuxSeccomp) error

AdjustSeccompPolicy adjusts the seccomp policy for the container, which may override kubelet's settings for the seccomp policy.

func (*Generator) AdjustSysctl added in v0.11.0

func (g *Generator) AdjustSysctl(sysctl map[string]string) error

AdjustSysctl adds, replaces, or removes the sysctl settings in the OCI Spec.

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 added in v0.7.0

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) RemoveLinuxNetDevice added in v0.11.0

func (g *Generator) RemoveLinuxNetDevice(hostDev string)

RemoveLinuxNetDevice removes a Linux net device.

func (*Generator) SetLinuxIntelRdt

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

SetLinuxIntelRdt sets RDT CLOS.

func (*Generator) SetLinuxIntelRdtClosID added in v0.11.0

func (g *Generator) SetLinuxIntelRdtClosID(closID string)

SetLinuxIntelRdtClosID sets g.Config.Linux.IntelRdt.ClosID

func (*Generator) SetLinuxIntelRdtEnableMonitoring added in v0.11.0

func (g *Generator) SetLinuxIntelRdtEnableMonitoring(value bool)

SetLinuxIntelRdtEnableMonitoring sets g.Config.Linux.IntelRdt.EnableMonitoring

func (*Generator) SetLinuxIntelRdtSchemata added in v0.11.0

func (g *Generator) SetLinuxIntelRdtSchemata(schemata []string)

SetLinuxIntelRdtSchemata sets g.Config.Linux.IntelRdt.Schemata

func (*Generator) SetLinuxResourcesBlockIO

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

SetLinuxResourcesBlockIO sets Block I/O settings.

func (*Generator) SetLinuxResourcesPidsLimit added in v0.11.0

func (g *Generator) SetLinuxResourcesPidsLimit(limit int64)

SetLinuxResourcesPidsLimit sets Linux PID limit. Starting with v1.3.0 opencontainers/runtime-spec switched the PID limit to *int64 from int64 with nil meaning "unlimited". We don't want to change our API types though, so instead we use a dedicated value for unlimited.

func (*Generator) SetProcessIOPriority added in v0.10.0

func (g *Generator) SetProcessIOPriority(ioprio *rspec.LinuxIOPriority)

SetProcessIOPriority sets the (Linux) IO priority of the container.

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 added in v0.7.0

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.

type UnderlyingGenerator added in v0.11.0

type UnderlyingGenerator interface {
	AddAnnotation(key, value string)
	AddDevice(device rspec.LinuxDevice)
	AddOrReplaceLinuxNamespace(ns string, path string) error
	AddPostStartHook(postStartHook rspec.Hook)
	AddPostStopHook(postStopHook rspec.Hook)
	AddPreStartHook(preStartHook rspec.Hook)
	AddProcessEnv(name, value string)
	AddLinuxResourcesDevice(allow bool, devType string, major, minor *int64, access string)
	AddLinuxResourcesHugepageLimit(pageSize string, limit uint64)
	AddLinuxResourcesUnified(key, val string)
	AddMount(mnt rspec.Mount)
	AddLinuxSysctl(key, value string)
	ClearMounts()
	ClearProcessEnv()
	Mounts() []rspec.Mount
	RemoveAnnotation(key string)
	RemoveDevice(path string)
	RemoveLinuxNamespace(ns string) error
	RemoveMount(dest string)
	RemoveLinuxSysctl(key string)
	SetProcessArgs(args []string)
	SetLinuxCgroupsPath(path string)
	SetLinuxResourcesCPUCpus(cpus string)
	SetLinuxResourcesCPUMems(mems string)
	SetLinuxResourcesCPUPeriod(period uint64)
	SetLinuxResourcesCPUQuota(quota int64)
	SetLinuxResourcesCPURealtimePeriod(period uint64)
	SetLinuxResourcesCPURealtimeRuntime(time int64)
	SetLinuxResourcesCPUShares(shares uint64)
	SetLinuxResourcesMemoryLimit(limit int64)
	SetLinuxResourcesMemorySwap(swap int64)
	SetLinuxRootPropagation(rp string) error
	SetProcessOOMScoreAdj(adj int)
	Spec() *rspec.Spec
}

UnderlyingGenerator is the interface for github.com/opencontainers/runtime-tools/generate.Generator.

Jump to

Keyboard shortcuts

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