how to login dashboard with username & password in v1.19.2

11/18/2020

i have installed my k8s cluster, and have installed dashboard v2.0.4, and i can login dashboard with token.but how can i login it with username & password ?

please help me!

kubectl version:

Client Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.2", GitCommit:"f5743093fd1c663cb0cbc89748f730662345d44d", GitTreeState:"clean", BuildDate:"2020-09-16T13:41:02Z", GoVersion:"go1.15", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.2", GitCommit:"f5743093fd1c663cb0cbc89748f730662345d44d", GitTreeState:"clean", BuildDate:"2020-09-16T13:32:58Z", GoVersion:"go1.15", Compiler:"gc", Platform:"linux/amd64"}

i followed the doc https://kubernetes.io/docs/reference/access-authn-authz/abac/, and edit the api-servier's config file with

- --authorization-mode=RBAC,Node,ABAC
- --authorization-policy-file=/root/dashboard.policy.yaml

the dashboard.policy.yaml file content is {"apiVersion":"abac.authorization.kubernetes.io/v1beta1","kind":"Policy","spec":{"user":"admin","namespace":"*","resource":"*","apiGroup":"*","nonResourcePath":"*"}} but the api-server cannot start. telnet 192.168.1.5 6443 cannot connected.

i followed the doc enter link description here(Bootstrapping clusters with kubeadm), so have no kube-apiserver.service file, i restart my computer.

-- Hui
centos
dashboard
kubernetes

1 Answer

11/18/2020

You can use the Basic authentication:

Basic authentication is disabled by default. The reason is that Kubernetes API server needs to be configured with authorization mode ABAC and --basic-auth-file flag provided. Without that API server automatically falls back to anonymous user and there is no way to check if provided credentials are valid.

In order to enable basic auth in Dashboard --authentication-mode=basic flag has to be provided. By default it is set to --authentication-mode=token.

You need to configure Kubernetes to allow basic auth and accept username/password. Here is the reference.

After you make sure that you are able to i.e. use kubectl configured with username/password to access the cluster, you can enable basic auth for the Dashboard.

Here is a useful step by step guide showing how to install the Kubernetes Dashboard and enable the authentication using the username and password.

-- WytrzymaƂy Wiktor
Source: StackOverflow