部署 Dashboard

返回目录

部署 Dashboard

  1. 修改host
    vim /etc/hosts,添加如下内容:

192.30.253.112 github.com
192.30.253.119 gist.github.com
151.101.100.133 assets-cdn.github.com
151.101.100.133 raw.githubusercontent.com
151.101.100.133 gist.githubusercontent.com
151.101.100.133 cloud.githubusercontent.com
151.101.100.133 camo.githubusercontent.com
151.101.100.133 avatars0.githubusercontent.com
151.101.100.133 avatars1.githubusercontent.com
151.101.100.133 avatars2.githubusercontent.com
151.101.100.133 avatars3.githubusercontent.com
151.101.100.133 avatars4.githubusercontent.com
151.101.100.133 avatars5.githubusercontent.com
151.101.100.133 avatars6.githubusercontent.com
151.101.100.133 avatars7.githubusercontent.com
151.101.100.133 avatars8.githubusercontent.com

下载
curl -kfLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta1/aio/deploy/recommended.yaml --no-check-certificate

修改recommended.yaml
sed -i ‘/namespace/ s/kubernetes-dashboard/kube-system/g’ recommended.yaml

vim recommended.yaml
添加40行和44行的内容

type: NodePort
nodePort: 30001

vim 中 set nu可以显示行号
部署 Dashboard_第1张图片

改名
mv recommended.yaml dashboard-recommended.yaml
启动kubernetes-dashboard
docker pull kubernetes/dashboard
kubectl apply -f dashboard-recommended.yaml
kubectl get pods,svc -n kube-system -o wide

如果镜像下载失败,可以去阿里镜像站手动下载
http://mirrors.aliyun.com

下载的是rmp文件,需要在linux中打包成tar.gz文件才可被docker导入
打包:
tar -cvf kubernetes-dashboard-27408f19-4.4.x86_64.tar.gz kubernetes-dashboard-27408f19-4.4.x86_64.rpm
导入:
docker import kubernetes-dashboard-27408f19-4.4.x86_64.tar.gz kubernetesui/dashboard:4.4

kubectl get pod
找到dashboard

访问kubernetes-dashboard
在那台机器就用哪台的ip
https://192.168.50.200:30001

部署 Dashboard_第2张图片
选择用token

创建SA并绑定默认cluster-admin管理员集群角色

创建管理员用户

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

在这里插入图片描述
获取token值
查找管理员用户的token名字
kubectl get secret -n kube-system |grep dashboard-admin
在这里插入图片描述
kubectl describe secret dashboard-admin -n kube-system
部署 Dashboard_第3张图片
将token后面的值复制到登录界面
部署 Dashboard_第4张图片
展示效果
部署 Dashboard_第5张图片

Dashboard部署完成

你可能感兴趣的:(Java学习,kubernetes)