image.png
# 拉镜像
docker pull registry.aliyuncs.com/google_containers/kubernetes-dashboard-amd64:v1.10.0
# 打标签
docker tag registry.aliyuncs.com/google_containers/kubernetes-dashboard-amd64:v1.10.0 k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.0
# 由于这种方式网址无法访问,所以采用手动下载的方式
# kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.0/src/deploy/recommended/kubernetes-dashboard.yaml
# 下载地址
https://github.com/kubernetes/dashboard/blob/v1.10.0/src/deploy/recommended/kubernetes-dashboard.yaml
# 修改对外暴露的端口
---------
type: NodePort # 158行
ports:
- port: 443
targetPort: 8443
nodePort: 30001 # 对外暴露端口30001
---------
# 应用配置
kubectl apply -f kubernetes-dashboard.yaml
# 查看pod,注意namespace为kube-system(2.x版本改成了kubernetes-dashboard)
kubectl get pods -n kube-system
# 查看pod详情
kubectl describe pods kubernetes-dashboard-79ff88449c-9xsz2 -n kube-system
# 创建账户
kubectl create serviceaccount dashboard-admin -n kube-system
# 创建角色
kubectl create clusterrolebinding dashboard-admin --clusterrole=cluster-admin --serviceaccount=kube-system:dashboard-admin
# 获取token
kubectl describe secrets -n kube-system $(kubectl -n kube-system get secret | awk '/dashboard-admin/{print $1}')
# 浏览器访问: https://k8s-01:30001
# 异常提示: 您的连接不是私密连接
# chrome快捷方式右键 -> 属性 -> 目标(T)最后加参数,注意空格
--test-type --ignore-certificate-errors
# 使用上面获取的token登录
网友评论