inventory

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 14 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package inventory holds the model of a GPU capable node: one flat type that every read-only command shares, built from node labels, node status and the GPU operator's pods.

The model is the contract between the commands that fill it (kubectl nv list and kubectl nv info) and the commands that read it (kubectl nv health, kubectl nv topology). It is deliberately flat and free of spec and status halves: nothing here is ever applied to a cluster, so the split would carry no meaning.

Build every value through NewGPUNode and NewGPUNodeList. That is not a convenience: the cli-runtime printers behind -o json, -o yaml and -o name read TypeMeta off the object and refuse one whose GroupVersionKind is empty, and they do it before any marshalling, so MarshalJSON stamping the envelope does not reach them. A GPUNode literal prints as an error at -o json. types_printer_test.go asserts both halves of that.

Two guarantees then hold on the wire, enforced by MarshalJSON rather than by the constructors, because a zero value still reaches encoding/json often enough:

  • The envelope is always stamped. A GPUNode marshals with the apiVersion and kind of pkg/output's contract whether or not TypeMeta was set.
  • Nothing is ever null. Every slice is an array and every map is an object, so a consumer can range or index without a null check first. The single documented exception is InitResult.ExitCode, where the alternative to an absent key is a null.

Nothing here carries omitempty, nested types included, with the one exception named above: the field set a reader sees is the same on every node, so a jq expression written against one node works against all of them and a consumer never has to tell "absent" from "empty".

Shaping cluster objects into this model is pkg/source's caller's job; this package defines the model, its deep copy and its JSON, and nothing else.

Index

Constants

View Source
const (
	// LabelProduct is the GFD device name, for instance "NVIDIA-T4". Under the
	// single MIG strategy GFD overrides it with the profile, for instance
	// "A100-SXM4-40GB-MIG-1g.5gb".
	LabelProduct = "nvidia.com/gpu.product"
	// LabelCount is how many devices GFD found.
	LabelCount = "nvidia.com/gpu.count"
	// LabelClique is the NVLink fabric clique, "<ClusterUUID>.<CliqueID>".
	LabelClique = "nvidia.com/gpu.clique"

	// LabelDriverVersionFull is the whole driver version in one label, which
	// is what GFD has written since k8s-device-plugin v0.15.0.
	LabelDriverVersionFull = "nvidia.com/cuda.driver-version.full"
	// LabelRuntimeVersionFull is the whole CUDA runtime version, from the same
	// release.
	LabelRuntimeVersionFull = "nvidia.com/cuda.runtime-version.full"

	// LabelDriverMajor, LabelDriverMinor and LabelDriverRev are the
	// deprecated driver version parts. GFD still writes them, and a cluster
	// running an older GPU Operator writes nothing else.
	LabelDriverMajor = "nvidia.com/cuda.driver.major"
	LabelDriverMinor = "nvidia.com/cuda.driver.minor"
	LabelDriverRev   = "nvidia.com/cuda.driver.rev"
	// LabelRuntimeMajor and LabelRuntimeMinor are the deprecated CUDA runtime
	// version parts.
	LabelRuntimeMajor = "nvidia.com/cuda.runtime.major"
	LabelRuntimeMinor = "nvidia.com/cuda.runtime.minor"

	// LabelMIGStrategy is "none", "single" or "mixed".
	LabelMIGStrategy = "nvidia.com/mig.strategy"
	// LabelMIGCapable is whether the hardware supports MIG at all.
	LabelMIGCapable = "nvidia.com/mig.capable"
	// LabelMIGConfig is the profile the mig-manager was asked to apply.
	LabelMIGConfig = "nvidia.com/mig.config"
	// LabelMIGConfigState is where the mig-manager got to with it.
	LabelMIGConfigState = "nvidia.com/mig.config.state"

	// LabelSharingStrategy is "none", "time-slicing" or "mps".
	LabelSharingStrategy = "nvidia.com/gpu.sharing-strategy"
	// LabelReplicas is how many times each physical GPU is advertised.
	LabelReplicas = "nvidia.com/gpu.replicas"

	// LabelUpgradeState is where the node is in a driver upgrade. The GPU
	// Operator builds the name from the driver it manages, and "gpu" is the
	// only driver it manages today.
	LabelUpgradeState = "nvidia.com/gpu-driver-upgrade-state"

	// TopologyFabricPrefix is the prefix of Topograph's fabric tier labels,
	// one per tier, with tier 0 closest to the node.
	TopologyFabricPrefix = "fabric.topograph.run/tier-"
	// TopologyAcceleratorDomain is Topograph's accelerator interconnect
	// locality.
	TopologyAcceleratorDomain = "accelerator.topograph.run/domain"
	// TopologyAcceleratorSubDomain is the optional level nested inside it.
	TopologyAcceleratorSubDomain = "accelerator.topograph.run/sub-domain"
)

