Kubernetes Dashboard 设置用户(四)

Kubernetes Dashboard 设置用户

目录

Kubernetes Dashboard 设置用户

一、创建账号文件

二、修改配置kube-apiserver.yaml文件

三、修改recommended.yaml 就是dashboard部署文件


一、创建账号文件

在装过dashboard环境下。我们去master节点新增一个文件,如果是ha会有多个master,那么每个master同下操作。里面内容结构是:用户名,密码(用户名和密码要保持一致),唯一ID

[root@master ~]# echo "admin,admin,1" > /etc/kubernetes/pki/basic_auth_file

二、修改配置kube-apiserver.yaml文件

spec:
  containers:
  - command:
    - kube-apiserver
    ...
    - --basic-auth-file=/etc/kubernetes/pki/basic_auth_file  # 就这一行是我新增的。大家不要搞错

重新部署

[root@master ~]# kubectl apply -f /etc/kubernetes/manifests/kube-apiserver.yaml

创建集群角色权限绑定

[root@master ~]# kubectl create clusterrolebinding  login-on-dashboard-with-cluster-admin  --clusterrole=cluster-admin --user=admin

# 验证 
[root@master ~]# kubectl get clusterrolebinding login-on-dashboard-with-cluster-admin
NAME                                    ROLE                        AGE
login-on-dashboard-with-cluster-admin   ClusterRole/cluster-admin   6m

三、修改recommended.yaml 就是dashboard部署文件

args:
    - --auto-generate-certificates
    - --namespace=kubernetes-dashboard
    - --token-ttl=21600 #新增行 单位秒
    - --authentication-mode=basic #新增行

重新部署

[root@k8s-master kubernetes]# kubectl apply -f recommended.yaml
namespace/kubernetes-dashboard unchanged
serviceaccount/kubernetes-dashboard unchanged
service/kubernetes-dashboard unchanged
secret/kubernetes-dashboard-certs unchanged
secret/kubernetes-dashboard-csrf configured
Warning: kubectl apply should be used on resource created by either kubectl create --save-config or kubectl apply
secret/kubernetes-dashboard-key-holder configured
configmap/kubernetes-dashboard-settings unchanged
role.rbac.authorization.k8s.io/kubernetes-dashboard unchanged
clusterrole.rbac.authorization.k8s.io/kubernetes-dashboard unchanged
rolebinding.rbac.authorization.k8s.io/kubernetes-dashboard unchanged
clusterrolebinding.rbac.authorization.k8s.io/kubernetes-dashboard unchanged
deployment.apps/kubernetes-dashboard configured
service/dashboard-metrics-scraper unchanged
deployment.apps/dashboard-metrics-scraper unchanged

上一篇:部署Kubernetes Dashboard(三)

下一篇:使用RKE部署Kubernetes(五)

 

你可能感兴趣的:(kubernetes,docker,kubernetes,k8s,dashboard,docker)