k8s部署Dashboard面板
Posted sunnyyangwang
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了k8s部署Dashboard面板相关的知识,希望对你有一定的参考价值。
Kubernetes Dashboard部署
参考:https://github.com/kubernetes/dashboard
https://www.jianshu.com/p/5ff6e26d1912
[[email protected] yaml]# cd dashboard/
[[email protected] dashboard]# wget https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml
报错:
Warning Failed 8m34s kubelet, node2 Failed to pull image "k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.1": rpc error: code = Unknown desc = Error response from daemon: Get https://k8s.gcr.io/v1/_ping: dial tcp 74.125.203.82:443: getsockopt: connection refused
处理:
[[email protected] ~]# docker pull mirrorgooglecontainers/kubernetes-dashboard-amd64:v1.10.1
[[email protected] ~]# docker tag mirrorgooglecontainers/kubernetes-dashboard-amd64:v1.10.1 k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.1
Google镜像操作:从国内某站下载镜像,到本地再上传到个人dockerhub站点。
[[email protected] ~]# docker tag mirrorgooglecontainers/kubernetes-dashboard-amd64:v1.10.1 szsunny/kubernetes-dashboard-amd64:v1.10.1
[[email protected] ~]# docker push szsunny/kubernetes-dashboard-amd64:v1.10.1
镜像推送到私有仓库。
查看,推送成功,
Node节点下载镜像。
[[email protected] ~]# docker pull szsunny/kubernetes-dashboard-amd64:v1.10.1
[[email protected] ~]# docker tag szsunny/kubernetes-dashboard-amd64:v1.10.1 k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.1
[[email protected] ~]#
多个节点均有执行此操作。
重新部署项目。
[[email protected] dashboard]# kubectl delete -f kubernetes-dashboard.yaml
[[email protected] dashboard]# kubectl create -f kubernetes-dashboard.yaml
[[email protected] ~]# kubectl get pods -n kube-system |grep dashboard
kubernetes-dashboard-57df4db6b-g4zgd 1/1 Running 0 64s
查看服务并访问,
[[email protected] ~]# kubectl get svc -n kube-system
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kube-dns ClusterIP 10.96.0.10 <none> 53/UDP,53/TCP 13d
kubernetes-dashboard ClusterIP 10.107.243.13 <none> 443/TCP 11m
[[email protected] ~]# curl https://10.107.243.13 --insecure
默认是Clusterip地址,外部不能直接访问。
可以打补丁,使用nodeport暴露实现,也可使用ingress-nginx实现。
先以为打补丁方式使用nodeport方式实现。
打补丁只会修改临时文件,不会修改器原始yml文件
[[email protected] dashboard]# kubectl patch svc kubernetes-dashboard -p ‘{"spec":{"type":"NodePort"}}‘ -n kube-system
[[email protected] dashboard]# kubectl edit svc/kubernetes-dashboard -n kube-system
选择Firefox浏览器登录页面。
使用默认的账号kubernetes-dashboard的Token登陆,会提示权限不足,
[[email protected] ~]# kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep kubernetes-dashboard | awk ‘{print $1}‘)
创建自己的账号登录,
[[email protected] dashboard]# kubectl create -f dash-cluster-admin.yaml
[[email protected] ~]# kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk ‘{print $1}‘)
页面查看,正常显示。自此,nodeport暴露dashboard方式已经实现。
通过ingress-nginx暴露,参考后期ingress配置。
以上是关于k8s部署Dashboard面板的主要内容,如果未能解决你的问题,请参考以下文章