The node labels this package reads. Every one of them is written by something outside kubectl-nv, and docs/labels.md records which component writes which and from which version, so that a name that moved is traced to the release it moved in rather than guessed at.

View Source
const (
	// ModeDevicePlugin means the node advertises the nvidia.com/gpu extended
	// resource and publishes no ResourceSlice.
	ModeDevicePlugin = "device-plugin"
	// ModeDRA means the node publishes a gpu.nvidia.com ResourceSlice and
	// advertises no extended resource.
	ModeDRA = "dra"
	// ModeBoth means the node does both, which is what a cluster migrating
	// from the device plugin to DRA looks like mid-flight.
	ModeBoth = "both"
	// ModeNone means the node carries a GPU hint label but advertises its
	// GPUs neither way: the operator has not finished with it, or it failed.
	ModeNone = "none"
)

How a node advertises its GPUs. A node can run the device plugin, DRA, both during a migration, or neither while the operator is still rolling out.

View Source
const (
	// ComponentDriver is the NVIDIA driver DaemonSet.
	ComponentDriver = "nvidia-driver-daemonset"
	// ComponentVGPUManager is the vGPU manager DaemonSet, which takes the
	// driver's place on a vGPU host.
	ComponentVGPUManager = "nvidia-vgpu-manager-daemonset"
	// ComponentContainerToolkit is the container toolkit DaemonSet.
	ComponentContainerToolkit = "nvidia-container-toolkit-daemonset"
	// ComponentDevicePlugin is the device plugin DaemonSet.
	ComponentDevicePlugin = "nvidia-device-plugin-daemonset"
	// ComponentGFD is GPU feature discovery, which writes the nvidia.com/gpu.*
	// labels this package reads almost everything from.
	ComponentGFD = "gpu-feature-discovery"
	// ComponentDCGM is the DCGM host engine.
	ComponentDCGM = "nvidia-dcgm"
	// ComponentDCGMExporter is the DCGM Prometheus exporter.
	ComponentDCGMExporter = "nvidia-dcgm-exporter"
	// ComponentOperatorValidator is the validator, whose verdict is carried in
	// its init container exit codes rather than in its logs. See InitResult.
	ComponentOperatorValidator = "nvidia-operator-validator"
	// ComponentMIGManager is the mig-manager, which applies nvidia.com/mig.config
	// and reports through nvidia.com/mig.config.state.
	ComponentMIGManager = "nvidia-mig-manager"
	// ComponentNodeStatusExporter is the node status exporter.
	ComponentNodeStatusExporter = "nvidia-node-status-exporter"
	// ComponentOperator is the GPU Operator controller itself. It is not a
	// per-node operand, but it carries the same label and a node scoped report
	// that found it still has to name it.
	ComponentOperator = "gpu-operator"
	// ComponentDRADriver is the NVIDIA DRA driver's kubelet plugin, which is
	// what publishes a node's gpu.nvidia.com ResourceSlices. A node whose
	// kubelet plugin is not running advertises nothing under DRA however
	// healthy every GPU Operator pod on it looks.
	//
	// The value is the verbatim "app" label the GPU Operator gives the pod
	// (manifests/state-dra-driver/0500_daemonset.yaml at gpu-operator
	// 9eddbaa42). The standalone charts label the same pod by component
	// instead and carry no "app" key at all; pkg/inventory maps those onto
	// this one value so that a rule matching on the component does not have to
	// know which chart installed the driver.
	ComponentDRADriver = "nvidia-dra-driver-kubelet-plugin"
	// ComponentIMEXDaemon is the DRA driver's IMEX daemon, which a
	// ComputeDomain is served by.
	//
	// This one is not an "app" label value, because that pod has none: the
	// upstream template labels it only with resource.nvidia.com/computeDomain
	// (templates/compute-domain-daemon.tmpl.yaml at nvidia-dra-driver-gpu
	// fb8b96747). The value here is the upstream template's own name for the
	// workload, which is what a reader would look for in the namespace.
	ComponentIMEXDaemon = "compute-domain-daemon"
)

