k8s-部署Dashboard (仪表板)
本文章是 k8s二进制高可用集群部署 的分支。详细步骤请参考目录。
官方介绍:https://kubernetes.io/zh-cn/docs/tasks/access-application-cluster/web-ui-dashboard/
1.部署
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml # 查看部署 kubectl get pods,svc -n kubernetes-dashboard
2.修改DashBoard的Service端口暴露模式为NodePort
kubectl edit service kubernetes-dashboard -n kubernetes-dashboard
4.创建Service Account 及 ClusterRoleBinding并绑定默认cluster-admin管理员集群角色
参考地址:https://github.com/kubernetes/dashboard/blob/master/docs/user/access-control/creating-sample-user.md
cat > auth.yaml << EOF apiVersion: v1 kind: ServiceAccount metadata: name: admin-user namespace: kubernetes-dashboard --- 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 auth.yaml
4.访问
#查看暴露端口
kubectl get svc -n kubernetes-dashboard
#获取访问Token
kubectl -n kubernetes-dashboard create token admin-user
使用输出的token登录Dashboard:
访问地址:https://NodeIP:Port