Difference between revisions of "Kubernetes/Monitoring"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
= Monitor cluster resources = | = Monitor cluster resources = | ||
== Metric-server == | |||
In order to get cluster resources you need a metric collector plugin. Popular one is <tt>heapster</tt> that exposes <tt>metric-server</tt> service. The below commands relay on its API to get data: | In order to get cluster resources you need a metric collector plugin. Popular one is <tt>heapster</tt> that exposes <tt>metric-server</tt> service. The below commands relay on its API to get data: | ||
Line 19: | Line 20: | ||
kubectl top pod <pod-name> # CPU,memory of a specific pod | kubectl top pod <pod-name> # CPU,memory of a specific pod | ||
kubectl top pods group-context --containers # CPU,memory of the containers inside the pod | kubectl top pods group-context --containers # CPU,memory of the containers inside the pod | ||
</source> | |||
== cAdvisor == | |||
Every node in a Kubernetes cluster has a Kubelet process. Within each Kubelet is a cAdvisor process. The cAdvisor is continuously gathering metrics about the state of the cluster. It's always available | |||
<source lang=bash> | |||
minikube start --extra-config=kubelet.CAdvisorPort=4194 | |||
kubectl proxy & # open a proxy to the Kubernetes API port | |||
# Each node provide statistics that are provided by cAdvisor. Access the node stats | |||
curl localhost:8001/api/v1/nodes/$(kubectl get nodes -o=jsonpath="{.items[0].metadata.name}")/proxy/stats/ | |||
# Kubernetes API also gather the cAdvisor metrics at /metrics | |||
curl localhost:8001/metrics | |||
</source> | </source> | ||
Revision as of 23:51, 1 October 2019
Monitor cluster resources
Metric-server
In order to get cluster resources you need a metric collector plugin. Popular one is heapster that exposes metric-server service. The below commands relay on its API to get data:
Install metrics-server
git clone https://github.com/kubernetes-incubator/metrics-server.git kubectl apply -f ~/metrics-server/deploy/1.8+/
Get metrics
# verify metrics server API kubectl get --raw /apis/metrics.k8s.io/ kubectl top node # CPU,memory utilization of the nodes in your cluster kubectl top pods # CPU,memory utilization of the pods in your cluster kubectl top pods -A # CPU,memory of pods in all namespaces kubectl top pod -l run=<label> # CPU and memory of pods with a label selector: kubectl top pod <pod-name> # CPU,memory of a specific pod kubectl top pods group-context --containers # CPU,memory of the containers inside the pod
cAdvisor
Every node in a Kubernetes cluster has a Kubelet process. Within each Kubelet is a cAdvisor process. The cAdvisor is continuously gathering metrics about the state of the cluster. It's always available
minikube start --extra-config=kubelet.CAdvisorPort=4194 kubectl proxy & # open a proxy to the Kubernetes API port # Each node provide statistics that are provided by cAdvisor. Access the node stats curl localhost:8001/api/v1/nodes/$(kubectl get nodes -o=jsonpath="{.items[0].metadata.name}")/proxy/stats/ # Kubernetes API also gather the cAdvisor metrics at /metrics curl localhost:8001/metrics
Liveness and Readiness probes
Check this Visual explanation
Get service endpoints
kubectl get endpoint