Can we display only a specific part of output from kubectl describe command in azure pipeline logs?

69 Views Asked by At

I'm creating an ansible task and using shell to execute kubectl describe node nodename command, and I want to display only a specific part of that output in azure pipeline logs. How I can achieve this?

By executing the kubectl describe node nodename getting the entire output but want to display only a specific part.

1

There are 1 best solutions below

0
wade zhou - MSFT On

kubectl describe doesn't support -o or equivalent parameters which can be used in kubectl get..., it provides a human-readable output and does not support structured output formats like JSON or YAML, please check the link for the details.

To extract part from the command output, you can use grep and awk commands in shell. Eg: kubectl describe node nodename | grep Capacity -A 6, it outputs 6 lines in the Capacity.