I can run kubectl get pod nginx -o=jsonpath={'.status'}
to get just the status in json for my pod.
How can I do the same filtering but have the result returned in yaml instead of json?
So I would like to get this kind of output by the command:
status:
conditions:
- lastProbeTime: null
lastTransitionTime: "2019-05-31T14:58:57Z"
status: "True"
type: Initialized
- lastProbeTime: null
lastTransitionTime: "2019-05-31T14:59:02Z"
status: "True"
type: Ready
- lastProbeTime: null
lastTransitionTime: "2019-05-31T14:58:57Z"
status: "True"
type: PodScheduled
containerStatuses:
- containerID: docker://5eb07d9c8c4de3b1ba454616ef7b258d9ce5548a46d4d5521a0ec5bc2d36b716
image: nginx:1.15.12
imageID: docker-pullable://nginx@sha256:1d0dfe527f801c596818da756e01fa0e7af4649b15edc3eb245e8da92c8381f8
lastState: {}
name: nginx
ready: true
restartCount: 0
state:
running:
startedAt: "2019-05-31T14:59:01Z"
You cannot do that with kubectl, there is no such output option for it.
However, it should be easy to extract that lines with awk
.
kubectl get pods -o yaml | awk '/^status:/{flag=1}flag'
This starts the output at the line status:
. In this case that is exactly what yo want.