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.
kubectl describedoesn't support-oor equivalent parameters which can be used inkubectl 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
grepandawkcommands in shell. Eg:kubectl describe node nodename | grep Capacity -A 6, it outputs 6 lines in the Capacity.