Monitoring cluster with Weave Scope
Creating a kubernetes cluster and deploying containerized applications is just the first step. Once the cluster is running, we need to ensure that all necessary components are in place and perform their duties together, and that there are enough resources to meet the application requirements. Kubernetes is a complex system. The operation and maintenance team needs a set of tools to help them know the real-time status of the cluster and provide timely and accurate data support for troubleshooting.
Kubernetes common monitoring scheme
Weave Scope
Weave Scope is a visualized monitoring tool for Docker and Kubernetes. Scope provides a complete view of the cluster infrastructure and applications from the top to the bottom. Users can easily monitor and diagnose the distributed containerized applications in real time.
Install Scope
The method to install Scope is simple. Execute the following command:
kubectl apply -f "https://cloud.weave.works/k8s/scope.yaml?k8s-version=$(kubectl version | base64 | tr -d '\n')&k8s-service-type=NodePort"
After successful deployment, there are the following related components:
[root@k8s-master ~]# kubectl apply -f "https://cloud.weave.works/k8s/scope.yaml?k8s-version=$(kubectl version | base64 | tr -d '\n')&k8s-service-type=NodePort" namespace/weave unchanged serviceaccount/weave-scope created clusterrole.rbac.authorization.k8s.io/weave-scope configured clusterrolebinding.rbac.authorization.k8s.io/weave-scope configured deployment.apps/weave-scope-app created service/weave-scope-app created deployment.apps/weave-scope-cluster-agent created daemonset.apps/weave-scope-agent created [root@k8s-master ~]# kubectl get pod -n weave NAME READY STATUS RESTARTS AGE weave-scope-agent-bct26 1/1 Running 0 30s weave-scope-agent-vzdbr 0/1 ContainerCreating 0 30s weave-scope-agent-xvwsp 0/1 ContainerCreating 0 30s weave-scope-app-cf544d8c4-v9x5z 1/1 Running 0 30s weave-scope-cluster-agent-6466d94ccf-r4vql 0/1 ContainerCreating 0 30s [root@k8s-master ~]# kubectl get pod -n weave NAME READY STATUS RESTARTS AGE weave-scope-agent-bct26 1/1 Running 0 57s weave-scope-agent-vzdbr 1/1 Running 0 57s weave-scope-agent-xvwsp 1/1 Running 0 57s weave-scope-app-cf544d8c4-v9x5z 1/1 Running 0 57s weave-scope-cluster-agent-6466d94ccf-r4vql 1/1 Running 0 57s [root@k8s-master ~]# kubectl get svc -n weave NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE weave-scope-app NodePort 10.108.59.226 <none> 80:31013/TCP 68s [root@k8s-master ~]# kubectl get deployments. -n weave NAME READY UP-TO-DATE AVAILABLE AGE weave-scope-app 1/1 1 1 81s weave-scope-cluster-agent 1/1 1 1 80s
Daemonset weave scope agent, the scope agent program that runs on each node of the cluster, is responsible for collecting data.
Deployment web scope app, a scope application, obtains data from agent s, displays it through Web UI and interacts with users.
Service weave scope app, the default is ClusterIP type, and the parameter k8s service type = NodePort has been added to the above command to modify it to NodePort.
Using Scope
Browser access http://192.168.56.106:31013/,Scope By default, all current controllers (Deployment, DaemonSet, etc.) are displayed.
topological structure
Scope automatically builds the logical topology of applications and clusters. For example, click PODS at the top to display all PODS and their dependencies.
Click HOSTS to display the relationship between each node.
Real time resource monitoring
You can view the CPU and memory usage of resources in Scope.
Supported resources are Host, Pod, and Container.
Online operation
Scope also provides convenient online operation functions, such as selecting a Host and clicking the > button can directly open the command line terminal of the node in the browser:
Click + of Deployment to perform Scale Up operation:
You can view the log of the Pod:
You can attach, restart, stop containers, and troubleshoot problems directly in Scope:
Powerful search capabilities
Scope supports keyword search and locating resources.
You can also perform conditional searches, such as finding and locating pods with memory > 100m.
The Weave Scope interface is extremely friendly and the operation is simple and smooth.