(一)、Dashboard可视化插件部署
在 Kubernetes Dashboard 中可以查看集群中应用的运行状态,也能够创建和修改各种 Kubernetes 资源,比如 Deployment、Job、DaemonSet 等。用户可以 Scale Up/Down Deployment、执行 Rolling Update、重启某个 Pod 或者通过向导部署新的应用。Dashboard 能显示集群中各种资源的状态以及日志信息。
可以说,Kubernetes Dashboard 提供了 kubectl 的绝大部分功能,大家可以根据情况进行选择。
github地址:
https://github.com/kubernetes/dashboard
具体步骤如下:
1、下载官方提供的Dashboard组件的yaml文件

[root@DEV004021 ~]# wget http://mirror.faasx.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml
--2019-08-13 10:58:15--  http://mirror.faasx.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml
Resolving mirror.faasx.com (mirror.faasx.com)... 101.89.125.212, 101.89.125.213, 101.89.125.214, ...
Connecting to mirror.faasx.com (mirror.faasx.com)|101.89.125.212|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4734 (4.6K) [text/yaml]
Saving to: ‘kubernetes-dashboard.yaml’

100%[===========================================================================================>] 4,734       --.-K/s   in 0s      

2019-08-13 10:58:15 (12.4 MB/s) - ‘kubernetes-dashboard.yaml’ saved [4734/4734]

2、修改yaml文件中的镜像
Kubernetes Dashboard可视化插件和Heapster监控组件部署(二)

3、修改yaml文件中的Dashboard Service,使其对外能够访问
Kubernetes Dashboard可视化插件和Heapster监控组件部署(二)
4、启动Dashboard,并查看相关服务

[root@DEV004021 opt]# kubectl apply -f kubernetes-dashboard.yaml 
secret/kubernetes-dashboard-certs unchanged
clusterrolebinding.rbac.authorization.k8s.io/admin-user unchanged
role.rbac.authorization.k8s.io/kubernetes-dashboard-minimal unchanged
rolebinding.rbac.authorization.k8s.io/kubernetes-dashboard-minimal unchanged
deployment.apps/kubernetes-dashboard unchanged
service/kubernetes-dashboard unchanged
[root@DEV004021 opt]# kubectl --namespace=kube-system get deployment kubernetes-dashboard
NAME                   READY   UP-TO-DATE   AVAILABLE   AGE
kubernetes-dashboard   1/1     1            1           3d19h
[root@DEV004021 opt]# kubectl --namespace=kube-system get service kubernetes-dashboard
NAME                   TYPE       CLUSTER-IP    EXTERNAL-IP   PORT(S)         AGE
kubernetes-dashboard   NodePort   10.1.104.20   <none>        443:31111/TCP   3d19h

5、访问Dashboard。地址是必须添加https
Kubernetes Dashboard可视化插件和Heapster监控组件部署(二)
6、创建访问用户

---
# ------------------- Dashboard Service Account ------------------- #

apiVersion: v1
kind: ServiceAccount
metadata:
  name: admin-user
  namespace: kube-system
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: admin-user
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: admin-user
  namespace: kube-system
---

7、获取登陆dsahboard的令牌,登陆面板如下:

[root@DEV004021 opt]# kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}')

Kubernetes Dashboard可视化插件和Heapster监控组件部署(二)

(二)、监控组件Heapster部署。
Heapster 用于计算并分析集群资源利用率、监控集群容器。
1、下载Heapster组件部署的yaml文件

# 新建文件夹,用于存放 Heapster 部署所需的 yaml 文件
mkdir heapster
cd heapster

# 获取相关 yaml 文件
wget https://raw.githubusercontent.com/kubernetes/heapster/master/deploy/kube-config/influxdb/grafana.yaml
wget https://raw.githubusercontent.com/kubernetes/heapster/master/deploy/kube-config/influxdb/heapster.yaml
wget https://raw.githubusercontent.com/kubernetes/heapster/master/deploy/kube-config/influxdb/influxdb.yaml
wget https://raw.githubusercontent.com/kubernetes/heapster/master/deploy/kube-config/rbac/heapster-rbac.yaml

2、修改yaml中的image值,把k8s.gcr.io 全部修改为 registry.cn-hangzhou.aliyuncs.com/google_containers

3、部署Heapster

[root@DEV004021 heapster]# kubectl create -f /opt/heapster/
deployment.extensions/monitoring-grafana created
service/monitoring-grafana created
clusterrolebinding.rbac.authorization.k8s.io/heapster created
serviceaccount/heapster created
deployment.extensions/heapster created
service/heapster created
deployment.extensions/monitoring-influxdb created
service/monitoring-influxdb created

4、查看效果
Kubernetes Dashboard可视化插件和Heapster监控组件部署(二)