mirror of
https://github.com/hanzoai/agent.git
synced 2026-09-11 21:08:51 +00:00
Multi-platform cloud bot provisioning (Linux K8s pods, Windows/macOS EC2), billing authorization via bootnode API, usage metering, and real-time monitoring. Includes REST + UI APIs, SSE events, dedicated host pooling for macOS, and per-tier compute quotas.
30 lines
732 B
Go
30 lines
732 B
Go
package k8s
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"k8s.io/client-go/kubernetes"
|
|
"k8s.io/client-go/rest"
|
|
"k8s.io/client-go/tools/clientcmd"
|
|
)
|
|
|
|
// NewClient creates a Kubernetes client. It tries in-cluster config first,
|
|
// then falls back to kubeconfig (for local development).
|
|
func NewClient() (*kubernetes.Clientset, error) {
|
|
config, err := rest.InClusterConfig()
|
|
if err != nil {
|
|
// Fallback to kubeconfig
|
|
config, err = clientcmd.BuildConfigFromFlags("", clientcmd.RecommendedHomeFile)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to create k8s config: %w", err)
|
|
}
|
|
}
|
|
|
|
clientset, err := kubernetes.NewForConfig(config)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to create k8s clientset: %w", err)
|
|
}
|
|
|
|
return clientset, nil
|
|
}
|