How do I solve this Lightning Lab question 2? `Print the names of all deploymen . . .

Saurav Kunwar:
How do I solve this Lightning Lab question 2?

Print the names of all deployments in the admin2406 namespace in the following format:
DEPLOYMENT CONTAINER_IMAGE READY_REPLICAS NAMESPACE
<deployment name> <container image used> <ready replica count> <Namespace>
. The data should be sorted by the increasing order of the deployment name.

Example:
DEPLOYMENT CONTAINER_IMAGE READY_REPLICAS NAMESPACE
deploy0 nginx:alpine 1 admin2406
Write the result to the file /opt/admin2406_data.

L B:
u need to learn kubectl -o …

1 way would be:

$ kubectl get deploy -n admin2406 -o custom-columns=DEPLOYMENT:metadata.name,CONTAINER_IMAGE:..image,READY_REPLICAS:status.availableReplicas

i leave 4 u to figure out how to add the NAMESPACE

L B:
another way could be

$ k get deploy -n admin2406 -o json | jq -r '.items[]|[.metadata.name,.spec.template.spec.containers[].image,(.status.availableReplicas//0)]|@tsv'

once again leave u to add namespace

L B:
another way could be

$ k get deploy -n admin2406 -o go-template='{{range .items}}{{.metadata.name}}{{"\t"}}{{range .spec.template.spec.containers -}}{{.image}}{{" "}}{{end}}{{"\t"}}{{or .status.availableReplicas "0"}}{{"\n"}}{{end}}'

L B:
i think first example is most clear – but each successive example has more powerful features