k8s

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package k8s provides Kubernetes client utilities for loading configs and creating typed and dynamic clients.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DrainNode added in v0.1.3

func DrainNode(ctx context.Context, kubeconfig, contextName, nodeName string) error

DrainNode uses kubectl's drain.Helper to cordon and drain a node.

func FormatAge added in v0.1.4

func FormatAge(d time.Duration) string

FormatAge returns the duration in s/m/h/d with max-granularity.

func LoadBaseModels added in v0.1.4

func LoadBaseModels(ctx context.Context, client dynamic.Interface) ([]models.BaseModel, error)

LoadBaseModels returns all ClusterBaseModel CRs as a slice.

func LoadDedicatedAIClusters

func LoadDedicatedAIClusters(ctx context.Context, client dynamic.Interface) (map[string][]models.DedicatedAICluster, error)

LoadDedicatedAIClusters loads DedicatedAICluster information using the provided DedicatedAIClusterLister.

func LoadGpuNodes

func LoadGpuNodes(ctx context.Context, clientset kubernetes.Interface) (map[string][]models.GpuNode, error)

LoadGpuNodes returns a map of node pool names to slices of GpuNode. It fetches all GPU nodes and groups them by their node pool label.

func NewClientsetFromKubeConfig added in v0.1.4

func NewClientsetFromKubeConfig(kubeconfig, ctx string) (kubernetes.Interface, error)

NewClientsetFromKubeConfig creates a new Kubernetes clientset from a kubeconfig file and context. Returns an error if config loading or client creation fails.

func NewClientsetFromRestConfig added in v0.1.4

func NewClientsetFromRestConfig(config *rest.Config) (kubernetes.Interface, error)

NewClientsetFromRestConfig creates a new Kubernetes clientset from the given rest.Config. Returns an error if the config is nil or client creation fails.

func NewConfig added in v0.1.4

func NewConfig(kubeconfig, ctx string) (*rest.Config, error)

NewConfig loads a rest.Config from kubeconfig/context.

func NewDynamicClient added in v0.1.4

func NewDynamicClient(config *rest.Config) (dynamic.Interface, error)

NewDynamicClient creates a new dynamic Kubernetes client from the given rest.Config. Returns an error if the config is nil or client creation fails.

func NewDynamicClientFromKubeConfig added in v0.1.4

func NewDynamicClientFromKubeConfig(kubeconfig, ctx string) (dynamic.Interface, error)

NewDynamicClientFromKubeConfig creates a new dynamic Kubernetes client from a kubeconfig file and context. Returns an error if config loading or client creation fails.

func ParseAge added in v0.1.4

func ParseAge(s string) int64

ParseAge converts strings like "10s", "3m", "4h", "2d" to seconds. Unsupported or malformed inputs return 0.

func ToggleCordon added in v0.1.3

func ToggleCordon(ctx context.Context, kubeconfig, contextName, nodeName string) (bool, error)

ToggleCordon uses kubectl's drain.Helper to cordon or uncordon a node. Returns true if node is cordoned after the call, false if uncordoned.

Types

type PodCache added in v0.1.4

type PodCache struct {
	// contains filtered or unexported fields
}

PodCache maps namespace name to pods.

type PodStats added in v0.1.4

type PodStats struct {
	TotalPods int
	IdlePods  int
	ModelName string
	Type      string
}

PodStats holds pod statistics for a namespace.

Jump to

Keyboard shortcuts

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