k8s實踐(十):監控工具Weave Scope詳解

  • 2019 年 11 月 1 日
  • 筆記

環境說明:

主機名

作業系統版本

ip

docker version

kubelet version

配置

備註

master

Centos 7.6.1810

172.27.9.131

Docker 18.09.6

V1.14.2

2C2G

master主機

node01

Centos 7.6.1810

172.27.9.135

Docker 18.09.6

V1.14.2

2C2G

node節點

node02

Centos 7.6.1810

172.27.9.136

Docker 18.09.6

V1.14.2

2C2G

node節點

一、Weave Scope簡介

Weave Scope自動生成應用程式的映射,使您能夠直觀地理解、監視和控制基於容器化微服務的應用程式。

Weave Scope可以監控kubernetes集群中的一系列資源的狀態、資源使用情況、應用拓撲、scale、還可以直接通過瀏覽器進入容器內部調試等,其提供的功能包括:

互動式拓撲介面 圖形模式和表格模式 過濾功能 搜索功能 實時度量 容器排錯 插件擴展

Weave Scope由App和Probe兩部分組成:

Probe 負責收集容器和宿主的資訊,並發送給 App App 負責處理這些資訊,並生成相應的報告,並以交互介面的形式展示

二、Weave Scope安裝

1.安裝Weave Scopea

[root@master ~]# kubectl apply -f "https://cloud.weave.works/k8s/scope.yaml?k8s-version=$(kubectl version | base64 | tr -d 'n')"  namespace/weave created  serviceaccount/weave-scope created  clusterrole.rbac.authorization.k8s.io/weave-scope created  clusterrolebinding.rbac.authorization.k8s.io/weave-scope created  deployment.apps/weave-scope-app created  service/weave-scope-app created  deployment.apps/weave-scope-cluster-agent created  daemonset.apps/weave-scope-agent created
圖片.png

2.資源查看

[root@master ~]# kubectl get all -n weave  NAME                                            READY   STATUS    RESTARTS   AGE  pod/weave-scope-agent-hx4t2                     1/1     Running   0          103s  pod/weave-scope-agent-vmbqr                     1/1     Running   0          103s  pod/weave-scope-agent-zd8x7                     1/1     Running   0          103s  pod/weave-scope-app-b99fb9585-77rld             1/1     Running   0          104s  pod/weave-scope-cluster-agent-58f5b5454-vnckm   1/1     Running   0          103s    NAME                      TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)   AGE  service/weave-scope-app   ClusterIP   10.99.31.182   <none>        80/TCP    105s    NAME                               DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR   AGE  daemonset.apps/weave-scope-agent   3         3         3       3            0           <none>          104s    NAME                                        READY   UP-TO-DATE   AVAILABLE   AGE  deployment.apps/weave-scope-app             1/1     1            1           105s  deployment.apps/weave-scope-cluster-agent   1/1     1            1           105s    NAME                                                  DESIRED   CURRENT   READY   AGE  replicaset.apps/weave-scope-app-b99fb9585             1         1         1       105s  replicaset.apps/weave-scope-cluster-agent-58f5b5454   1         1         1       105s
圖片.png

3.對外訪問

修改service/weave-scope-app,將其模式由ClusterIP修改為NodePort,使其可以直接通過NodeIP:Port方式訪問

[root@master ~]# kubectl edit service -n weave weave-scope-app  service/weave-scope-app edited
圖片.png

4.登錄

登錄url:http://172.27.9.131:30022/

圖片.png

三、使用Weave Scope

1.資源查看的兩種方式

以pod為例查看資源,資源有兩種展現形式:

圖形式性:

圖片.png

圖形方式還會展示pod之間的拓撲關係

圖片.png

表格形式:

圖片.png

Weave Scope監控對象有進程、容器、pods、主機等,監控項有cpu、記憶體、平均負載等。

2.查看資源使用詳情

點擊某個pod,會展示狀態、資源使用、進程等詳細資訊

圖片.png

3.pod日誌查看

資源使用詳情中點擊'Get logs'

圖片.png
圖片.png

4.pod描述查看

圖片.png
圖片.png

5.資源伸縮

圖片.png

點擊deployment類型的Controllers,可以進行deployment的伸縮和查看

6.容器操作

圖片.png

可以對容器進行attach、exec shell、restart、paus和stop操作

圖片.png

進入容器,執行df -h操作

7.展示條件選擇

圖片.png

左下角可按條件展示,有容器類型(系統或者應用)、容器狀態(停止或者運行)、命名空間等。

8.搜索功能

按容器名搜索

圖片.png

按資源使用搜索

圖片.png