FairwindsOps / goldilocks

Get your resource requests "Just Right"
https://fairwinds.com
Apache License 2.0
2.55k stars 135 forks source link

goldilocks Dashboard does not show namespaces #245

Closed ghost closed 3 years ago

ghost commented 3 years ago

The visit page did not get a namespace

Error getting namespace list
<!doctype html>
<html>

<head>
  <script>
    window.data = [];
  </script>

  <base href="/">
  <meta charset="utf-8">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  <title>Fairwinds Goldilocks</title>
  <meta name="description" content="">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <link href="static/css/Muli.css" rel="stylesheet">
  <link rel="stylesheet" href="static/css/normalize.css">
  <link rel="stylesheet" href="static/css/main.css">
  <link rel="stylesheet" href="static/css/fontawesome-5.7.2.css">
  <link rel="stylesheet" href="static/css/dashboard.css">
  <link rel="stylesheet" href="static/css/prism.css">
  <script type="text/javascript" src="static/js/Chart-2.7.2.min.js"></script>
  <script type="text/javascript" src="static/js/cash-4.1.2.min.js"></script>
  <script type="text/javascript" src="static/js/main.js"></script>
  <script type="text/javascript" src="static/js/prism.js"></script>

   <script type="text/javascript" src="static/js/namespace_list.js"></script>
</head>
....
ghost commented 3 years ago

But I have enabled namespace support here, what is the cause of this, is it a mirroring problem

# kubectl get ns --show-labels
NAME                STATUS   AGE    LABELS
default             Active   6d6h   goldilocks.fairwinds.com/enabled=true
goldilocks          Active   99m    goldilocks.fairwinds.com/enabled=true,name=goldilocks,system/namespace=goldilocks,system/tenant-id=TENANT-xxH6MimNDozf
kube-node-lease     Active   6d6h   goldilocks.fairwinds.com/enabled=true
kube-public         Active   6d6h   goldilocks.fairwinds.com/enabled=true
kube-system         Active   6d6h   goldilocks.fairwinds.com/enabled=true
sudermanjr commented 3 years ago

Error getting namespace list usually indicates that the dashboard pod doesn't have the correct RBAC permissions to view namespaces. How did you deploy the dashboard?

containerpope commented 3 years ago

@zhaocheng173 you possibly need to update the clusterrole for your dashboard as follows:

---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
  name: goldilocks-dashboard
  labels:
    app: goldilocks
rules:
  - apiGroups:
      - 'autoscaling.k8s.io'
    resources:
      - 'verticalpodautoscalers'
    verbs:
      - 'get'
      - 'list'
  - apiGroups:
      - 'apps'
    resources:
      - 'deployments'
    verbs:
      - 'get'
      - 'list'
  - apiGroups:
      - '' # core
    resources:
      - 'namespaces'
    verbs:
      - 'get'
      - 'list'
sudermanjr commented 3 years ago

The rbac solution above should fix. Please reopen if not