K8S安装kubernetes-dashboard

GitHub地址:https://github.com/kubernetes/dashboard

执行官方最新yaml文件

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

可能github官方无法访问,可以使用我的git

kubectl apply -f https://git.cnbugs.com/mrtom/kubernetes/raw/commit/2b7bf3d350e23b272f48b0fa2f6dd98ee79d52ac/kubernetes-dashboard.yaml

创建认证令牌RBAC

cat >>dashboard-admin.yaml<<EOF
apiVersion: v1
kind: ServiceAccount
metadata:
  name: admin-user
  namespace: kubernetes-dashboard
EOF
kubectl apply -f dashboard-admin.yaml

创建集群角色

cat >> dashboard-ClusterRoleBinding.yaml <<EOF
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 dashboard-ClusterRoleBinding.yaml

获取token

kubectl -n kubernetes-dashboard describe secret $(kubectl -n kubernetes-dashboard get secret | grep admin-user | awk '{print $1}')

修改service的ClusterIP为NodePort

kubectl edit  service kubernetes-dashboard -n  kubernetes-dashboard

查看登录端口号

使用token进行登录即可

发表评论

后才能评论