LAB09: Fetching Kubelet Metrics

LAB 20.1: Fetching Kubelet metric endpoint

STEP 0 — Start the Proxy (required)

kubectl proxy --port=8001

This opens a local gateway:

http://127.0.0.1:8001/

Now your curl commands DO NOT need TLS, CA bundles, or certs. API server authenticates you automatically.


STEP 1 — List All Nodes (raw JSON)

curl -s http://127.0.0.1:8001/api/v1/nodes | jq

Only print node names:

curl -s http://127.0.0.1:8001/api/v1/nodes \
  | jq -r '.items[].metadata.name'

Example output:

k8s-cluster-m1
k8s-cluster-w1
k8s-cluster-w2

STEP 2 — KUBELET SUMMARY METRICS (MAIN ENTRYPOINT)

This is where Metrics Server gets its data.

Replace <node> with one from above:

This gives:

  • CPU usage (node + pods + containers)

  • Memory usage

  • Network stats

  • Disk stats

  • Ephemeral storage

  • cgroup stats

This is the heart of kubelet metrics.


STEP 3 — List Pods on That Node (from kubelet)

This gives full pod specs as kubelet sees them.


STEP 4 — cAdvisor Metrics (raw Prometheus-style)

Yes — kubelet exposes cAdvisor through:

Curl it:

This prints ALL low-level container metrics in Prometheus format, including:

  • throttling

  • cgroup CPU stats

  • container memory pages

  • IO stats

  • filesystem stats

  • network packets

This is massive — hundreds of metrics.


STEP 5 — Kubelet Internal Metrics

From /metrics endpoint:

Expose kubelet internals:

  • pod lifecycle

  • garbage collector

  • volume plugin timing

  • runtime stats

  • kubelet request latency

  • pod admission latency


STEP 6 — Resource Metrics (new endpoint)

Contains:

  • container CPU usage

  • container memory usage

  • node CPU

  • node memory

Metrics Server reads from Summary API, not from this one. But Prometheus scrapes this too.


STEP 7 — Kubelet Health Endpoints

Live

Subsystems:


STEP 8 — Get Container Logs Directly via Kubelet

Format:

Example:


STEP 9 — Direct Logs of Kubelet (if exposed)

Some clusters expose:

(Not always available)


STEP 10 — FULL MENU of Kubelet Endpoints

Here is everything exposed behind kubelet’s secure port 10250, but through the API server proxy (so no TLS/Cert issues):

Endpoint
Purpose

/stats/summary

Main Metrics Server source

/metrics/cadvisor

Raw container metrics

/metrics/resource

Node+container CPU/mem

/metrics

Kubelet internal metrics

/pods

Pod list (as seen by kubelet)

/healthz

Kubelet health

/containerLogs/..

Pod/container logs

/configz

Kubelet config

/run/..

Runtime info

/debug/pprof/...

Profiling

You can curl all of these through:


Correct usage: You must get one of the API resources in that group

The API resources inside metrics.k8s.io/v1beta1 are:

Their resource names:

So you can do:


1. Get node metrics

or


2. Get pod metrics

or


3. Get schema via explain


Helpful Table (This will make everything click)

What you type
What it is
Valid?

metrics.k8s.io

API Group

❌ cannot kubectl get

metrics.k8s.io/v1beta1

GroupVersion

❌ cannot kubectl get

nodes.metrics.k8s.io

API Resource

✅ can kubectl get

pods.metrics.k8s.io

API Resource

✅ can kubectl get

NodeMetrics

Kind

❌ cannot kubectl get (unless plural)

PodMetrics

Kind

❌ cannot kubectl get


Final working commands

All node metrics:

All pod metrics:

Raw JSON:

Last updated