Monitoring Kubernetes Cluster — Part I

First, let's clear our understanding of the resource types and unit of measure.

In Kubernetes, we can specify the maximum value of resources using “Limit” and request minimum resources using “Request” field in our defination YAML file.

1. CPU

Limits and requests for CPU resources are measured in cpu units. One cpu, in Kubernetes, is equivalent to 1 AWS vCPU or 1 GCP Core. We can specify a value for CPU resources in points. The expression 0.1 is equivalent to the expression 100m, which can be read as “one hundred millicpu”. Some people say “one hundred millicores”, and this is understood to mean the same thing.

2. Memory

Limits and requests for memory are measured in bytes. You can express memory as a plain integer or as a fixed-point integer using one of these suffixes: E, P, T, G, M, K. You can also use the power-of-two equivalents: Ei, Pi, Ti, Gi, Mi, Ki.

Difference between MiB and MB?

The megabyte is a multiple of the unit byte for digital information. Its recommended unit symbol is MB. The unit prefix mega is a multiplier of 1000000 (106) in the International System of Units (SI).[1] Therefore, one megabyte is one million bytes of information. This definition has been incorporated into the International System of Quantities.

3. Local ephemeral storage

FEATURE STATE: Kubernetes v1.16 beta

Kubernetes version 1.8 introduces a new resource, ephemeral-storage for managing local ephemeral storage. In each Kubernetes node, kubelet’s root directory (/var/lib/kubelet by default) and log directory (/var/log) are stored on the root partition of the node. This partition is also shared and consumed by Pods via emptyDir volumes, container logs, image layers and container writable layers.

What happens when we exceed limits,

If a Container exceeds its memory limit, it might be terminated. If it is restartable, the kubelet will restart it, as with any other type of runtime failure.

As our understanding of resource types is clear we will implement two of many methods to monitor our cluster.

1. Dashboard (Web UI)

The dashboard is a web-based Kubernetes user interface. You can use Dashboard to deploy containerized applications to a Kubernetes cluster, troubleshoot your containerized application, and manage the cluster resources. You can use Dashboard to get an overview of applications running on your cluster, as well as for creating or modifying individual Kubernetes resources (such as Deployments, Jobs, DaemonSets, etc).

$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta4/aio/deploy/recommended.yaml
kubectl proxy
kubectl -n kubernetes-dashboard describe secret

2. Kubernetes Metrics Server

Metric is a cluster-wide aggregator of resource usage data. Metric server collects metrics from the Summary API, exposed by Kubelet on each node. Metrics Server registered in the main API server through Kubernetes aggregator. This API doesn’t store the metric values, so it’s not possible for example to get the amount of resources used by a given node 10 minutes ago.

$ git clone https://github.com/skynet86/hello-world-k8s.git
$ kubectl create -f metrics-server.yaml
$ kubectl top nodes
$ kubectl top pods
# Different namespace
$ kubectl top pods -n kube-system

In the next blog, we will be exploring “Prometheus and Grafana”.

Thank You.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Bhargav Shah

Bhargav Shah

Cloud Solution Architect at Walmart Japan