kubectl output for READY

4/18/2019

By default, kubectl get pods outputs

NAME                                                              READY   STATUS         RESTARTS   AGE
my-podob-6f7f9d798c-grhmd                                       1/1     Running        0          6d17h

Now I'd like to add a few extra columns to this, so I've set up a template.txt file with:

NAME          IMAGES
metadata.name metadata.annotations.imageTag

I can't seem to figure out how READY is calculated from the output. Ideally, I would append to the get pods output with a few custom columns but I can't tell if that's possible.

-- Anthony
kubectl
kubernetes

2 Answers

4/18/2019

The simplest solution would be:

NAME          IMAGES                         READY  
metadata.name metadata.annotations.imageTag .status.containerStatuses[*].ready
-- Shainberg
Source: StackOverflow

5/9/2019

There is a FR for appending extra columns here.

The "READY" column is a special case in the source: printers.go#L558 and its value is calculated in the implementation.

Unfortunately it seems that it's impossible to "count things" both in JSONPath and Go templates.

Maybe consider creating an alias to run the ordinary kubectl get pods and then the one with your custom columns?

-- BartoszKP
Source: StackOverflow