Kubernetes - login to kubernetes dashboard issue

7/11/2020

So I'm trying to bring up my kubernetes dashboard (remote server) but I'm having issues. How do I resolve this issue?

  1. using https://github.com/kubernetes/dashboard

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

  2. Created a ServiceAccount

    kubectl create serviceaccount dashboard-admin-sa

  3. Created an RBAC profile

    kubectl create clusterrolebinding dashboard-admin-sa --clusterrole=cluster-admin --serviceaccount=default:dashboard-admin-sa

When I load the page I get this not the kubernetes dashboard

{
  "paths": [
    "/apis",
    "/apis/",
    "/apis/apiextensions.k8s.io",
    "/apis/apiextensions.k8s.io/v1",
    "/apis/apiextensions.k8s.io/v1beta1",
    "/healthz",
    "/healthz/etcd",
    "/healthz/log",
    "/healthz/ping",
    "/healthz/poststarthook/crd-informer-synced",
    "/healthz/poststarthook/generic-apiserver-start-informers",
    "/healthz/poststarthook/start-apiextensions-controllers",
    "/healthz/poststarthook/start-apiextensions-informers",
    "/livez",
    "/livez/etcd",
    "/livez/log",
    "/livez/ping",
    "/livez/poststarthook/crd-informer-synced",
    "/livez/poststarthook/generic-apiserver-start-informers",
    "/livez/poststarthook/start-apiextensions-controllers",
    "/livez/poststarthook/start-apiextensions-informers",
    "/metrics",
    "/openapi/v2",
    "/readyz",
    "/readyz/etcd",
    "/readyz/log",
    "/readyz/ping",
    "/readyz/poststarthook/crd-informer-synced",
    "/readyz/poststarthook/generic-apiserver-start-informers",
    "/readyz/poststarthook/start-apiextensions-controllers",
    "/readyz/poststarthook/start-apiextensions-informers",
    "/readyz/shutdown",
    "/version"
  ]
}

Details:

kubectl config view

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: DATA+OMITTED
    server: https://100.xx.xx.x27:6443
  name: kubernetes
contexts:
- context:
    cluster: kubernetes
    user: kubernetes-admin
  name: kubernetes-admin@kubernetes
current-context: kubernetes-admin@kubernetes
kind: Config
preferences: {}
users:
- name: kubernetes-admin
  user:
    client-certificate-data: REDACTED
    client-key-data: REDACTED

kubectl get svc --all-namespaces

NAMESPACE              NAME                        TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                  AGE
default                kubernetes                  ClusterIP   10.96.0.1        <none>        443/TCP                  7h19m
kube-system            kube-dns                    ClusterIP   10.96.0.10       <none>        53/UDP,53/TCP,9153/TCP   7h19m
kubernetes-dashboard   dashboard-metrics-scraper   ClusterIP   10.110.162.231   <none>        8000/TCP                 84m
kubernetes-dashboard   kubernetes-dashboard        ClusterIP   10.104.136.25    <none>        443/TCP                  84m

kubectl get pods --all-namespaces

NAMESPACE              NAME                                                     READY   STATUS    RESTARTS   AGE
kube-system            coredns-66bff467f8-jk8ql                                 1/1     Running   1          7h27m
kube-system            coredns-66bff467f8-wxsnf                                 1/1     Running   1          7h27m
kube-system            etcd-ip-100-xx-xx-x27                      1/1     Running   1          7h28m
kube-system            kube-apiserver-ip-100-xx-xx-x27            1/1     Running   1          7h28m
kube-system            kube-controller-manager-ip-100-xx-xx-x27   1/1     Running   1          7h28m
kube-system            kube-proxy-vbddf                                         1/1     Running   1          7h27m
kube-system            kube-scheduler-ip-100-xx-xx-x27            1/1     Running   1          7h28m
kube-system            weave-net-cfk2m                                          2/2     Running   3          7h27m
kubernetes-dashboard   dashboard-metrics-scraper-6b4884c9d5-fwljp               1/1     Running   0          93m
kubernetes-dashboard   kubernetes-dashboard-7f99b75bf4-x2hpq                    1/1     Running   0          93m
-- Lacer
kubernetes

1 Answer

7/15/2020

Here is the really good guide which i would suggest to follow for setting up kubernetes dashaboard - https://jhooq.com/setting-up-kubernetes-dashboard/#kubernetes-dashboard-local-cluster

But what i see here is -

  1. Keep the kubectl proxy running otherwise you will not be able to access the dashboard and it might result in http 404
  2. Also check the validity of the token.
  3. Check the service account, here is what i used for service account
cat <<EOF | kubectl create -f -
apiVersion: v1
kind: ServiceAccount
metadata:
  name: admin-user
  namespace: kube-system
EOF
  1. ClusterRoleBinding
cat <<EOF | kubectl create -f -
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: kube-system
EOF

I hope it should solve your issue. If not then please check the guide and compare your steps which you did while setting up the dashboard

-- Rahul Wagh
Source: StackOverflow