diff --git a/content/zh/docs/tasks/administer-cluster/access-cluster-api.md b/content/zh/docs/tasks/administer-cluster/access-cluster-api.md index 35d7cc2a20..fc25f2645c 100644 --- a/content/zh/docs/tasks/administer-cluster/access-cluster-api.md +++ b/content/zh/docs/tasks/administer-cluster/access-cluster-api.md @@ -280,6 +280,7 @@ Go 客户端可以使用与 kubectl 命令行工具相同的 package main import ( + "context" "fmt" "k8s.io/client-go/1.4/kubernetes" "k8s.io/client-go/1.4/pkg/api/v1" @@ -293,7 +294,7 @@ func main() { // creates the clientset clientset, _ := kubernetes.NewForConfig(config) // access the API to list pods - pods, _ := clientset.CoreV1().Pods("").List(v1.ListOptions{}) + pods, _ := clientset.CoreV1().Pods("").List(context.TODO(), v1.ListOptions{}) fmt.Printf("There are %d pods in the cluster\n", len(pods.Items)) } ```