A background

Many K8S applications are deployed in the generation environment. Therefore, a visual tool is required to obtain real-time cluster status and provide timely and accurate data support for troubleshooting. In this context, Weaveworks’ project Weave Scope, a visual monitoring tool for Docker and Kubernetes, emerged. Scope provides a complete top-down view of clustered infrastructure and applications. Users can easily monitor and troubleshoot distributed containerized applications in real time to ensure the stability and performance of containerized applications by viewing metrics/markers in container context, as well as raw data. The container that consumes the most CPU/ memory resources to run a service can be easily determined between processes within the container.

Two components detailed explanation

2.1 features

Weave Scope can monitor the status, resource usage, application topology, scale of a series of resources in kubernetes cluster. It can also directly enter the container through the browser for debugging.

  • Interactive topological interface
  • Graphic mode and table mode
  • Filter function
  • The search function
  • Real-time measurement
  • Container line fault
  • Plug-in extension

Composition of 2.2

Weave Scope consists of App and Probe:

  • Probe Agent is responsible for collecting container and host information and sending it to App

  • The App is responsible for processing this information and generating corresponding reports, which are presented in the form of an interactive interface

2.3 Deployment Mode

  1. weave-scope-agent, scope Agent program will run on each node of the cluster to collect data, and its deployment is DaemonSet mode.
  2. weave-scope-appScope application, which obtains data from agent, displays and interacts with users through Web UI, and is deployed in Deployment mode.
  3. weave-scope-app, the default type is ClusterIP for conveniencekubectl editModified toNodePort.

3 Installation and Deployment

3.1 Node Node Deployment

Weave Scope can initially be installed and deployed on hosts that run Docker containers

sudo curl -L git.io/scope -o /usr/local/bin/scope
sudo chmod a+x /usr/local/bin/scope
scope launch
Copy the code

Then access http:// host IP address :4040

3.2 K8s Resource file Deployment

kubectl apply -f "https://cloud.weave.works/k8s/scope.yaml? k8s-version=$(kubectl version | base64 | tr -d '\n')"
#Example Change SVC to NodePortkubectl patch svc $(kubectl get svc -n weave |grep weave-scope-app |awk '{print $1}') -p '{"spec":{"type": "NodePort"}}' -n weave [root@master ~]# kubectl get svc -n weave |grep weave-scope-app weave-scope-app NodePort 10.96.244.177 < none > 80:30156 / TCP 52 s
#Check out Weave's Pod[root@master ~]# kubectl get pod -n weave -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES Weave-scope-agent-49csj 1/1 Running 0 7m58s 10.234.2.204 master <none> <none> weave-scope-agent-lxjKB 1/1 Running 0 7m58s 10.234.2.132 node1 <none> <none> weave-scope-agent-wp22d 1/1 Running 0 7m58s 10.234.2.160 node2 <none> <none> Weave -scope-app- 85966885C8-9GF86 1/1 Running 0 7m59s 10.244.2.246 node2 <none> <none> Weave - scope-cluster-agent-5C9765fff6-hsl9r 1/1 Running 0 7m58s 10.244.2.247node2 <none> <none>Copy the code

3.2 helm deployment

At present, the Helm warehouse provides charts compiled by Weave-Scope, which can be fetched locally and installed after simple modification. It is very convenient and quick

