Weave Scope是Docker和Kubernetes可是化监控工具。Scope提供了至上而下的集群基础设施和应用的完整视图,使你能够直观地理解,监视和控制相关应用程序。

Weave Scope功能及组成

提供的功能包括:

  • 交互式拓扑界面
  • 图形模式和表格模式
  • 过滤功能
  • 搜索功能
  • 实时度量
  • 容器排错
  • 插件扩展

Weave Scope由App和probe两部分组成:

  • probe负责收集容器和宿主机的信息,并发送给App
  • App负责处理这些信息,并生成相应的报告,并以交互界面的形式展示

Weave Scope安装

  • 安装Weave Scope
1
2
3
4
5
6
7
8
9
[root@k8s-77-40 ~]# 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
  • 查看资源
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
[root@k8s-77-40 ~]# kubectl get all -n weave
NAME                                             READY   STATUS    RESTARTS   AGE
pod/weave-scope-agent-8gbhj                      1/1     Running   0          78s
pod/weave-scope-agent-n466h                      1/1     Running   0          78s
pod/weave-scope-agent-w4zrc                      1/1     Running   0          78s
pod/weave-scope-app-7b679dfc-8k6kz               1/1     Running   0          78s
pod/weave-scope-cluster-agent-6c64567585-sncd6   1/1     Running   0          78s

NAME                      TYPE        CLUSTER-IP    EXTERNAL-IP   PORT(S)   AGE
service/weave-scope-app   ClusterIP   10.69.23.30   <none>        80/TCP    78s

NAME                               DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR   AGE
daemonset.apps/weave-scope-agent   3         3         3       3            3           <none>          78s

NAME                                        READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/weave-scope-app             1/1     1            1           78s
deployment.apps/weave-scope-cluster-agent   1/1     1            1           78s

NAME                                                   DESIRED   CURRENT   READY   AGE
replicaset.apps/weave-scope-app-7b679dfc               1         1         1       78s
replicaset.apps/weave-scope-cluster-agent-6c64567585   1         1         1       78s
  • 设置对外访问

默认的service是ClusterIP方式,需要改成NodePort

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
[root@k8s-77-40 ~]# kubectl edit service -n weave weave-scope-app

......
spec:
  clusterIP: 10.69.23.30
  ports:
  - name: app
    port: 80
    protocol: TCP
    nodePort: 31080  #增加这行
    targetPort: 4040
  selector:
    app: weave-scope
    name: weave-scope-app
    weave-cloud-component: scope
    weave-scope-component: app
  sessionAffinity: None
  type: NodePort  # 此处修改为NodePort,默认是ClusterIP
  ......
  • 查看svc
1
2
3
[root@k8s-77-40 ~]# kubectl get svc -n weave
NAME              TYPE       CLUSTER-IP    EXTERNAL-IP   PORT(S)        AGE
weave-scope-app   NodePort   10.69.23.30   <none>        80:31080/TCP   6m53s

访问Weave Scope

  • url:http://172.16.77.40:31080

Gkq9Te.png

使用Weave Scope

  • 图表模式

GkLDUg.png

  • 表格模式

GkLI54.png

  • pod信息查看

GkO0Q1.png

  • 日志查看

GkO2JH.png

  • yaml描述查看

GkOoef.png

  • 资源伸缩

GkXFfJ.png

  • 容器操作

可以对容器进行attach、exec shell、restart、paus、stop操作

GkXdAS.png

Weave Scope界面及其友好,操作简介流畅,更多功能可以自己去仔细探索一下

参考链接

官方文档