Kubernetes Dashboard 部署应用以及访问
k8s dashbord
-
环境和版本说明:
centos7.6、docker-18.09.8、kubernetes-1.15.1、kubernetes-dashboard-v2.0.0-beta2
k8s和docker版本对应关系请查看链接: k8s-docker版本对应查看
kubernetes和kubernetes-dashboard版本对应关系查看:k8s-kubernetes-dashboard版本对应查看
-
hosts配置
在https://ipaddress.com/网址中查看raw.githubusercontent.com对应的ip,然后在hosts中进行配置
vim /etc/hosts
185.199.108.133 raw.githubusercontent.com
3.kubernetes-dashboard编排文件下载,并配置必要项
wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta2/aio/deploy/recommended.yaml
vim recommended.yaml 配置文件中进行三出修改:
第一处修改:添加对外暴露的端口
第二处修改:设置部署到master结点
第三处修改:
-
证书设置
依次执行如下命令
openssl genrsa -out dashboard.key 2048 #ip设置 openssl req -new -out dashboard.csr -key dashboard.key -subj '/CN=192.168.8.125' 192.168.8.125为主节点ip,根据需要这是你自己的即可 openssl x509 -req -in dashboard.csr -signkey dashboard.key -out dashboard.crt #删除之前的证书 kubectl delete secret kubernetes-dashboard-certs -n kube-system #删除旧的证书 kubectl delete secret kubernetes-dashboard-certs -n kubernetes-dashboard #创建新的证书 kubectl create secret generic kubernetes-dashboard-certs --from-file=dashboard.key --from-file=dashboard.crt -n kubernetes-dashboard
-
启动服务
kubectl apply -f recommended.yaml -
创建管理账户并绑定角色
vim dashboard-adminuser.yaml 创建文件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
执行创建并绑定:kubectl apply -f dashboard-adminuser.yaml
-
登录
https://masterip:3.修改一处中设置的port
查看并输出登录tokenkubectl -n kube-system describe $(kubectl -n kube-system get secret -n kube-system -o name | grep namespace) | grep token
更多推荐
所有评论(0)