The operand vocabulary.

Two different strings name the same operand and they are easy to confuse:

the component: the verbatim value of the "app" label on the operand's
pods, which is what OperandPod.Component holds and what a rule matches on.
"nvidia-driver-daemonset".

the deploy key: the suffix of the nvidia.com/gpu.deploy.<key> node label
the operator gates that operand on. "driver".

They are not derivable from each other: the driver is "driver" and "nvidia-driver-daemonset", while GFD is "gpu-feature-discovery" both times. A command that reported one where the other belongs would be presenting two vocabularies as one, so both are written out here and ComponentForDeployKey is the only bridge between them.

The constants are the values observed in this repository's own fixtures and collection code (pkg/mustgather's driver pod selectors, pkg/source/testdata, NOTES.md's record of the Mokka lane) together with the operands the GPU Operator and the NVIDIA DRA driver publish. The list is not a closed set: OperandPod.Component carries whatever the label said, so an operand nothing here names still reaches a reader under its own name.

View Source
const DeployLabelPrefix = "nvidia.com/gpu.deploy."

DeployLabelPrefix is the prefix of the per-operand gating labels the GPU Operator writes on a node: nvidia.com/gpu.deploy.<key>.

View Source
const (

	// LabelComputeDomain is the only label the DRA driver's IMEX daemon pod
	// carries: the upstream template labels it with the compute domain UUID
	// and with nothing else, no "app" key of any kind
	// (templates/compute-domain-daemon.tmpl.yaml, and the key itself at
	// cmd/compute-domain-daemon/common.go:32, nvidia-dra-driver-gpu
	// fb8b96747). Only the key is matched; the value is a UUID.
	LabelComputeDomain = "resource.nvidia.com/computeDomain"
)

Variables

This section is empty.

Functions

func ComponentForDeployKey

func ComponentForDeployKey(key string) (string, bool)

ComponentForDeployKey returns the component a nvidia.com/gpu.deploy.<key> label gates. key is the suffix alone, not the whole label name: a caller reading a node's labels strips DeployLabelPrefix first, and passing the full label here is a mistake that has to be visible rather than a lookup that quietly misses.

func Components

func Components() []string

Components returns the operand components this package names, as a fresh slice so that a caller may sort or truncate it.

func DeployKeys

func DeployKeys() []string

DeployKeys returns the deploy label keys this package maps, sorted, as a fresh slice.

func DeployLabel

func DeployLabel(key string) string

DeployLabel returns the full node label name for a deploy key.

func PodSpecGPURequest

func PodSpecGPURequest(spec *corev1.PodSpec) int64

PodSpecGPURequest is the number of GPUs one pod asks the scheduler for, by the scheduler's own rule.

It takes a PodSpec rather than a Pod so that a caller holding a pod template can use it: a Job's spec.template.spec is a PodSpec, and the question "how many GPUs will each of this Job's pods need" has to be answered before any of those pods exist. The node inventory and that question then come out of one rule rather than two that agree until one of them is edited.

The rule:

  • The containers run together, so their requests add up.
  • The init containers run one at a time and before the containers, so only the largest of them counts, and it counts against the container sum rather than on top of it.
  • A restartable init container, that is, a sidecar, is the exception. It keeps running once it has started, so it is held for the whole life of the pod: it adds to the container sum, and it also adds to every init container that starts after it, because those two do run at once.

Two resource names are counted and summed, nvidia.com/gpu and nvidia.com/gpu.shared, because under renameByDefault the second is the only name a workload can ask for. A request written as a limit alone counts as that limit. A MIG profile does not count: it is a different unit.

