Documentation ¶
Index ¶
- Variables
- func ContainerLog(podName string, containerName string) *rest.Request
- func ContainerShell(podName string, containerName string) *exec.Cmd
- func KubeCmd() *exec.Cmd
- func KubeCmdArgs(args ...string) *exec.Cmd
- func PodGet(name string) (*v12.Pod, error)
- func ShowContext() string
- func ShowNamespace() string
Constants ¶
This section is empty.
Variables ¶
View Source
var Client = sync.OnceValue(func() *kubernetes.Clientset { config := ShowKubeConfig() clientset, errKubernetes := kubernetes.NewForConfig(config) if errKubernetes != nil { logrus.Fatal(errKubernetes) } return clientset })
Client 获取k8s client
View Source
var PodCache = sync.OnceValue(func() *podCache { c := &podCache{ livetime: time.Second * time.Duration(comm.ShowKubeteaConfig().PodCacheLivetime), dataRead: make(chan bool), } return c })
View Source
var ShowApiConfig = sync.OnceValue(func() *api.Config { configAccess := clientcmd.NewDefaultPathOptions() configAccess.GetLoadingPrecedence() config, err := configAccess.GetStartingConfig() if err != nil { logrus.Fatalf("show api config error: %v", err) } return config })
ShowApiConfig 获取kube的配置
View Source
var ShowKubeConfig = sync.OnceValue(func() *restclient.Config { configOverrides := &clientcmd.ConfigOverrides{ CurrentContext: ShowContext(), } config, err := clientcmd.NewNonInteractiveDeferredLoadingClientConfig( &clientcmd.ClientConfigLoadingRules{ExplicitPath: ShowKubeConfigPath()}, configOverrides, ).ClientConfig() if err != nil { logrus.Fatalf("Error loading kubeconfig: %v\n", err) } return config })
ShowKubeConfig 获取kube的配置
View Source
var ShowKubeConfigPath = sync.OnceValue(func() string { kubeconfig := comm.Context.String("kubeconfig") if kubeconfig == "" { home, err := os.UserHomeDir() if err != nil { logrus.Fatal(err) } kubeconfig = filepath.Join(home, ".kube", "config") } return kubeconfig })
ShowKubeConfigPath 获取kubeconfig的路径
Functions ¶
func ContainerLog ¶
ContainerLog 获取一个容器的日志
func ContainerShell ¶
ContainerShell 生成一个容器Shell命令
func KubeCmdArgs ¶ added in v0.0.13
KubeCmdArgs 生成带指定参数的kubectl命令
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.