{"record":{"id":"2660b8e9ff26dfd4","repo":"cilium/cilium","slug":"unable-to-create-kubernetes-client-for-remote-clus","errorCode":null,"errorMessage":"unable to create Kubernetes client for remote cluster %q: %w","messagePattern":"unable to create Kubernetes client for remote cluster %q: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cilium-cli/connectivity/check/context.go","lineNumber":971,"sourceCode":"// initClients assigns the k8s clients used for connectivity tests.\n// in the event that this is a multi-cluster test scenario the destination k8s\n// client is set to the cluster provided in the MultiCluster parameter.\nfunc (ct *ConnectivityTest) initClients(ctx context.Context) error {\n\tc := &deploymentClients{\n\t\tsrc: ct.client,\n\t\tdst: ct.client,\n\t}\n\n\tif ctx.Err() != nil {\n\t\treturn ctx.Err()\n\t}\n\n\tif ct.params.MultiCluster != \"\" {\n\t\tmultiClusterClientLock.Lock()\n\t\tdefer multiClusterClientLock.Unlock()\n\t\tdst, err := k8s.NewClient(ct.params.MultiCluster, \"\", ct.params.CiliumNamespace, ct.params.ImpersonateAs, ct.params.ImpersonateGroups)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"unable to create Kubernetes client for remote cluster %q: %w\", ct.params.MultiCluster, err)\n\t\t}\n\n\t\tc.dst = dst\n\t}\n\n\tct.clients = c\n\n\treturn nil\n}\n\n// errNoCiliumPods is returned by initCiliumPods when a cluster runs no Cilium\n// agent, so that callers which tolerate this can tell it apart from a failure\n// to reach the Kubernetes API.\nvar errNoCiliumPods = errors.New(\"no cilium agent pods found\")\n\n// initCiliumPods fetches the Cilium agent pod information from all clients\nfunc (ct *ConnectivityTest) initCiliumPods(ctx context.Context) error {\n\tfor _, client := range ct.clients.clients() {","sourceCodeStart":953,"sourceCodeEnd":989,"githubUrl":"https://github.com/cilium/cilium/blob/ac7b90affa4baf0642e6685319d56907b3a73a6d/cilium-cli/connectivity/check/context.go#L953-L989","documentation":"initClients fails when creating the Kubernetes client for the remote (multi-cluster) target cluster via k8s.NewClient. The remote cluster name is used to find/construct client configuration; any failure there aborts multi-cluster setup since c.dst is required.","triggerScenarios":"--multi-cluster <name> is set and k8s.NewContext/NewClient cannot build a client for that cluster: no matching kubeconfig context, missing/clusted-config file, bad impersonation args, or unreachable API server.","commonSituations":"Typo in --multi-cluster name (must match context/cluster name); missing kubeconfig entries for the peer cluster; running inside a cluster without the cilium-clustermesh config; expired tokens.","solutions":["Confirm a kubeconfig context exists for the cluster name passed to --multi-cluster (kubectl config get-contexts) and pass a valid --context if needed","Run cilium-cli clustermesh connect/status to verify inter-cluster connectivity and config","Check --impersonate-as/--impersonate-groups values are valid","Re-authenticate (kubectl login / refresh token) if credentials expired"],"exampleFix":"// before\ncilium-cli connectivity test --multi-cluster prd-west\n# no such context: prd-west\n// after\ncilium-cli connectivity test --multi-cluster prod-west --context prod-west","handlingStrategy":"validation","validationCode":"ctxs, _ := run(\"kubectl config get-contexts -o name\")\nif !slices.Contains(ctxs, multiClusterName) {\n\treturn fmt.Errorf(\"context %q for --multi-cluster not found in kubeconfig\", multiClusterName)\n}","typeGuard":null,"tryCatchPattern":"if err := ct.Run(ctx); err != nil && strings.Contains(err.Error(), \"remote cluster\") {\n\t// fix kubeconfig / clustermesh, then retry\n}","preventionTips":["Merge peer-cluster credentials into the kubeconfig before running","Name --multi-cluster exactly as the kubeconfig context/cluster","Validate clustermesh status before connectivity tests","Keep impersonation flags consistent across clusters"],"tags":["multi-cluster","kubernetes","kubeconfig","clustermesh"],"backgroundTag":"kubeconfig-context-missing","analyzedSha":"ac7b90affa4baf0642e6685319d56907b3a73a6d","analyzedAt":"2026-08-31T18:27:15.868Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}