Kubernetes Dashboard可視化插件和Heapster監控組件部署(二)

(一)、Dashboard可視化插件部署
在 Kubernetes Dashboard 中能夠查看集羣中應用的運行狀態,也可以建立和修改各類 Kubernetes 資源,好比 Deployment、Job、DaemonSet 等。用戶能夠 Scale Up/Down Deployment、執行 Rolling Update、重啓某個 Pod 或者經過嚮導部署新的應用。Dashboard 能顯示集羣中各類資源的狀態以及日誌信息。
能夠說,Kubernetes Dashboard 提供了 kubectl 的絕大部分功能,你們能夠根據狀況進行選擇。
github地址:
https://github.com/kubernetes/dashboard
具體步驟以下:
一、下載官方提供的Dashboard組件的yaml文件git

[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]

二、修改yaml文件中的鏡像
Kubernetes Dashboard可視化插件和Heapster監控組件部署(二)github

三、修改yaml文件中的Dashboard Service,使其對外可以訪問
Kubernetes Dashboard可視化插件和Heapster監控組件部署(二)
四、啓動Dashboard,並查看相關服務api

[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

五、訪問Dashboard。地址是必須添加https
Kubernetes Dashboard可視化插件和Heapster監控組件部署(二)
六、建立訪問用戶app

---
# ------------------- 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
---

七、獲取登錄dsahboard的令牌,登錄面板以下:ide

[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 用於計算並分析集羣資源利用率、監控集羣容器。
一、下載Heapster組件部署的yaml文件google

# 新建文件夾,用於存放 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

二、修改yaml中的image值,把k8s.gcr.io 所有修改成 registry.cn-hangzhou.aliyuncs.com/google_containersspa

三、部署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

四、查看效果
Kubernetes Dashboard可視化插件和Heapster監控組件部署(二)3d

相關文章
相關標籤/搜索