mirror of
https://github.com/1Panel-dev/KubePi.git
synced 2025-10-05 15:26:58 +08:00
26 lines
452 B
Go
26 lines
452 B
Go
package kubernetes
|
|
|
|
import (
|
|
"k8s.io/client-go/kubernetes"
|
|
"k8s.io/client-go/rest"
|
|
)
|
|
|
|
type Config struct {
|
|
Host string
|
|
Token string
|
|
}
|
|
|
|
func NewKubernetesClient(c *Config) (*kubernetes.Clientset, error) {
|
|
return kubernetes.NewForConfig(NewClusterConfig(c))
|
|
}
|
|
|
|
func NewClusterConfig(c *Config) *rest.Config {
|
|
return &rest.Config{
|
|
Host: c.Host,
|
|
BearerToken: c.Token,
|
|
TLSClientConfig: rest.TLSClientConfig{
|
|
Insecure: true,
|
|
},
|
|
}
|
|
}
|