嗨,我正在尝试运行kubectl-n***获取pod
这返回标准的一个,它包括名称、就绪和状态。。。
我需要的是名字和准备然而,我无法通过使用自定义列来实现这一点。需要关于如何将就绪列添加回自定义列的帮助
kubectl-n***获取pods-o=自定义列=";名称:.metadata.NAME";
提前感谢
kubectl get pods -o custom-columns='NAME:metadata.name,READY:status.conditions[?(@.type=="Ready")].status'
使用go-template
:的解决方案
kubectl get pods -o go-template='{{range $index, $element := .items}}{{range .status.containerStatuses}}{{if .ready }}{{$element.metadata.name}} {{"READYn"}}{{end}}{{end}}{{end}}'
示例:
k get pod
NAME READY STATUS RESTARTS AGE
httpd-757fb56c8d-2vnw4 1/1 Running 2 (6h24m ago) 3d3h
readiness-exec 0/1 Running 0 22s #<---this is not ready
nginx 1/1 Running 2 (6h24m ago) 4d1h
nginx-6799fc88d8-5cflk 1/1 Running 2 (6h24m ago) 3d3h
//未列出未就绪(readiness-exec
(吊舱:
kubectl get pods -o go-template='{{range $index, $element := .items}}{{range .status.containerStatuses}}{{if .ready }}{{$element.metadata.name}} {{"READYn"}}{{end}}{{end}}{{end}}'
httpd-757fb56c8d-2vnw4 READY
nginx READY
nginx-6799fc88d8-5cflk READY
//一旦readiness-exec
吊舱准备就绪:
kubectl get pods -o go-template='{{range $index, $element := .items}}{{range .status.containerStatuses}}{{if .ready }}{{$element.metadata.name}} {{"READYn"}}{{end}}{{end}}{{end}}' |column -t
httpd-757fb56c8d-2vnw4 READY
readiness-exec READY
nginx READY
nginx-6799fc88d8-5cflk READY