What this cannot do is decide whether the pod still holds those GPUs. A PodSpec carries no status, so the phase filter belongs to the caller; requestedByNode applies it for the node inventory.

This is k8s.io/component-helpers' PodRequests narrowed to these resources. Reimplementing it rather than vendoring that package keeps the rule visible next to the tests that pin it; getting it wrong is how a half full node reads as a full one.

Types

type BuildOptions

type BuildOptions struct {
	// Node narrows the result to one node, by name. It reaches the hinted
	// nodes too: the node a user names is most often the one that went quiet.
	Node string
	// Selector is a label selector the nodes have to match.
	Selector string
	// NoPods skips the pod listing. Requested is then not computed and every
	// node says so through RequestedKnown, and no operands are reported,
	// because both come out of that one read.
	NoPods bool
	// IncludeHinted keeps the nodes that carry a GPU hint label and advertise
	// no GPUs. They are out of the list by default, because on most clusters
	// they are a control plane that node-feature-discovery labelled.
	IncludeHinted bool
	// WithDetails fills the fields kubectl nv info shows and kubectl nv list does not: the
	// node conditions and the names of its ResourceSlices.
	WithDetails bool
}

BuildOptions is what a command asks the builder for.

type GPUNode

type GPUNode struct {
	metav1.TypeMeta `json:",inline" yaml:",inline"`
	// ObjectMeta is the apimachinery type so that the cli-runtime printers can
	// reach the name through meta.Accessor.
	metav1.ObjectMeta `json:"metadata,omitzero" yaml:"metadata,omitempty"`

	// Product is nvidia.com/gpu.product, the GFD device name, for instance
	// "NVIDIA-H100-80GB-HBM3".
	Product string `json:"product" yaml:"product"`
	// Count is nvidia.com/gpu.count, how many devices GFD found. It is 0 when
	// the label is absent, which is not the same as a node with no GPUs: a
	// node can have GPUs and no GFD.
	Count int `json:"count" yaml:"count"`

	// Capacity is the nvidia.com/gpu capacity the node advertises. It is zero
	// on a node running MIG in the mixed strategy, which advertises one
	// resource per profile instead; MIG.Resources carries those.
	Capacity int64 `json:"capacity" yaml:"capacity"`
	// Allocatable is the nvidia.com/gpu allocatable.
	Allocatable int64 `json:"allocatable" yaml:"allocatable"`
	// Requested is the nvidia.com/gpu summed over the pods scheduled on the
	// node. It is 0 and meaningless unless RequestedKnown is set.
	Requested int64 `json:"requested" yaml:"requested"`
	// RequestedKnown is whether Requested was computed. It is false under
	// --no-pods, which skips the pod listing; reporting 0 requested GPUs for a
	// busy node because nobody looked would be worse than reporting nothing.
	RequestedKnown bool `json:"requestedKnown" yaml:"requestedKnown"`

	// DriverVersion is the NVIDIA driver version GFD reports.
	DriverVersion string `json:"driverVersion" yaml:"driverVersion"`
	// CUDAVersion is the CUDA version GFD reports.
	CUDAVersion string `json:"cudaVersion" yaml:"cudaVersion"`

	// Mode is how the node advertises its GPUs: one of ModeDevicePlugin,
	// ModeDRA, ModeBoth or ModeNone.
	Mode string `json:"mode" yaml:"mode"`

	// MIG is the node's Multi-Instance GPU configuration.
	MIG MIG `json:"mig" yaml:"mig"`
	// Sharing is how the node shares each GPU between pods.
	Sharing Sharing `json:"sharing" yaml:"sharing"`

	// UpgradeState is nvidia.com/gpu-driver-upgrade-state, where the node is
	// in a driver upgrade: "upgrade-done", "cordon-required" and so on.
	UpgradeState string `json:"upgradeState" yaml:"upgradeState"`
	// Deploy holds the nvidia.com/gpu.deploy.<operand> labels, keyed by the
	// operand: "driver", "container-toolkit", "device-plugin". The operator
	// gates each operand on its own label, so this is what says why an operand
	// is not running on a node.
	Deploy map[string]string `json:"deploy" yaml:"deploy"`
	// Clique is nvidia.com/gpu.clique, the NVLink or IMEX clique the node's
	// GPUs belong to.
	Clique string `json:"clique" yaml:"clique"`
	// Topology holds every fabric.topograph.run/tier-* label and
	// accelerator.topograph.run/domain, keyed by the full label name. Track G
	// builds the fabric tree out of it, so the keys are kept verbatim rather
	// than parsed into tiers here.
	Topology map[string]string `json:"topology" yaml:"topology"`

	// Ready is whether the node's Ready condition is True.
	Ready bool `json:"ready" yaml:"ready"`
	// Unschedulable is spec.unschedulable, that is, whether it is cordoned.
	Unschedulable bool `json:"unschedulable" yaml:"unschedulable"`
	// Taints are the node's taints, which is how a GPU node that nothing can
	// land on explains itself.
	Taints []corev1.Taint `json:"taints" yaml:"taints"`
	// Conditions are the node conditions. kubectl nv info and kubectl nv
	// health both fill them, the latter because NV-NODE-005 reads them;
	// kubectl nv list leaves them empty, because a list of nodes with every
	// condition on each one is not a list anyone reads.
	Conditions []corev1.NodeCondition `json:"conditions" yaml:"conditions"`

	// Operands are the GPU Operator's pods running on the node, plus the
	// NVIDIA DRA driver's kubelet-plugin and IMEX daemon pods on it. The DRA
	// pods are operands in every sense that matters to a reader: they are what
	// makes the node's GPUs allocatable under DRA, and a node whose
	// kubelet-plugin is not running advertises nothing even though every GPU
	// Operator pod is healthy.
	Operands []OperandPod `json:"operands" yaml:"operands"`
	// ResourceSlices are the names of the gpu.nvidia.com ResourceSlices
	// published for the node. kubectl nv info fills them.
	ResourceSlices []string `json:"resourceSlices" yaml:"resourceSlices"`

	// Hinted is set when the node is not a GPU node but carries a hint label,
	// that is, when it came from Source.HintedNodes rather than Source.Nodes.
	// A hinted node is a node that should have GPUs and does not advertise
	// any, which is the single most common thing a user is looking for.
	Hinted bool `json:"hinted" yaml:"hinted"`
}

