Kubernetes Dashboard 从v2.0.0-beta1版本开始,集成了一个metrics-scraper的组件,可以通过 Kubernetes 的 Metrics API 收集一些基础资源的监控信息,并在web页面展示
下载文件
1 | wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta6/aio/deploy/recommended.yaml |
使用 openssl 签发证书
1 | mkdir certs |
安装 Dashboard
创建namespace
1 | kubectl create namespace kubernetes-dashboard |
导入证书
1 | kubectl create secret generic kubernetes-dashboard-certs --from-file=certs -n kubernetes-dashboard |
修改recommended.yaml
注释namespace
1
2
3
4apiVersion: v1
kind: Namespace
metadata:
name: kubernetes-dashboard使用自签发的证书
使用自签发的证书,注释掉 kubernetes-dashboard-certs 的 Secret 定义1
2
3
4
5
6
7
8apiVersion: v1
kind: Secret
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard-certs
namespace: kubernetes-dashboard
type: Opaque部署
1
kubectl create -f recommended.yaml
使用 NodePort 暴露服务
新建 external-https-svc.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15cat >external-https-svc.yaml<<EOF
kind: Service
apiVersion: v1
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard-external
namespace: kubernetes-dashboard
spec:
type: NodePort
ports:
- port: 443
targetPort: 8443
selector:
k8s-app: kubernetes-dashboard部署
1
kubectl create -f external-https-svc.yaml
查看验证
1
2
3
4
5
6
7
8
9
10# kubectl get svc,pods -n kubernetes-dashboard
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/dashboard-metrics-scraper ClusterIP 10.254.199.169 <none> 8000/TCP 9m50s
service/kubernetes-dashboard ClusterIP 10.254.73.119 <none> 443/TCP 9m51s
service/kubernetes-dashboard-external NodePort 10.254.169.250 <none> 443:32318/TCP 11m
NAME READY STATUS RESTARTS AGE
pod/dashboard-metrics-scraper-69fcc6d9df-4lctd 1/1 Running 0 9m49s
pod/kubernetes-dashboard-77d4694b5f-vkgfz 1/1 Running 0 9m49s
使用之前的密钥认证登录,未出图,查了一下,说的是兼容问题,v1.15.0以上就没问题