I want to get kubectl get pod outputs with go-template. I don't know the way as kubectl get pod -o yaml(json) does not contain READY values (e.g. 1/1)
kubectl get pod
NAME READY STATUS RESTARTS AGE
client-qfr4s 1/1 Running 0 14d
My purpose is to get additional values (e.g. container-port) in addition to default columns (NAME, READN, STATUS etc.) with one time kubectl command.
You can add custom column in kubectl get command like following
$ kubectl get pods -o custom-columns=NAME:.metadata.name,STATUS:.status.phase,RESTARTS:.status.containerStatuses[].restartCount,CONATAINER_NAME:.spec.containers[*].name,PORT:.spec.containers[*].ports,READY:.status.containerStatuses[*].ready
NAME STATUS RESTARTS CONATAINER_NAME PORT READY
nginx-6bc98f4797-7kv6m Pending 0 busy,nginx [map[containerPort:8000 protocol:TCP]] false,true
nginx-6bc98f4797-zv4sp Pending 0 busy,nginx [map[containerPort:8000 protocol:TCP]] false,true
php-apache-5986bb6b9-gllq8 Running 5 php-apache [map[containerPort:80 protocol:TCP]] true
You can find more details here
Instead of using get, you can use describe
kubectl describe pod
You will get complete status like below :
Conditions:
Type Status
Initialized True
Ready True
ContainersReady True
PodScheduled True