How can I tell with kubectl
how much ephemeral storage a pod is currently using?
In a Kubernetes pod spec, I can specify resource requests and limits for CPU, memory, and ephemeral storage:
resources:
requests:
memory: "60Mi"
cpu: "70m"
ephemeral-storage: "2Gi"
limits:
memory: "65Mi"
cpu: "75m"
ephemeral-storage: "4Gi"
However, to set good requests and limits on ephemeral storage, I need to know what this value actually is for a running pod, which I can't figure out. I can get CPU and memory usage using kubectl top pod
, but, from what I can tell, ephemeral storage usage is only actually calculated when making an actual eviction decision.
The pure raw approach for this is to use the disk usage (du) Unix command line.
Shell into your pod:
Change dirs to the mount point of your ephemeral-storage (if you are using volume mounts):
If you are not using volume mounts:
There are other tools that you can use to get metrics:
cAdvisor also embedded into the kubelet code, exposed under the
/stats/summary
or/metrics
endpoint. More info here. An example output:Similarly:
More info on kubelet authentication/authorization.
Prometheus
More info on K8s metrics here.