[root@master common-service]# helm fetch stable/weave-scope [root@master common-service]# tar -zxvf Weave-scope-1.1.8. TGZ [root@master common-service]# sed -i "s @type :\ \"ClusterIP\" @type: \"NodePort\"@" weave-scope/values.yaml [root@master common-service]# helm install -n weave-scope --namespace common-service -f weave-scope/values.yaml weave-scope/ NAME: weave-scope LAST DEPLOYED: Thu Jan 30 18:37:14 2020 NAMESPACE: common-service STATUS: DEPLOYED RESOURCES: ==> v1/ConfigMap NAME DATA AGE weave-scope-weave-scope-tests 1 1s ==> v1/DaemonSet NAME DESIRED CURRENT READY UP-TO-DATE  AVAILABLE NODE SELECTOR AGE weave-scope-agent-weave-scope 4 4 0 4 0 <none> 1s ==> v1/Deployment NAME READY UP-TO-DATE AVAILABLE AGE weave-scope-cluster-agent-weave-scope 0/1 1 0 1s weave-scope-frontend-weave-scope 0/1 1 0 1s ==> v1/Pod(related) NAME READY STATUS RESTARTS AGE weave-scope-agent-weave-scope-5xskf 0/1 ContainerCreating 0 1s weave-scope-agent-weave-scope-76t2s 0/1 ContainerCreating 0 1s weave-scope-agent-weave-scope-qb74g 0/1 ContainerCreating  0 1s weave-scope-agent-weave-scope-zggff 0/1 ContainerCreating 0 1s weave-scope-cluster-agent-weave-scope-5b8bf77f5f-7jkhq 0/1 ContainerCreating 0 1s weave-scope-frontend-weave-scope-6d985ccff6-xmz2d 0/1 ContainerCreating 0 1s ==> v1/Service NAME TYPE CLUSTER-IP External-ip PORT(S) AGE weave-scope-weave-scope NodePort 10.233.41.4 < None > 80:31709/TCP 1s ==> v1/ServiceAccount NAME SECRETS AGE weave-scope-cluster-agent-weave-scope 1 1s ==> v1beta1/ClusterRole NAME AGE weave-scope-cluster-agent-weave-scope 1s ==> v1beta1/ClusterRoleBinding NAME AGE weave-scope-weave-scope 1s NOTES: You should now be able to access the Scope frontend in your web browser, by going to the address or hostname of any node in the cluster, using http and the port given by: SCOPE_PORT=$(kubectl -n common-service get svc weave-scope-weave-scope \ -o jsonpath='{.spec.ports[?(@.name==http)].nodePort}'); echo $SCOPE_PORT Most likely one or more of the URLs given by this pipeline will work: SCOPE_PORT=$(kubectl -n common-service get svc \ -o jsonpath='{.spec.ports[?(@.name==http)].nodePort}'); \ kubectl get nodes -o jsonpath='{.items[0].status.addresses[*].address}' | \ xargs -I{} -d" " echo http://{}:$SCOPE_PORT For more details on using Weave Scope, see the Weave Scope documentation: https://www.weave.works/docs/scope/latest/introducing/Copy the code

4 use

4.1 Viewing Resource Objects

Take POD resource objects as an example. Weave Scope monitors processes, containers, Pods, and hosts, and monitors CPU, memory, and load average.

4.1.1 Chart mode

4.1.2 Form method

4.2 Object Resource Usage

Clicking on a POD displays details about status, resource usage, processes, and so on

4.3 Log Information

Click get Logs of a specific POD to pop up the Terminal window to view logs

4.4 Description

Click describe on specific POD to view POD resource information through Terminal

4.5 Resource Scaling

Click on deployment Controllers to go to the Web interface to expand or zoom out and see the number and details of pods.

4.6 Container Operations

You can perform attach, exec shell, restart, PAUS, and stop operations on containers, as well as view container logs

4.7 Conditional Query

The lower left corner can be displayed according to conditions, including container type (system or application), container status (stopped or running), namespace, etc.

4.8 Search Function

4.8.1 name

4.8.2 Resource Usage

Five reflection

  • Weave Scope provides a concise visualization of service, Controller, pod and other resource object management and simple Web UI operations, facilitating troubleshooting and timely location
  • Weave Scope as a Web UI currently lacks login authentication. You can use other ways to authenticate the Web server for security control.

Refer to the link

  • cloud.weave.works/signup
  • www.weave.works/docs/
  • Github.com/weaveworks/…