Documentation
¶
Overview ¶
Package k8s provides helper functions for interacting with Kubernetes clusters and related resources.
Package k8s contains helpers for interacting with Kubernetes clusters and related resources.
Index ¶
- Constants
- Variables
- func DrainNode(ctx context.Context, kubeconfig, contextName, nodeName string) error
- func LoadDedicatedAIClusters(ctx context.Context, lister DedicatedAIClusterLister) (map[string][]models.DedicatedAICluster, error)
- func LoadGpuNodes(ctx context.Context, lister GpuNodeLister) (map[string][]models.GpuNode, error)
- func TenantIDFromLabels(labels map[string]any) string
- func ToggleCordon(ctx context.Context, kubeconfig, contextName, nodeName string) error
- type DedicatedAIClusterLister
- type GpuNodeLister
- type Helper
- func (k *Helper) ChangeContext(context string) error
- func (k *Helper) ListDedicatedAIClusters(ctx context.Context) ([]models.DedicatedAICluster, error)
- func (k *Helper) ListGpuNodes(ctx context.Context) ([]models.GpuNode, error)
- func (k *Helper) ListGpuNodesWithSelectors(ctx context.Context, selectors ...string) ([]models.GpuNode, error)
Constants ¶
const GPUProperty corev1.ResourceName = "nvidia.com/gpu"
GPUProperty is the Kubernetes resource name for GPU.
const NodeCondGpuUnhealthy corev1.NodeConditionType = "GpuUnhealthy"
NodeCondGpuUnhealthy is the condition type for unhealthy GPU nodes.
Variables ¶
var DefaultGPUSelectors = []string{
"app=dummy",
"component=predictor",
"ome.oracle.com/trainingjob",
}
DefaultGPUSelectors is the default set of label selectors used to sum GPU allocations.
Functions ¶
func LoadDedicatedAIClusters ¶
func LoadDedicatedAIClusters(ctx context.Context, lister DedicatedAIClusterLister) (map[string][]models.DedicatedAICluster, error)
LoadDedicatedAIClusters loads DedicatedAICluster information using the provided DedicatedAIClusterLister.
func LoadGpuNodes ¶
LoadGpuNodes loads GPU node information using the provided GpuNodeLister.
func TenantIDFromLabels ¶
TenantIDFromLabels extracts the tenant ID from a map of labels. Returns "UNKNOWN_TENANCY" if the label is missing or not a string.
Types ¶
type DedicatedAIClusterLister ¶
type DedicatedAIClusterLister interface {
ListDedicatedAIClusters(ctx context.Context) ([]models.DedicatedAICluster, error)
}
DedicatedAIClusterLister is an interface for listing DedicatedAIClusters.
type GpuNodeLister ¶
GpuNodeLister is an interface for listing GPU nodes.
type Helper ¶
type Helper struct {
// contains filtered or unexported fields
}
Helper provides helpers for interacting with Kubernetes clusters. It manages client configuration, context switching, and provides methods for listing GPU nodes and AI clusters.
func (*Helper) ChangeContext ¶
ChangeContext switches the current context of the K8sHelper to the specified context.
func (*Helper) ListDedicatedAIClusters ¶
ListDedicatedAIClusters returns all DedicatedAICluster resources from both v1alpha1 and v1beta1 CRDs.
func (*Helper) ListGpuNodes ¶
ListGpuNodes is the production version, using all selectors.
func (*Helper) ListGpuNodesWithSelectors ¶
func (k *Helper) ListGpuNodesWithSelectors(ctx context.Context, selectors ...string) ([]models.GpuNode, error)
ListGpuNodesWithSelectors returns a list of GpuNode objects from the current Kubernetes context. If no selectors are provided, DefaultGPUSelectors is used.