Skip to content

Instantly share code, notes, and snippets.

@mattfenwick
Last active July 31, 2020 13:26
How to set up the kubernetes dashboard in your cluster

Based on https://github.com/kubernetes/dashboard.

  1. install the dashboard in your cluster:

    kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.3/aio/deploy/recommended.yaml
    
  2. run a proxy:

    kubectl proxy
    
  3. Go to http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/, where it will ask you for a token. You won't be able to get in yet.

  4. Following these instructions, create a service account and a cluster role binding:

    cat << EOF > dashboard-service-account.yaml
    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: admin-user
      namespace: kubernetes-dashboard
    EOF
    
    kubectl apply -f dashboard-service-account.yaml
    
    cat << EOF > dashboard-cluster-role-binding.yaml
    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRoleBinding
    metadata:
      name: admin-user
    roleRef:
      apiGroup: rbac.authorization.k8s.io
      kind: ClusterRole
      name: cluster-admin
    subjects:
    - kind: ServiceAccount
      name: admin-user
      namespace: kubernetes-dashboard
    EOF
    
    kubectl apply -f dashboard-cluster-role-binding.yaml
    
  5. Copy the token from the following command, and paste it into your browser:

    kubectl -n kubernetes-dashboard describe secret $(kubectl -n kubernetes-dashboard get secret | grep admin-user | awk '{print $1}')
    
  6. Now you should be up and running, remember to turn on 'all namespaces' if you're not seeing anything!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment