diff --git a/images/weave-scope-service-topology.jpg b/images/weave-scope-service-topology.jpg new file mode 100644 index 000000000..ba3759fa8 Binary files /dev/null and b/images/weave-scope-service-topology.jpg differ diff --git a/manifests/weave/kube-system b/manifests/weave/kube-system new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/manifests/weave/kube-system @@ -0,0 +1 @@ + diff --git a/manifests/weave/scope.yaml b/manifests/weave/scope.yaml new file mode 100644 index 000000000..8b95a5ff4 --- /dev/null +++ b/manifests/weave/scope.yaml @@ -0,0 +1,199 @@ +apiVersion: v1 +kind: List +items: + - apiVersion: v1 + kind: ServiceAccount + metadata: + name: weave-scope + annotations: + cloud.weave.works/launcher-info: |- + { + "server-version": "master-38521be", + "original-request": { + "url": "/k8s/v1.6/scope.yaml?k8s-version=Q2xpZW50IFZlcnNpb246IHZlcnNpb24uSW5mb3tNYWpvcjoiMSIsIE1pbm9yOiI2IiwgR2l0VmVyc2lvbjoidjEuNi4wIiwgR2l0Q29tbWl0OiJmZmY1MTU2MDkyYjU2ZTZiZDYwZmZmNzVhYWQ0ZGM5ZGU2YjZlZjM3IiwgR2l0VHJlZVN0YXRlOiJjbGVhbiIsIEJ1aWxkRGF0ZToiMjAxNy0wMy0yOFQxNjozNjozM1oiLCBHb1ZlcnNpb246ImdvMS43LjUiLCBDb21waWxlcjoiZ2MiLCBQbGF0Zm9ybToibGludXgvYW1kNjQifQpTZXJ2ZXIgVmVyc2lvbjogdmVyc2lvbi5JbmZve01ham9yOiIxIiwgTWlub3I6IjYiLCBHaXRWZXJzaW9uOiJ2MS42LjAiLCBHaXRDb21taXQ6ImZmZjUxNTYwOTJiNTZlNmJkNjBmZmY3NWFhZDRkYzlkZTZiNmVmMzciLCBHaXRUcmVlU3RhdGU6ImNsZWFuIiwgQnVpbGREYXRlOiIyMDE3LTAzLTI4VDE2OjI0OjMwWiIsIEdvVmVyc2lvbjoiZ28xLjcuNSIsIENvbXBpbGVyOiJnYyIsIFBsYXRmb3JtOiJsaW51eC9hbWQ2NCJ9Cg==", + "date": "Wed Jul 12 2017 02:25:45 GMT+0000 (UTC)" + }, + "email-address": "support@weave.works" + } + labels: + name: weave-scope + - apiVersion: rbac.authorization.k8s.io/v1beta1 + kind: ClusterRole + metadata: + name: weave-scope + annotations: + cloud.weave.works/launcher-info: |- + { + "server-version": "master-38521be", + "original-request": { + "url": "/k8s/v1.6/scope.yaml?k8s-version=Q2xpZW50IFZlcnNpb246IHZlcnNpb24uSW5mb3tNYWpvcjoiMSIsIE1pbm9yOiI2IiwgR2l0VmVyc2lvbjoidjEuNi4wIiwgR2l0Q29tbWl0OiJmZmY1MTU2MDkyYjU2ZTZiZDYwZmZmNzVhYWQ0ZGM5ZGU2YjZlZjM3IiwgR2l0VHJlZVN0YXRlOiJjbGVhbiIsIEJ1aWxkRGF0ZToiMjAxNy0wMy0yOFQxNjozNjozM1oiLCBHb1ZlcnNpb246ImdvMS43LjUiLCBDb21waWxlcjoiZ2MiLCBQbGF0Zm9ybToibGludXgvYW1kNjQifQpTZXJ2ZXIgVmVyc2lvbjogdmVyc2lvbi5JbmZve01ham9yOiIxIiwgTWlub3I6IjYiLCBHaXRWZXJzaW9uOiJ2MS42LjAiLCBHaXRDb21taXQ6ImZmZjUxNTYwOTJiNTZlNmJkNjBmZmY3NWFhZDRkYzlkZTZiNmVmMzciLCBHaXRUcmVlU3RhdGU6ImNsZWFuIiwgQnVpbGREYXRlOiIyMDE3LTAzLTI4VDE2OjI0OjMwWiIsIEdvVmVyc2lvbjoiZ28xLjcuNSIsIENvbXBpbGVyOiJnYyIsIFBsYXRmb3JtOiJsaW51eC9hbWQ2NCJ9Cg==", + "date": "Wed Jul 12 2017 02:25:45 GMT+0000 (UTC)" + }, + "email-address": "support@weave.works" + } + labels: + name: weave-scope + rules: + - apiGroups: + - '*' + resources: + - '*' + verbs: + - '*' + - nonResourceURLs: + - '*' + verbs: + - '*' + - apiVersion: rbac.authorization.k8s.io/v1beta1 + kind: ClusterRoleBinding + metadata: + name: weave-scope + annotations: + cloud.weave.works/launcher-info: |- + { + "server-version": "master-38521be", + "original-request": { + "url": "/k8s/v1.6/scope.yaml?k8s-version=Q2xpZW50IFZlcnNpb246IHZlcnNpb24uSW5mb3tNYWpvcjoiMSIsIE1pbm9yOiI2IiwgR2l0VmVyc2lvbjoidjEuNi4wIiwgR2l0Q29tbWl0OiJmZmY1MTU2MDkyYjU2ZTZiZDYwZmZmNzVhYWQ0ZGM5ZGU2YjZlZjM3IiwgR2l0VHJlZVN0YXRlOiJjbGVhbiIsIEJ1aWxkRGF0ZToiMjAxNy0wMy0yOFQxNjozNjozM1oiLCBHb1ZlcnNpb246ImdvMS43LjUiLCBDb21waWxlcjoiZ2MiLCBQbGF0Zm9ybToibGludXgvYW1kNjQifQpTZXJ2ZXIgVmVyc2lvbjogdmVyc2lvbi5JbmZve01ham9yOiIxIiwgTWlub3I6IjYiLCBHaXRWZXJzaW9uOiJ2MS42LjAiLCBHaXRDb21taXQ6ImZmZjUxNTYwOTJiNTZlNmJkNjBmZmY3NWFhZDRkYzlkZTZiNmVmMzciLCBHaXRUcmVlU3RhdGU6ImNsZWFuIiwgQnVpbGREYXRlOiIyMDE3LTAzLTI4VDE2OjI0OjMwWiIsIEdvVmVyc2lvbjoiZ28xLjcuNSIsIENvbXBpbGVyOiJnYyIsIFBsYXRmb3JtOiJsaW51eC9hbWQ2NCJ9Cg==", + "date": "Wed Jul 12 2017 02:25:45 GMT+0000 (UTC)" + }, + "email-address": "support@weave.works" + } + labels: + name: weave-scope + roleRef: + kind: ClusterRole + name: weave-scope + apiGroup: rbac.authorization.k8s.io + subjects: + - kind: ServiceAccount + name: weave-scope + namespace: kube-system + - apiVersion: apps/v1beta1 + kind: Deployment + metadata: + name: weave-scope-app + annotations: + cloud.weave.works/launcher-info: |- + { + "server-version": "master-38521be", + "original-request": { + "url": "/k8s/v1.6/scope.yaml?k8s-version=Q2xpZW50IFZlcnNpb246IHZlcnNpb24uSW5mb3tNYWpvcjoiMSIsIE1pbm9yOiI2IiwgR2l0VmVyc2lvbjoidjEuNi4wIiwgR2l0Q29tbWl0OiJmZmY1MTU2MDkyYjU2ZTZiZDYwZmZmNzVhYWQ0ZGM5ZGU2YjZlZjM3IiwgR2l0VHJlZVN0YXRlOiJjbGVhbiIsIEJ1aWxkRGF0ZToiMjAxNy0wMy0yOFQxNjozNjozM1oiLCBHb1ZlcnNpb246ImdvMS43LjUiLCBDb21waWxlcjoiZ2MiLCBQbGF0Zm9ybToibGludXgvYW1kNjQifQpTZXJ2ZXIgVmVyc2lvbjogdmVyc2lvbi5JbmZve01ham9yOiIxIiwgTWlub3I6IjYiLCBHaXRWZXJzaW9uOiJ2MS42LjAiLCBHaXRDb21taXQ6ImZmZjUxNTYwOTJiNTZlNmJkNjBmZmY3NWFhZDRkYzlkZTZiNmVmMzciLCBHaXRUcmVlU3RhdGU6ImNsZWFuIiwgQnVpbGREYXRlOiIyMDE3LTAzLTI4VDE2OjI0OjMwWiIsIEdvVmVyc2lvbjoiZ28xLjcuNSIsIENvbXBpbGVyOiJnYyIsIFBsYXRmb3JtOiJsaW51eC9hbWQ2NCJ9Cg==", + "date": "Wed Jul 12 2017 02:25:45 GMT+0000 (UTC)" + }, + "email-address": "support@weave.works" + } + labels: + name: weave-scope-app + app: weave-scope + weave-cloud-component: scope + weave-scope-component: app + spec: + replicas: 1 + template: + metadata: + labels: + name: weave-scope-app + app: weave-scope + weave-cloud-component: scope + weave-scope-component: app + spec: + containers: + - name: app + args: + - '--no-probe' + image: 'weaveworks/scope:1.5.1' + imagePullPolicy: IfNotPresent + ports: + - containerPort: 4040 + protocol: TCP + - apiVersion: v1 + kind: Service + metadata: + name: weave-scope-app + annotations: + cloud.weave.works/launcher-info: |- + { + "server-version": "master-38521be", + "original-request": { + "url": "/k8s/v1.6/scope.yaml?k8s-version=Q2xpZW50IFZlcnNpb246IHZlcnNpb24uSW5mb3tNYWpvcjoiMSIsIE1pbm9yOiI2IiwgR2l0VmVyc2lvbjoidjEuNi4wIiwgR2l0Q29tbWl0OiJmZmY1MTU2MDkyYjU2ZTZiZDYwZmZmNzVhYWQ0ZGM5ZGU2YjZlZjM3IiwgR2l0VHJlZVN0YXRlOiJjbGVhbiIsIEJ1aWxkRGF0ZToiMjAxNy0wMy0yOFQxNjozNjozM1oiLCBHb1ZlcnNpb246ImdvMS43LjUiLCBDb21waWxlcjoiZ2MiLCBQbGF0Zm9ybToibGludXgvYW1kNjQifQpTZXJ2ZXIgVmVyc2lvbjogdmVyc2lvbi5JbmZve01ham9yOiIxIiwgTWlub3I6IjYiLCBHaXRWZXJzaW9uOiJ2MS42LjAiLCBHaXRDb21taXQ6ImZmZjUxNTYwOTJiNTZlNmJkNjBmZmY3NWFhZDRkYzlkZTZiNmVmMzciLCBHaXRUcmVlU3RhdGU6ImNsZWFuIiwgQnVpbGREYXRlOiIyMDE3LTAzLTI4VDE2OjI0OjMwWiIsIEdvVmVyc2lvbjoiZ28xLjcuNSIsIENvbXBpbGVyOiJnYyIsIFBsYXRmb3JtOiJsaW51eC9hbWQ2NCJ9Cg==", + "date": "Wed Jul 12 2017 02:25:45 GMT+0000 (UTC)" + }, + "email-address": "support@weave.works" + } + labels: + name: weave-scope-app + app: weave-scope + weave-cloud-component: scope + weave-scope-component: app + spec: + ports: + - name: app + port: 80 + protocol: TCP + targetPort: 4040 + selector: + name: weave-scope-app + app: weave-scope + weave-cloud-component: scope + weave-scope-component: app + - apiVersion: extensions/v1beta1 + kind: DaemonSet + metadata: + name: weave-scope-agent + annotations: + cloud.weave.works/launcher-info: |- + { + "server-version": "master-38521be", + "original-request": { + "url": "/k8s/v1.6/scope.yaml?k8s-version=Q2xpZW50IFZlcnNpb246IHZlcnNpb24uSW5mb3tNYWpvcjoiMSIsIE1pbm9yOiI2IiwgR2l0VmVyc2lvbjoidjEuNi4wIiwgR2l0Q29tbWl0OiJmZmY1MTU2MDkyYjU2ZTZiZDYwZmZmNzVhYWQ0ZGM5ZGU2YjZlZjM3IiwgR2l0VHJlZVN0YXRlOiJjbGVhbiIsIEJ1aWxkRGF0ZToiMjAxNy0wMy0yOFQxNjozNjozM1oiLCBHb1ZlcnNpb246ImdvMS43LjUiLCBDb21waWxlcjoiZ2MiLCBQbGF0Zm9ybToibGludXgvYW1kNjQifQpTZXJ2ZXIgVmVyc2lvbjogdmVyc2lvbi5JbmZve01ham9yOiIxIiwgTWlub3I6IjYiLCBHaXRWZXJzaW9uOiJ2MS42LjAiLCBHaXRDb21taXQ6ImZmZjUxNTYwOTJiNTZlNmJkNjBmZmY3NWFhZDRkYzlkZTZiNmVmMzciLCBHaXRUcmVlU3RhdGU6ImNsZWFuIiwgQnVpbGREYXRlOiIyMDE3LTAzLTI4VDE2OjI0OjMwWiIsIEdvVmVyc2lvbjoiZ28xLjcuNSIsIENvbXBpbGVyOiJnYyIsIFBsYXRmb3JtOiJsaW51eC9hbWQ2NCJ9Cg==", + "date": "Wed Jul 12 2017 02:25:45 GMT+0000 (UTC)" + }, + "email-address": "support@weave.works" + } + labels: + name: weave-scope-agent + app: weave-scope + weave-cloud-component: scope + weave-scope-component: agent + spec: + template: + metadata: + labels: + name: weave-scope-agent + app: weave-scope + weave-cloud-component: scope + weave-scope-component: agent + spec: + containers: + - name: agent + args: + - '--no-app' + - '--probe.docker.bridge=docker0' + - '--probe.docker=true' + - '--probe.kubernetes=true' + - >- + $(WEAVE_SCOPE_APP_SERVICE_HOST):$(WEAVE_SCOPE_APP_SERVICE_PORT) + image: 'weaveworks/scope:1.5.1' + imagePullPolicy: IfNotPresent + securityContext: + privileged: true + volumeMounts: + - name: docker-socket + mountPath: /var/run/docker.sock + - name: scope-plugins + mountPath: /var/run/scope/plugins + hostNetwork: true + hostPID: true + serviceAccountName: weave-scope + tolerations: + - effect: NoSchedule + operator: Exists + volumes: + - name: docker-socket + hostPath: + path: /var/run/docker.sock + - name: scope-plugins + hostPath: + path: /var/run/scope/plugins + updateStrategy: + type: RollingUpdate diff --git a/practice/monitor.md b/practice/monitor.md index 0b86bda06..e03338798 100644 --- a/practice/monitor.md +++ b/practice/monitor.md @@ -188,6 +188,51 @@ Kubernetes中应用的监控架构如图: - 直接访问应用的Pod的IP和端口获取应用监控数据 - metrics发送到[OWL](https://github.com/talkingdata/owl)中存储和展示 +## 应用拓扑状态图 + +对于复杂的应用编排和依赖关系,我们希望能够有清晰的图标一览应用状态和拓扑关系,因此我们用到了Weaveworks开源的[scope](https://github.com/weaveworks/scope)。 + +**安装scope** + +我们在kubernetes集群上使用standalone方式安装,详情参考[Installing Weave Scope](https://www.weave.works/docs/scope/latest/installing/#k8s)。 + +使用[scope.yaml](../manifests/weave/scope.yaml)文件安装scope,该服务安装在`kube-system` namespace下。 + +```Bash +$ kubectl apply -f scope.yaml +``` + +创建一个新的Ingress:`kube-system.yaml`,配置如下: + +```yaml +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: traefik-ingress + namespace: kube-system +spec: + rules: + - host: scope.weave.io + http: + paths: + - path: / + backend: + serviceName: weave-scope-app + servicePort: 80 +``` + +执行`kubectl apply -f kube-system.yaml`后在你的主机上的`/etc/hosts`文件中添加一条记录: + +``` +172.20.0.119 scope.weave.io +``` + +在浏览器中访问`scope.weave.io`就可以访问到scope了,详见[边缘节点配置](edge-node-configuration.md)。 + +![应用拓扑图](../images/weave-scope-service-topology.jpg) + +如上图所示,scope可以监控kubernetes集群中的一系列资源的状态、资源使用情况、应用拓扑、scale、还可以直接通过浏览器进入容器内部调试等。 + ## 参考 [Monitoring in the Kubernetes Era](https://www.datadoghq.com/blog/monitoring-kubernetes-era/) \ No newline at end of file