我有下面的代码打印我的 kubernetes 部署元数据,
package test
import (
"context"
"fmt"
"os"
"testing"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd"
)
func TestEksStandaloneModule(t *testing.T) {
namespace := fmt.Sprintf("%v-%v", "project", "dit")
kubeconfig := os.Getenv("HOME") + "/KUBECONFIG"
clientCfg, err := clientcmd.BuildConfigFromFlags("", kubeconfig)
if err != nil {
t.Error(err)
}
clientset, err := kubernetes.NewForConfig(clientCfg)
appDeployment, err := clientset.AppsV1().Deployments(namespace).Get(context.TODO(), "deploymentname", v1.GetOptions{})
fmt.Println(appDeployment)
}
任何人都可以帮我获得打印入口元数据的功能吗?我是新来的。
呼啦一阵风
相关分类