lensapp / lens

Lens - The way the world runs Kubernetes
https://k8slens.dev/
MIT License
22.55k stars 1.47k forks source link

What resources do lens need to get metrics #5046

Open MagicalBomb opened 2 years ago

MagicalBomb commented 2 years ago

I had created a clusterRole with following rules. After that I created service account, clusterRoleBinding, kubeconfig.yaml manually.

# ClusterRole.yaml
rules:
  - verbs:
      - get
      - list
      - watch
    apiGroups:
      - ''
    resources:
      - pods
      - services
      - namespaces
      - nodes
      - services/proxy
      - nodes/proxy
      - nodes/metrics
      - pods/proxy
  - verbs:
      - create
      - get
      - update
      - list
      - delete
      - watch
      - patch
    apiGroups:
      - apps
    resources:
      - deployment
  - verbs:
      - create
      - get
      - list
      - watch
    apiGroups:
      - rbac.authorization.k8s.io
    resources:
      - clusterroles
# kubeconfig.yaml
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data:  xxxx
    server: https://xxx:xxx
  name: kubernetes
contexts:
- context:
    cluster: kubernetes
    user: adam
  name: kubernetes-test@kubernetes
current-context: kubernetes-test@kubernetes
kind: Config
users:
- name: adam
  user:
    token:  xxxx

image

I added the kubeconfig.yaml to Lens and log in my cluster successfully, but it can't fetch metrics. I am wondering if there are some mistake I made and I really don't want login with default amin user. Could someone help, thx!

Nokel81 commented 2 years ago

Does https://github.com/lensapp/lens/issues/3698 help?

jim-docker commented 1 year ago

This worked for me for Lens built-in metrics on the LDK cluster. Note that create is required for services/proxy, not sure why.