我嘗試使用客戶端集。CoreV1().終結點(命名空間)。獲?。ㄉ舷挛摹ODO(),名稱字符串 ,metav1.GetOptions{})endpoints, err2 := clientset.CoreV1().Endpoints(namespace2).Get(context.TODO(), namespace2, metav1.GetOptions{}) if err2 != nil { log.Println(err2.Error()) } fmt.Printf("GetPodList There are %v endpoints in the cluster\n", (endpoints))但我不確定為名稱字符串(第二個參數)和metav1給出的參數。GetOptions{}.(第三個參數)
1 回答

MMTTMM
TA貢獻1869條經驗 獲得超4個贊
您應該使用函數而不是:允許您檢索與特定條件匹配的多個端點,允許您檢索特定的端點(按名稱)。ListGetListGet
因此:
endpoints, err := clientset.CoreV1().Endpoints(namespace2).List(context.TODO(), metav1.ListOptions{})
// ...
fmt.Printf("GetPodList there are %v endpoints in the cluster\n", len(endpoints.Items)
如果希望命名空間中的所有終結點,則無需指定任何列表選項,并且可以傳遞空結構。
- 1 回答
- 0 關注
- 107 瀏覽
添加回答
舉報
0/150
提交
取消