发布时间: 2023-6-20 文章作者: myluzh 分类名称: Kubernetes 朗读文章
[root@master]# mkdir k8s-dashboard && cd k8s-dashboard [root@master k8s-dashboard]# wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.5.1/aio/deploy/recommended.yaml在Service中增加type: NodePort与nodePort: 32000
[root@master k8s-dashboard]# vi recommended.yaml kind: Service apiVersion: v1 metadata: labels: k8s-app: kubernetes-dashboard name: kubernetes-dashboard namespace: kubernetes-dashboard spec: type: NodePort ports: - port: 443 targetPort: 8443 nodePort: 32000 selector: k8s-app: kubernetes-dashboard
[root@master k8s-dashboard]# kubectl apply -f recommended.yaml2.查看pod状态
[root@master k8s-dashboard]# kubectl get pod -A kubernetes-dashboard dashboard-metrics-scraper-799d786dbf-5qd6t 1/1 Running 0 85m kubernetes-dashboard kubernetes-dashboard-fb8648fd9-cvttf 1/1 Running 0 85m如果状态是而是ImagePullBackOff则需要更新下docker加速源,错误比较简单,镜像下载失败,要么网络设置有问题,要么没有设置镜像源,另外一个比较隐蔽的问题是,当你在集群环境下,假设有3个节点,那么这三个节点都要设置镜像源,因为 kubectl run命令默认可以在任一个节点上安装,而不是命令在哪个节点上执行!
编辑docker配置文件 [root@master k8s-dashboard]# vi /etc/docker/daemon.json 加入"registry-mirrors":["https://docker.mirrors.ustc.edu.cn"] 重载配置文件重启docker生效 [root@master k8s-dashboard]# systemctl daemon-reload [root@master k8s-dashboard]# systemctl restart docker 删除后重新创建下 [root@master k8s-dashboard]# kubectl delete -f recommended.yaml [root@master k8s-dashboard]# kubectl apply -f recommended.yaml
[root@master k8s-dashboard]# kubectl get clusterrolebindings kubernetes-dashboard NAME ROLE AGE kubernetes-dashboard ClusterRole/kubernetes-dashboard 15m修改权限
[root@master k8s-dashboard]# kubectl create clusterrolebinding dashboard-cluster-admin --clusterrole=cluster-admin --serviceaccount=kubernetes-dashboard:kubernetes-dashboard
[root@master k8s-dashboard]# kubectl -n kubernetes-dashboard describe secret $(kubectl -n kubernetes-dashboard get secret | grep admin-user | awk '{print $1}')
标签: k8s dashboard kubernetes
发表评论