resource

package
v0.0.0-...-12e0a72 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PodResourcesPath is the path to the local endpoint serving the PodResources GRPC service.
	PodResourcesPath = "/var/lib/kubelet/pod-resources"
)

Variables

This section is empty.

Functions

func ComputePodRequest

func ComputePodRequest(pod v1.Pod) v1.ResourceList

func FromFrameworkToList

func FromFrameworkToList(r framework.Resource) v1.ResourceList

FromFrameworkToList converts the input scheduler framework.Resource to a core v1.ResourceList

func FromListToFramework

func FromListToFramework(r v1.ResourceList) framework.Resource

FromListToFramework converts the input core v1.ResourceList to a scheduler framework.Resource

func NewPodResourcesListerClient

func NewPodResourcesListerClient(timeout time.Duration, maxMsgSize int) (pdrv1.PodResourcesListerClient, error)

func Subtract

Subtract returns a new resource corresponding to the result of r1 - r2. The returned resource contains the union of the scalar resources of r1 and r2.

func SubtractNonNegative

func SubtractNonNegative(r1 framework.Resource, r2 framework.Resource) framework.Resource

SubtractNonNegative returns a new resource corresponding to the result of Max(0, r1 - r2). The returned resource contains the union of the scalar resources of r1 and r2.

func Sum

Sum returns a new resource corresponding to the result of Max(0, r1 - r2). The returned resource contains the union of the scalar resources of r1 and r2.

Types

type Calculator

type Calculator interface {
	ComputePodRequest(pod v1.Pod) v1.ResourceList
}

type Client

type Client interface {
	GetAllocatableDevices(ctx context.Context) ([]Device, error)
	GetUsedDevices(ctx context.Context) ([]Device, error)
}

func NewClient

func NewClient(lister pdrv1.PodResourcesListerClient) Client

type Device

type Device struct {
	// ResourceName is the name of the resource exposed to k8s
	// (e.g. nvidia.com/gpu, nvidia.com/mig-2g10gb, etc.)
	ResourceName v1.ResourceName
	// DeviceId is the actual ID of the underlying device
	// (e.g. ID of the GPU, ID of the MIG device, etc.)
	DeviceId string
	// Status represents the status of the k8s resource (e.g. free or used)
	Status Status
}

func (Device) IsFree

func (d Device) IsFree() bool

func (Device) IsNvidiaResource

func (d Device) IsNvidiaResource() bool

func (Device) IsUsed

func (d Device) IsUsed() bool

type Status

type Status string
const (
	StatusUsed    Status = "used"
	StatusFree    Status = "free"
	StatusUnknown Status = "unknown"
)

func ParseStatus

func ParseStatus(status string) (Status, error)

Jump to

Keyboard shortcuts

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