Hi Guys. Can i get some guidance on this one? I'm looking at the k8s kubectl Ch . . .

Victor Pacheco:
Hi Guys. Can i get some guidance on this one?

I’m looking at the k8s kubectl Cheat Sheet. And looking at formatting output but still stuck. BTW. I’m familiar with JSON path. I assume this is something similar.

I’m looking at this section:

# All images running in namespace: default, grouped by Pod
kubectl get pods --namespace default --output=custom-columns="NAME:.metadata.name,IMAGE:.spec.containers[*].image"

In this case it is not pods but deployments. If you give me the correct syntax i can figure out how the path is defined. I’m looking at the yaml file for “deployments” in this namespace and trying to define from there.

Lightning Lab 1 Q 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."

Prashanth Vusirikapalli:
@Victor Pacheco answer might look something like below

kubectl get deployments -n admin2406 --sort-by=.metadata.name -o=custom-columns=DEPLOYMENT:.metadata.name,CONTAINER_IMAGE:.spec.template.spec.containers[*].image,READY_REPLICAS:.status.readyReplicas,NAMESPACE:.metadata.namespace &gt; /opt/admin2406_data

For deployments you need to query spec.template.spec

Victor Pacheco:
Thanks Prashanth. I will study this.

Prashanth Vusirikapalli:
First run kubectl get deployments -n admin2406 -o json and copy the output json to your favorite editor and look for the fields you are interested in for learning.