new clientset

This commit is contained in:
GLYASAI 2020-01-08 18:18:09 +08:00
parent cb0392c47a
commit dee14ce89b
4 changed files with 23 additions and 9 deletions

View File

@ -50,11 +50,13 @@ func Run(s *option.GWServer) error {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
var clientset kubernetes.Interface
if s.Config.K8SConfPath == "" {
clientset = k8sutil.MustNewKubeClient()
} else {
k8sutil.NewClientset(s.K8SConfPath)
config, err := k8sutil.NewRestConfig(s.K8SConfPath)
if err != nil {
return err
}
clientset, err := kubernetes.NewForConfig(config)
if err != nil {
return err
}
//create cluster node manage

View File

@ -72,7 +72,11 @@ func Run(s *option.Worker) error {
logrus.Errorf("create kube rest config error: %s", err.Error())
return err
}
clientset, _ := kubernetes.NewForConfig(restConfig)
clientset, err := kubernetes.NewForConfig(restConfig)
if err != nil {
logrus.Error("Error creating clientset: %v", err)
return err
}
s.Config.KubeClient = clientset
kubeaggregatorclientset, err := kubeaggregatorclientset.NewForConfig(restConfig)

View File

@ -22,8 +22,9 @@ import (
"path"
"github.com/goodrain/rainbond/builder/sources"
k8sutil "github.com/goodrain/rainbond/util/k8s"
"github.com/Sirupsen/logrus"
"k8s.io/client-go/kubernetes"
)
@ -44,6 +45,10 @@ func InitClient(kubeconfig string) error {
config.QPS = 50
config.Burst = 100
K8SClient, _ = kubernetes.NewForConfig(config)
K8SClient, err = kubernetes.NewForConfig(config)
if err != nil {
logrus.Error("Create kubernetes client error.", err.Error())
return err
}
return nil
}

View File

@ -80,7 +80,10 @@ func NewKubeClient(cfg *conf.Conf) (KubeClient, error) {
config.QPS = 50
config.Burst = 100
cli, _ := kubernetes.NewForConfig(config)
cli, err := kubernetes.NewForConfig(config)
if err != nil {
return nil, err
}
stop := make(chan struct{})
sharedInformers := informers.NewFilteredSharedInformerFactory(cli, cfg.MinResyncPeriod, v1.NamespaceAll,