![](/img/trans.png)
[英]How to get list of terminated and running pods list using Kubectl command
[英]How to get the count of the jobs running using kubectl command?
如果您想獲得在命名空間中運行的作業數量,您也可以像這樣使用它
kubectl get jobs -n dcs | grep -v NAME | wc -l
您可以為此使用wc或jq
kubectl get jobs --output name | wc -l
與jq :
kubectl get jobs --output json | jq -j '.items | length'
go-template
方式,無需管道或安裝。 只是好的舊 kubectl:
kubectl get jobs --namespace xxx -o go-template='{{printf "%d\n" (len .items)}}'
len
是go-template
中的一個內置函數,用於將元素的數量返回給它的參數。 例如: items
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.