Skip to content

Latest commit

 

History

History
133 lines (97 loc) · 3.37 KB

b.logging_monitoring.md

File metadata and controls

133 lines (97 loc) · 3.37 KB

Logging/Monitoring (5%)

Curriculum

  • Understand how to monitor all cluster components. en
  • Understand how to monitor applications.
  • Manage cluster component logs. en
  • Manage application logs. en

Exercise

  1. Install the Kubernetes Metrics Server.

    show

    git clone https://github.com/kubernetes-incubator/metrics-server.git
    
    kubectl create -f  metrics-server/deploy/1.8+/

  2. 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     

  3. 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

  4. Report free disk space in the master node.

    show

    ssh master 'df -h'
    exit

  5. 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/

  6. Check the number of pods running in one node.

    show

    kubectl get pods --all-namespaces -o wide | grep <NODE_NAME> | wc -l

  7. 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>

  8. 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

  9. Printing only the logs since 30s.

    show

    kubectl logs generator-random-numbers --since=30s