mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-11-30 10:48:15 +08:00
31 lines
657 B
Go
31 lines
657 B
Go
package controller
|
|
|
|
import (
|
|
"github.com/Sirupsen/logrus"
|
|
"k8s.io/client-go/kubernetes"
|
|
"k8s.io/client-go/tools/clientcmd"
|
|
)
|
|
|
|
// NewClientSet returns a new kubernetes clientSet
|
|
func NewClientSet(kubeconfig string) (*kubernetes.Clientset, error) {
|
|
conf, err := clientcmd.BuildConfigFromFlags("", kubeconfig)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
conf.QPS = 50
|
|
conf.Burst = 100
|
|
clientSet, err := kubernetes.NewForConfig(conf)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
//_, err = clientSet.CoreV1().Namespaces().List(v1.ListOptions{})
|
|
//if err != nil {
|
|
// return nil, err
|
|
//}
|
|
|
|
logrus.Debug("Kube client api create success.")
|
|
|
|
return clientSet, nil
|
|
}
|