GPUNode is one GPU capable node, as the read-only commands see it.

ObjectMeta carries the node's name, its labels and its creation timestamp, and nothing else: the rest of a node's metadata (managed fields, resource version, annotations) is noise in a report and churn in a golden file, so a builder trims it rather than copying the node's metadata wholesale.

func NewGPUNode

func NewGPUNode(name string) *GPUNode

NewGPUNode returns a GPU node stamped with the API version and carrying the name. Every GPUNode handed to a printer has to come from here or carry the same TypeMeta: the printers read it off the struct, not off the bytes.

func (*GPUNode) DeepCopy

func (n *GPUNode) DeepCopy() *GPUNode

DeepCopy returns a copy of the receiver.

func (*GPUNode) DeepCopyInto

func (n *GPUNode) DeepCopyInto(out *GPUNode)

DeepCopyInto copies the receiver into out.

func (*GPUNode) DeepCopyObject

func (n *GPUNode) DeepCopyObject() runtime.Object

DeepCopyObject implements runtime.Object.

func (GPUNode) MarshalJSON

func (n GPUNode) MarshalJSON() ([]byte, error)

MarshalJSON stamps the envelope and renders every nil slice and map as an empty array or object. Both guarantees belong on the type: a GPUNode built by hand, or a zero value from a test, has to come off the wire looking like every other one.

func (*GPUNode) TableColumns

func (n *GPUNode) TableColumns(wide bool) []output.Column

TableColumns implements output.TableRows.

func (*GPUNode) TableRows

func (n *GPUNode) TableRows(wide bool) [][]string

TableRows implements output.TableRows.

type GPUNodeList

type GPUNodeList struct {
	metav1.TypeMeta `json:",inline" yaml:",inline"`
	metav1.ListMeta `json:"metadata,omitzero" yaml:"metadata,omitempty"`

	// Items keeps the order the command produced, as output.List does.
	Items []GPUNode `json:"items" yaml:"items"`
}

