美文网首页
Kubernetes 安装dashboard v2.0.4

Kubernetes 安装dashboard v2.0.4

作者: jinbulee | 来源:发表于2020-09-28 17:03 被阅读0次

1、在github上找到yaml地址

https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.4/aio/deploy/recommended.yaml

2、下载yaml文件

wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.4/aio/deploy/recommended.yaml

修改yaml 文件中的Service ,添加type类型为NodePort ,并添加nodePort端口

yaml

3、执行安装

kubectl apply -f recommended.yaml

4、创建 serviceaccount
方法一:
直接执行如下命令

kubectl create serviceaccount dashboard-admin -n kube-system

方法二:
添加如下yaml文件并执行:kubectl apply -f dashboard-sa.yaml

# cat dashboard-sa.yaml

apiVersion: v1

kind: ServiceAccount

metadata:

 name: dashboard-admin

 namespace: kubernetes-dashboard 

5、创建clusterrolebinding为dashboard sa授权集群权限cluster-admin

方法一:
执行如下命令:

kubectl create clusterrolebinding dashboard-admin --clusterrole=cluster-admin --serviceaccount=kube-system:dashboard-admin

方法二:
创建如下yaml文件并执行 kubectl apply -f dashboard-clusterrolebinding.yaml

apiVersion: rbac.authorization.k8s.io/v1

kind: ClusterRoleBinding

metadata:

  name: dashboard-admin

roleRef:

  apiGroup: rbac.authorization.k8s.io

  kind: ClusterRole

  name: cluster-admin

subjects:- kind: ServiceAccount

  name: dashboard-admin

  namespace: kubernetes-dashboard

执行完成后,根据dashboard所在节点登陆:ip:30001 (端口根据前面自定义的端口填写)
提示:使用火狐浏览器访问
查看dashboard所在node 可以用

kubectl get pods -A -o wide 

然后找到dashboard 所在的node节点

登陆

使用token 登陆

获取token

kubectl describe secrets -n kube-system $(kubectl -n kube-system get secret | awk '/dashboard-admin/{print $1}')
token

登陆成功

登陆成功.png

相关文章

网友评论

      本文标题:Kubernetes 安装dashboard v2.0.4

      本文链接:https://www.haomeiwen.com/subject/lkzduktx.html