1.下載dashboard: [root@master kubernetes]# wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta5/aio/deploy/recommended.yaml 2.修改配置文件: [root@master kubernetes]#vim 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 selector: k8s-app: kubernetes-dashboard [root@master kubernetes]# kubectl apply -f recommended.yaml
3.創建dashboard管理員: 創建key文件 openssl genrsa -out dashboard.key 2048 #證書請求 openssl req -days 36000 -new -out dashboard.csr -key dashboard.key -subj '/CN=dashboard-cert' #自簽證書 openssl x509 -req -in dashboard.csr -signkey dashboard.key -out dashboard.crt #創建kubernetes-dashboard-certs對象 kubectl create secret generic kubernetes-dashboard-certs --from-file=dashboard.key --from-file=dashboard.crt -n kubernetes-dashboard
[root@master dashboard-v2.0]# vim dashboard-admin.yaml apiVersion: v1 kind: ServiceAccount metadata: labels: k8s-app: kubernetes-dashboard name: dashboard-admin namespace: kubernetes-dashboard [root@master dashboard-v2.0]#kubectl apply -f dashboard-admin.yaml [root@master dashboard-v2.0]# vim dashboard-admin-bind-cluster-role.yaml apiVersion: rbac.authorization.k8s.io/v1beta1 kind: ClusterRoleBinding metadata: labels: k8s-app: kubernetes-dashboard name: dashboard-admin-bind-cluster-role roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: cluster-admin subjects: - kind: ServiceAccount name: dashboard-admin namespace: kubernetes-dashboard [root@master dashboard-v2.0]#kubectl apply -f dashboard-admin-bind-cluster-role.yaml [root@master dashboard-v2.0]#kubectl get secret -n kubernetes-dashboard [root@master dashboard-v2.0]# kubectl describe secret dashboard-admin-token-9rlc2 -n kubernetes-dashboard
測試訪問:https://node_ip:port
注意,此時獲取不到cpu,內存信息,因為沒有按照metrics-server.
安裝metrics-server:
1.下載鏡像: docker pull bluersw/metrics-server-amd64:v0.3.6 docker tag bluersw/metrics-server-amd64:v0.3.6 k8s.gcr.io/metrics-server-amd64:v0.3.6 2.下載聲明文件: wget https://raw.githubusercontent.com/kubernetes-incubator/metrics-server/master/deploy/1.8%2B/aggregated-metrics-reader.yaml wget https://raw.githubusercontent.com/kubernetes-incubator/metrics-server/master/deploy/1.8%2B/auth-delegator.yaml wget https://raw.githubusercontent.com/kubernetes-incubator/metrics-server/master/deploy/1.8%2B/auth-reader.yaml wget https://raw.githubusercontent.com/kubernetes-incubator/metrics-server/master/deploy/1.8%2B/metrics-apiservice.yaml wget https://raw.githubusercontent.com/kubernetes-incubator/metrics-server/master/deploy/1.8%2B/metrics-server-deployment.yaml wget https://raw.githubusercontent.com/kubernetes-incubator/metrics-server/master/deploy/1.8%2B/metrics-server-service.yaml wget https://raw.githubusercontent.com/kubernetes-incubator/metrics-server/master/deploy/1.8%2B/resource-reader.yaml
[root@master dashboard-v2.0]#vi metrics-server-deployment.yaml
[root@master metrics-server]# ll 總用量 32 -rw-r--r-- 1 root root 397 11月 18 23:33 aggregated-metrics-reader.yaml -rw-r--r-- 1 root root 303 11月 18 23:33 auth-delegator.yaml -rw-r--r-- 1 root root 324 11月 18 23:33 auth-reader.yaml -rw-r--r-- 1 root root 298 11月 18 23:33 metrics-apiservice.yaml -rw-r--r-- 1 root root 1230 11月 18 23:49 metrics-server-deployment.yaml -rw-r--r-- 1 root root 1129 11月 18 23:36 metrics-server-deployment.yaml.bak -rw-r--r-- 1 root root 297 11月 18 23:34 metrics-server-service.yaml -rw-r--r-- 1 root root 517 11月 18 23:34 resource-reader.yaml [root@master metrics-server]# kubectl apply -f ./
查看:
