Metrics Server + cAdvisor monitors cluster resource consumption
Metrics Server is a cluster-wide resource usage data aggregator; deployed as an application in the cluster, Metrics Server collects metrics from the kubelet API-Server on each node and registers it in the Master APIServer through the k8s aggregator;
Resource address:
- Kubernetes Metrics Server:https://github.com/kubernetes-sigs/metrics-server
- cAdvisor:https://github.com/google/cadvisor
chait@k8s-master01:~$ kubectl top
Display Resource (CPU/Memory/Storage) usage.
The top command allows you to see the resource consumption for nodes or pods.
This command requires Metrics Server to be correctly configured and working on the server.
Available Commands:
node Display Resource (CPU/Memory/Storage) usage of nodes
pod Display Resource (CPU/Memory/Storage) usage of pods
Usage:
kubectl top [flags] [options]
Use "kubectl <command> --help" for more information about a given command.
Use "kubectl options" for a list of global command-line options (applies to all commands).
chait@k8s-master01:~$
- View cluster resource consumption information=》# kubectl top [flags] [options]
Install metrics-server
Directly use the command [kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml] installation may fail due to network reasons;
Can be performed step by step:
- Download yaml resources=》# wget https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
- Modify yaml resource name=》# sudo mv components.yaml metrics-server.yaml
- View yaml information=》# vim metrics-server.yaml
- Modify the yaml mirror address=》Mark the position as shown in the figure below (args parameter & image mirror) to add parameters and modify the mirror access address, you can download the mirror resource to the private warehouse first;
- Run the command to install=》# kubectl apply -f metrics-server.yaml
spec:
containers:
- args:
- --cert-dir=/tmp
- --secure-port=4443
- --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname
- --kubelet-use-node-status-port
image: k8s.gcr.io/metrics-server/metrics-server:v0.4.1
args parameter description:
- cert-dir specifies the certificate directory
- secure-port open secure port
- kubelet-preferred-address-types Use InternalIP, ExternalIP, Hostname to connect to kubelet
- kubelet-use-node-status-port Use node status port
args parameter added:
- kubelet-insecure-tls does not verify the https certificate/ca provided by kubelet
After the modification is saved, run the command to install: =》# kubectl apply -f metrics-server.yaml
View cluster resource consumption information:
- # kubectl top node
- # kubectl top pod
Metrics-server + cAdvisor displays resource (CPU/memory/storage) usage.
Manage k8s component logs
- k8s system component log
- Application logs deployed in k8s cluster
- Standard output
- Log file