The kubectl describe command is an invaluable tool for inspecting the detailed configuration and runtime state of Kubernetes objects like pods, deployments, and services. It is very useful for troubleshooting issues in a Kubernetes cluster.
The describe command works for any Kubernetes object kind such as nodes, namespaces, ingresses, etc. - not just pods. It is commonly combined with grep to extract specific details from the verbose output. Moreover, we can make the describe command even more powerful by passing flags to it in combination with grep.
1) -i flag → The -i flag enables case-insensitive matching for the regular expression pattern.
Syntax
kubectl describe <object_type> <obejct_name> | grep -i "keyword_you_are_searching"
Example
kubectl describe pod pod1 | grep -i "image"
2) -A flag → The -A flag is used to print lines of trailing context after matching lines.
Syntax
kubectl describe <object_type> <obejct_name> | grep -i -A <no_of_lines_you_want_to_print> "keyword_you_are_searching"
Example
kubectl describe pod pod1 | grep -i -A 8 "image"
3) -B flag → The -B flag will print lines before the matching lines.
Syntax
kubectl describe <object_type> <obejct_name> | grep -i -B <no_of_lines_you_want_to_print> "keyword_you_are_searching"
Example
kubectl describe pod pod1 | grep -i -B 8 "image"
Top comments (2)
This is a helpful post for anyone learning Kubernetes! It gives easy tips about using kubectl describe to check and understand your resources better. Great for troubleshooting and learning.
Subject is not about kubectl describe flags, but grep flags instead