func NewClient(context string) (*Client, error) {
	var c *rest.Config
	var err error
	configFilepath := filepath.Join(os.Getenv("HOME"), ".kube", "config")
	if context != "" {
		c, err = clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
			&clientcmd.ClientConfigLoadingRules{ExplicitPath: configFilepath},
			&clientcmd.ConfigOverrides{
				ClusterInfo:    clientcmdapi.Cluster{Server: ""},
				CurrentContext: context,
			}).ClientConfig()
	} else {
		c, err = clientcmd.BuildConfigFromFlags("", configFilepath)
	}
	if err != nil {
		return nil, err
	}
	if c.Timeout == 0 {
		c.Timeout = 5 * time.Second
	}
	cs, err := kubernetes.NewForConfig(c)
	if err != nil {
		return nil, err
	}
	sv, err := cs.ServerVersion()
	if err != nil {
		return nil, err
	}
	return &Client{
		Clientset:         cs,
		Config:            c,
		ServerVersionInfo: sv,
	}, nil
}
NewClient returns a k8s api client.
package k8s
import (
	"bytes"
	"context"
	"fmt"
	"os"
	"path/filepath"
	"strings"
	"time"
	v1 "k8s.io/api/core/v1"
	rbacv1 "k8s.io/api/rbac/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/version"
	"k8s.io/client-go/kubernetes"
	"k8s.io/client-go/rest"
	"k8s.io/client-go/tools/clientcmd"
	clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
	"k8s.io/client-go/tools/remotecommand"
)
type Client struct {
	Clientset         *kubernetes.Clientset
	Config            *rest.Config
	ServerVersionInfo *version.Info
}