GPUNodeList is a list of GPU capable nodes.

func Build

func Build(ctx context.Context, src source.Source, opts BuildOptions) (*GPUNodeList, error)

Build reads the cluster through src and returns the GPU nodes it holds.

The whole inventory is three reads, whatever the cluster's size: one node classification, one pod list over every namespace, one ResourceSlice list. There is no per-node read at all, because on a two thousand node cluster that is two thousand round trips for data the list already carried.

A source.PartialError comes back unchanged, alongside the nodes that were read. That is the exit code 3 contract: the answer is incomplete and usable, and the caller must not treat it as "no result". Anything else means the run did not happen and no list is returned with it.

func BuildWithHinted

func BuildWithHinted(
	ctx context.Context,
	src source.Source,
	opts BuildOptions,
) (*GPUNodeList, int, error)

BuildWithHinted is Build, and also reports how many hinted nodes were left out because IncludeHinted was not set.

The count is what kubectl nv list says on stderr, and it has to come from the same pass: asking the cluster a second time to count them would be a second read of a second moment, and the number printed would not be the number of nodes missing from the list beside it.

func NewGPUNodeList

func NewGPUNodeList() *GPUNodeList

NewGPUNodeList returns an empty list stamped with the API version. As with NewGPUNode, a list handed to a printer has to come from here.

func (*GPUNodeList) DeepCopy

func (l *GPUNodeList) DeepCopy() *GPUNodeList

DeepCopy returns a copy of the receiver.

func (*GPUNodeList) DeepCopyInto

func (l *GPUNodeList) DeepCopyInto(out *GPUNodeList)

DeepCopyInto copies the receiver into out.

func (*GPUNodeList) DeepCopyObject

func (l *GPUNodeList) DeepCopyObject() runtime.Object

DeepCopyObject implements runtime.Object.

func (GPUNodeList) MarshalJSON

func (l GPUNodeList) MarshalJSON() ([]byte, error)

MarshalJSON stamps the envelope and renders a nil Items as an empty array.

func (*GPUNodeList) TableColumns

func (l *GPUNodeList) TableColumns(wide bool) []output.Column

TableColumns implements output.TableRows. The wide table grows one column per topology key the listed nodes carry, so the columns are a function of the items: a cluster with no fabric labels gets no empty fabric columns.

func (*GPUNodeList) TableRows

func (l *GPUNodeList) TableRows(wide bool) [][]string

TableRows implements output.TableRows.

type InitResult

type InitResult struct {
	// Name is the init container name, for instance "toolkit-validation".
	Name string `json:"name" yaml:"name"`
	// ExitCode is the code it terminated with. It is a pointer because "has
	// not finished" and "exited 0" are different facts and both are common.
	//
	// This is the one field in the package that keeps omitempty, and so the
	// one field whose presence varies between nodes. The alternative for a nil
	// pointer is a null, and never-null is the guarantee consumers were given
	// first; an absent key and a null both have to be handled, and an absent
	// key is the one that does not break a reader that trusted the rest.
	ExitCode *int32 `json:"exitCode,omitempty" yaml:"exitCode,omitempty"`
	// Reason is the termination reason, for instance "Error" or "Completed".
	Reason string `json:"reason" yaml:"reason"`
}

InitResult is what one init container of an operand pod ended up doing. The operator's validator pods carry their verdict in init container exit codes, so this is where a failed validation is visible.

func (*InitResult) DeepCopy

func (r *InitResult) DeepCopy() *InitResult

DeepCopy returns a copy of the receiver.

func (*InitResult) DeepCopyInto

func (r *InitResult) DeepCopyInto(out *InitResult)

DeepCopyInto copies the receiver into out.

type MIG

