github.com/olli-ai/jx/v2@v2.0.400-0.20210921045218-14731b4dd448/pkg/kube/clients.go (about)

     1  package kube
     2  
     3  import (
     4  	"k8s.io/client-go/kubernetes"
     5  	"k8s.io/client-go/tools/clientcmd"
     6  )
     7  
     8  // CreateKubeClient creates a new Kubernetes client
     9  func CreateKubeClient(kubeconfig *string) (kubernetes.Interface, error) {
    10  	// use the current context in kubeconfig
    11  	config, err := clientcmd.BuildConfigFromFlags("", *kubeconfig)
    12  	if err != nil {
    13  		panic(err.Error())
    14  	}
    15  
    16  	// create the clientset
    17  	return kubernetes.NewForConfig(config)
    18  }