Inspecting a container
Whenever our application behaves abnormally, we will definitely want to know what happened, using all means, such as checking logs, resource usage, processes watchdog, or even getting into the running host directly to dig problems out. In Kubernetes, we have kubectl get
and kubectl describe
that can query deployment states, which will help us determine if an application has crashed or works as desired.
Further, if we want to know what is going on from the outputs of an application, we also have kubectl logs
that redirects a container's stdout
to our Terminal. For CPU and memory usage stats, there's also a top-like command we can employ, kubectl top
. kubectl top node
, which gives an overview of the resource usages of nodes, and kubectl top pod <POD_NAME>
which displays per-pod usage:
# kubectl top node
NAME CPU(cores) CPU% MEMORY(bytes) MEMORY%
node-1 42m 4% 273Mi 12%
node-2 152m 15% 1283Mi...