Issue
I have to count the number of replicasets running in a system.
kubectl get replicasets | wc -l
It give output 2
as it counts the header as well.
NAME DESIRED CURRENT READY AGE
new-replica-set 4 4 0 20s
How to print the count excluding the headers?
Solution
add no-headers
kubectl get replicasets --no-headers | wc -l
if you want to count rs
from all namespaces just add -A
before --no-headers
kubectl get replicasets -A --no-headers | wc -l
Answered By - Tasnuva Leeya Answer Checked By - Candace Johnson (WPSolving Volunteer)