source/store.go
func NewKubeClient(kubeConfig, kubeMaster string, requestTimeout time.Duration) (*kubernetes.Clientset, error) {
	if kubeConfig == "" {
		if _, err := os.Stat(clientcmd.RecommendedHomeFile); err == nil {
			kubeConfig = clientcmd.RecommendedHomeFile
		}
	}

	config, err := clientcmd.BuildConfigFromFlags(kubeMaster, kubeConfig)
	if err != nil {
		return nil, err
	}

	config.WrapTransport = func(rt http.RoundTripper) http.RoundTripper {
		return instrumented_http.NewTransport(rt, &instrumented_http.Callbacks{
			PathProcessor: func(path string) string {
				parts := strings.Split(path, "/")
				return parts[len(parts)-1]
			},
		})
	}

	config.Timeout = requestTimeout

	client, err := kubernetes.NewForConfig(config)
	if err != nil {
		return nil, err
	}

	log.Infof("Created Kubernetes client %s", config.Host)

	return client, nil
}
func NewKubeClient(kubeConfig, kubeMaster string, requestTimeout time.Duration) (*kubernetes.Clientset, error) {
	if kubeConfig == "" {
		if _, err := os.Stat(clientcmd.RecommendedHomeFile); err == nil {
			kubeConfig = clientcmd.RecommendedHomeFile
		}
	}

	config, err := clientcmd.BuildConfigFromFlags(kubeMaster, kubeConfig)
	if err != nil {
		return nil, err
	}

	config.WrapTransport = func(rt http.RoundTripper) http.RoundTripper {
		return instrumented_http.NewTransport(rt, &instrumented_http.Callbacks{
			PathProcessor: func(path string) string {
				parts := strings.Split(path, "/")
				return parts[len(parts)-1]
			},
		})
	}

	config.Timeout = requestTimeout

	client, err := kubernetes.NewForConfig(config)
	if err != nil {
		return nil, err
	}

	log.Infof("Created Kubernetes client %s", config.Host)

	return client, nil
}
func NewKubeClient ( kubeConfig , kubeMaster string , requestTimeout time . Duration ) ( * kubernetes . Clientset , error ) { if kubeConfig == " " { if _ , err := os . Stat ( clientcmd . RecommendedHomeFile ) ; err == nil { kubeConfig = clientcmd . RecommendedHomeFile } } config , err := clientcmd . BuildConfigFromFlags ( kubeMaster , kubeConfig ) if err != nil { return nil , err } config . WrapTransport = func ( rt http . RoundTripper ) http . RoundTripper { return instrumented_http . NewTransport ( rt , & instrumented_http . Callbacks { PathProcessor : func ( path string ) string { parts := strings . Split ( path , " " ) return parts [ len ( parts ) - 1 ] } , } ) } config . Timeout = requestTimeout client , err := kubernetes . NewForConfig ( config ) if err != nil { return nil , err } log . Infof ( " " , config . Host ) return client , nil }
// NewKubeClient returns a new Kubernetes client object. It takes a Config and
// uses KubeMaster and KubeConfig attributes to connect to the cluster. If
// KubeConfig isn't provided it defaults to using the recommended default.
NewKubeClient returns a new Kubernetes client object . It takes a Config and uses KubeMaster and KubeConfig attributes to connect to the cluster . If KubeConfig isn t provided it defaults to using the recommended default .