kubernetes / client-go

Go client for Kubernetes.
Apache License 2.0
8.78k stars 2.9k forks source link

when creating a watcher,how to solve error :"unknown (get deployments.apps)"? #1271

Closed steaksunflower0107 closed 3 months ago

steaksunflower0107 commented 1 year ago

when I deploy my program which aims to watch all k8s's deployment's cpu and memory on k8s,it shows the error : "unknown (get deployments.apps)" here are where my error happend watcher, err := clientSet.AppsV1().Deployments(*nameSpace).Watch(context.Background(), metav1.ListOptions{}) if err != nil { log.Fatalf("Creating Watcher failed: %v", err) } defer watcher.Stop()

and I have try to add serviceAccount, clusterRole,clusterRoleBinding,it still does work here are my yaml file `apiVersion: v1 kind: ServiceAccount metadata: name: watcher namespace: watcher

apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: watcher namespace: watcher rules:


apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: watcher-binding namespace: watcher subjects:

rpstw commented 1 year ago

facing the same issue with version 0.24.6

rpstw commented 1 year ago

The err returned is misleading. Making klog more verbose shows the actual error.

// just a workaround, normally v should be passed via command line
l := klog.Level(6)
_ = l.Set("6")

I0705 10:47:43.414058 1 round_trippers.go:553] GET https://10.39.0.1:443/api/v1/namespaces/xxx/pods?fieldSelector=metadata.namespace%3Dxxx%2Cmetadata.name%3Dxxxx-qhj-rpzqh&watch=true 403 Forbidden in 0 milliseconds

k8s-triage-robot commented 5 months ago

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot commented 4 months ago

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

k8s-triage-robot commented 3 months ago

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

k8s-ci-robot commented 3 months ago

@k8s-triage-robot: Closing this issue, marking it as "Not Planned".

In response to [this](https://github.com/kubernetes/client-go/issues/1271#issuecomment-2016621591): >The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. > >This bot triages issues according to the following rules: >- After 90d of inactivity, `lifecycle/stale` is applied >- After 30d of inactivity since `lifecycle/stale` was applied, `lifecycle/rotten` is applied >- After 30d of inactivity since `lifecycle/rotten` was applied, the issue is closed > >You can: >- Reopen this issue with `/reopen` >- Mark this issue as fresh with `/remove-lifecycle rotten` >- Offer to help out with [Issue Triage][1] > >Please send feedback to sig-contributor-experience at [kubernetes/community](https://github.com/kubernetes/community). > >/close not-planned > >[1]: https://www.kubernetes.dev/docs/guide/issue-triage/ Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
81981266 commented 1 week ago

/remove-lifecycle stale