type MIG struct {
	// Strategy is nvidia.com/mig.strategy: "none", "single" or "mixed".
	Strategy string `json:"strategy" yaml:"strategy"`
	// Config is nvidia.com/mig.config, the profile the mig-manager was asked
	// to apply.
	Config string `json:"config" yaml:"config"`
	// ConfigState is nvidia.com/mig.config.state, where the mig-manager got
	// to with it: "success", "pending", "failed".
	ConfigState string `json:"configState" yaml:"configState"`
	// Capable is nvidia.com/mig.capable, whether the hardware supports MIG at
	// all. A node can be capable and unconfigured.
	Capable bool `json:"capable" yaml:"capable"`
	// Resources is what the node advertises per MIG profile, keyed by the
	// full resource name, for instance "nvidia.com/mig-1g.10gb".
	//
	// It is only ever populated under the mixed strategy, which is the one
	// where it is the only description of the node's capacity: a mixed node
	// advertises one extended resource per profile and no nvidia.com/gpu at
	// all, so GPUNode.Capacity is zero on it and these counts are the real
	// numbers. The single strategy keeps advertising nvidia.com/gpu and
	// leaves this empty.
	//
	// The keys are the same strings pkg/source reads membership from, kept
	// whole rather than split into a profile name, so that the two cannot
	// disagree about what counts as a MIG resource.
	Resources map[string]ResourceCount `json:"resources" yaml:"resources"`
}

MIG is the Multi-Instance GPU configuration of a node, read from the nvidia.com/mig.* labels and, in the mixed strategy, from the node's own extended resources.

func (MIG) MarshalJSON

func (m MIG) MarshalJSON() ([]byte, error)

MarshalJSON renders a nil Resources as an empty object.

type OperandPod

type OperandPod struct {
	// Name is the pod name.
	Name string `json:"name" yaml:"name"`
	// Namespace is the namespace it runs in, usually gpu-operator.
	Namespace string `json:"namespace" yaml:"namespace"`
	// Component is which operand it is: the verbatim value of the pod's "app"
	// label, or of "app.kubernetes.io/component" when there is no "app". The
	// operator has used both over its lifetime, so a reader takes whichever is
	// there and does not rewrite it.
	//
	// Verbatim is the contract. The Component* constants in this package are
	// the values the GPU Operator and the NVIDIA DRA driver are known to use,
	// and a rule matching on a component compares against one of them; a pod
	// labelled with something this package has never heard of still arrives
	// here with its own label value rather than an empty string, so an
	// unrecognised operand is visible rather than silently dropped.
	Component string `json:"component" yaml:"component"`
	// Phase is the pod phase.
	Phase string `json:"phase" yaml:"phase"`
	// Restarts is the restart count summed over the pod's containers.
	Restarts int32 `json:"restarts" yaml:"restarts"`
	// Images are the container images the pod runs, which is how a driver or
	// toolkit version mismatch becomes visible.
	Images []string `json:"images" yaml:"images"`
	// Ready is whether every container reports ready.
	Ready bool `json:"ready" yaml:"ready"`
	// InitContainers are the init container results, in pod order.
	InitContainers []InitResult `json:"initContainers" yaml:"initContainers"`
}

OperandPod is one GPU operator pod running on the node.

func (*OperandPod) DeepCopy

func (p *OperandPod) DeepCopy() *OperandPod

DeepCopy returns a copy of the receiver.

func (*OperandPod) DeepCopyInto

func (p *OperandPod) DeepCopyInto(out *OperandPod)

DeepCopyInto copies the receiver into out.

func (OperandPod) MarshalJSON

func (p OperandPod) MarshalJSON() ([]byte, error)

MarshalJSON renders the nil slices as empty arrays.

type ResourceCount

type ResourceCount struct {
	// Capacity is the resource's capacity on the node.
	Capacity int64 `json:"capacity" yaml:"capacity"`
	// Allocatable is what is left for the scheduler to place on it.
	Allocatable int64 `json:"allocatable" yaml:"allocatable"`
}

ResourceCount is what a node advertises of one extended resource.

type Sharing

type Sharing struct {
	// Strategy is nvidia.com/gpu.sharing-strategy: "none", "time-slicing" or
	// "mps".
	Strategy string `json:"strategy" yaml:"strategy"`
	// Replicas is nvidia.com/gpu.replicas, how many times each GPU is
	// advertised. It is 1, or absent, when nothing is shared.
	Replicas int `json:"replicas" yaml:"replicas"`
}

Sharing is how a node shares each physical GPU between pods, read from the nvidia.com/gpu.sharing-strategy and nvidia.com/gpu.replicas labels.

Jump to

Keyboard shortcuts

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