- Understand how to monitor all cluster components.
- Understand how to monitor applications.
- Manage cluster component logs.
- Manage application logs.
-
Install the Kubernetes Metrics Server.
show
git clone https://github.com/kubernetes-incubator/metrics-server.git kubectl create -f metrics-server/deploy/1.8+/
-
Check how many nodes your cluster have. Describe one.
show
kubectl get nodes NAME STATUS ROLES AGE VERSION k8s-0001 Ready master,node 26d v1.9.2+coreos.0 k8s-0002 Ready master,node 26d v1.9.2+coreos.0 k8s-0003 Ready master,node 26d v1.9.2+coreos.0 k8s-0005 Ready node 26d v1.9.2+coreos.0 kubectl describe nodes k8s-0001
-
List the nodes with a custom columns (NAME, CAPACITY (CPU), CAPACITY (Memory)).
show
kubectl get nodes k8s-0001 -o=custom-columns=NAME:.metadata.name,CPU:.status.capacity.cpu,MEMORY:.status.capacity.memory
-
Report free disk space in the master node.
show
ssh master 'df -h' exit
-
Analyze the disk space usage in /etc/kubernetes/ repository.
show
du -h /etc/kubernetes/ 36K /etc/kubernetes/pki/etcd 96K /etc/kubernetes/pki 20K /etc/kubernetes/manifests 152K /etc/kubernetes/
-
Check the number of pods running in one node.
show
kubectl get pods --all-namespaces -o wide | grep <NODE_NAME> | wc -l
-
Check the request and limits memory of the API server pod.
show
kubectl describe pods <API_SERVER_POD_NAME> # Check the resources tag or kubectl get pods -n kube-system -o=jsonpath='{.metadata.name}{"\t"}{.spec.containers[*].resources.requests.memory}{"\t"}{.spec.containers[*].resources.limits.memory}' <API_SERVER_POD_NAME>
-
Create the following pod. Print Logs for a Container in a Pod.
kubectl create -f https://raw.githubusercontent.com/roxcarpio/cka-exercises/master/exercices/b.logging_monitoring/log-pod.yaml
show
kubectl logs generator-random-numbers
-
Printing only the logs since 30s.
show
kubectl logs generator-random-numbers --since=30s