Documentation
¶
Overview ¶
Package k8s provides Kubernetes integration for Cloud Native Stack.
This package contains sub-packages for Kubernetes cluster interaction:
Sub-packages ¶
client: Singleton Kubernetes client with automatic authentication
clientset, config, err := client.GetKubeClient()
if err != nil {
return err
}
// Use clientset for API operations
agent: Kubernetes Job deployment for automated snapshot capture
deployer := agent.NewDeployer(clientset, agentConfig)
if err := deployer.Deploy(ctx); err != nil {
return err
}
Architecture ¶
The k8s package follows these design principles:
Singleton Pattern: The client package uses sync.Once to ensure a single Kubernetes client instance is shared across the application, preventing connection exhaustion and reducing API server load.
Automatic Authentication: The client automatically detects whether it's running in-cluster (using service account) or out-of-cluster (using kubeconfig file).
Job-based Agent: The agent package deploys snapshot capture as a Kubernetes Job, enabling GPU node targeting and ConfigMap-based output storage.
Usage Patterns ¶
For most use cases, import and use the client sub-package:
import "github.com/NVIDIA/aicr/pkg/k8s/client" // Get shared client instance clientset, _, err := client.GetKubeClient()
For agent deployment, import the agent sub-package:
import "github.com/NVIDIA/aicr/pkg/k8s/agent"
// Deploy snapshot agent
config := agent.Config{
Namespace: "gpu-operator",
Image: "ghcr.io/nvidia/aicr-validator:latest",
}
deployer := agent.NewDeployer(clientset, config)
Thread Safety ¶
Both sub-packages are designed for concurrent use:
- client: Uses sync.Once for thread-safe initialization
- agent: Each Deployer instance is independent
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IgnoreAlreadyExists ¶
IgnoreAlreadyExists returns nil if the error is "already exists", otherwise returns the error. Used to make resource creation idempotent.
func IgnoreNotFound ¶
IgnoreNotFound returns nil if the error is "not found", otherwise returns the error. Used to make resource deletion idempotent.
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package agent provides Kubernetes Job deployment for automated snapshot capture.
|
Package agent provides Kubernetes Job deployment for automated snapshot capture. |
|
Package client provides a singleton Kubernetes client for efficient cluster interactions.
|
Package client provides a singleton Kubernetes client for efficient cluster interactions. |
|
Package pod provides shared utilities for Kubernetes Job and Pod operations.
|
Package pod provides shared utilities for Kubernetes Job and Pod operations. |