load-watcher icon indicating copy to clipboard operation
load-watcher copied to clipboard

no premisstion

Open 13567436138 opened this issue 1 year ago • 1 comments

time="2025-01-12T05:05:16Z" level=error msg="received error while fetching metrics: nodes is forbidden: User "system:serviceaccount:loadwatcher:default" cannot list resource "nodes" in API group "" at the cluster scope" func="github.com/paypal/load-watcher/pkg/watcher.(*Watcher).StartWatching.func1" file="/go/src/github.com/paypal/load-watcher/pkg/watcher/watcher.go:136" time="2025-01-12T05:05:16Z" level=error msg="received error while fetching metrics: nodes is forbidden: User "system:serviceaccount:loadwatcher:default" cannot list resource "nodes" in API group "" at the cluster scope" func="github.com/paypal/load-watcher/pkg/watcher.(*Watcher).StartWatching.func1" file="/go/src/github.com/paypal/load-watcher/pkg/watcher/watcher.go:136" time="2025-01-12T05:05:16Z" level=error msg="received error while fetching metrics: nodes is forbidden: User "system:serviceaccount:loadwatcher:default" cannot list resource "nodes" in API group "" at the cluster scope" func="github.com/paypal/load-watcher/pkg/watcher.(*Watcher).StartWatching.func1" file="/go/src/github.com/paypal/load-watcher/pkg/watcher/watcher.go:136"

I have added

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: metrics-reader
rules:
- apiGroups: ["metrics.k8s.io"]  
  resources: ["nodes"]         
  verbs: ["get", "list", "watch"]  
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: metrics-reader-binding
subjects:
- kind: ServiceAccount
  name: default
  namespace: loadwatcher
roleRef:
  kind: ClusterRole
  name: metrics-reader 
  apiGroup: rbac.authorization.k8s.io

13567436138 avatar Jan 12 '25 05:01 13567436138

Proper rules should look like this:

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: metrics-reader
rules:
  - apiGroups: ["metrics.k8s.io"]
    resources: ["nodes"]
    verbs: ["get", "list", "watch"]
  - apiGroups: [""]
    resources: ["nodes"]
    verbs: ["get", "list", "watch"]

deniszh avatar Aug 08 '25 10:08 deniszh