From f40b8a1bfa410bba17df7f3e5e99f1ad5c841c3a Mon Sep 17 00:00:00 2001 From: Jerome Petazzoni Date: Fri, 12 Apr 2019 17:58:14 -0500 Subject: [PATCH] Add short section about metrics server --- slides/k8s/metrics-server.md | 66 ++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 slides/k8s/metrics-server.md diff --git a/slides/k8s/metrics-server.md b/slides/k8s/metrics-server.md new file mode 100644 index 00000000..c08b00d7 --- /dev/null +++ b/slides/k8s/metrics-server.md @@ -0,0 +1,66 @@ +# Checking pod and node resource usage + +- Since Kubernetes 1.8, metrics are collected by the [core metrics pipeline](https://v1-13.docs.kubernetes.io/docs/tasks/debug-application-cluster/core-metrics-pipeline/) + +- The core metrics pipeline is: + + - optional (Kubernetes can function without it) + + - necessary for some features (like the Horizontal Pod Autoscaler) + + - exposed through the Kubernetes API using the [aggregation layer](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/apiserver-aggregation/) + + - usually implemented by the "metrics server" + +--- + +## How to know if the metrics server is running? + +- The easiest way to know is to run `kubectl top` + +.exercise[ + +- Check if the core metrics pipeline is available: + ```bash + kubectl top nodes + ``` + +] + +If it shows our nodes and their CPU and memory load, we're good! + +--- + +## Installing metrics server + +- The metrics server doesn't have any particular requirement + + (it doesn't need persistence, as it doesn't *store* metrics) + +- It has its own repository, [kubernetes-incubator/metrics-server](https://github.com/kubernetes-incubator/metrics-server]) + +- The repository comes with [YAML files for deployment](https://github.com/kubernetes-incubator/metrics-server/tree/master/deploy/1.8%2B) + +- These files may not work on some clusters + + (e.g. if your node names are not in DNS) + +- The container.training repository has a [metrics-server.yaml](https://github.com/jpetazzo/container.training/blob/master/k8s/metrics-server.yaml#L90) file to help with that + + (we can `kubectl apply -f` that file if needed) + +--- + +## Showing container resource usage + +- Once metrics server is running, we can check container resource usage + +.exercise[ + +- Show resource usage accross all containers: + ```bash + kuebectl top pods --containers --all-namespaces + ``` +] + +- We can also use selectors (`-l app=...`)