kubectl icon indicating copy to clipboard operation
kubectl copied to clipboard

How can get the kubectl describe output to a table format

Open vivuu1989 opened this issue 1 year ago • 4 comments

I am using Kubernetes VPA as a resource recommender tool for my cluster and its generating the recommended specification for each deployment. But I would like to get a automated way to create the vpa recommendation to all the existing VPAs in a much readable format ( preffered way is table format) dynamically.

I tried to create an Azuredevops pipeline and when parsing the json path from the kubectl get command I am not getting the resulted output.

k get  vpa myvpa -n mynamespace -o jsonpath='{status.recommendation.containerRecommendations.containerName[*]}'

vivuu1989 avatar Sep 22 '23 17:09 vivuu1989

This issue is currently awaiting triage.

SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the triage/accepted label.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

k8s-ci-robot avatar Sep 22 '23 17:09 k8s-ci-robot

Hi @vivuu1989,

To create a table format output from the VPA recommendations, you can use tools like jq to parse the JSON output and format it as a table. Here's how you can achieve this:

Step 1 : Ensure you have jq installed on your system. If it's not installed, you can typically install it using your package manager (e.g., apt-get, brew, yum, etc.).

Step 2 : Run the kubectl get command to retrieve the VPA recommendations and pipe the output to jq for formatting. You can use the --output flag with jq to format the data as a table. Here's an example command:

kubectl get vpa -n mynamespace -o json | jq -r '.items[] | [.metadata.name, .status.recommendation.containerRecommendations[].containerName] | @tsv'

This command retrieves the VPA recommendations in JSON format, extracts the VPA name and container recommendations, and formats the output as a tab-separated table.

I hope you find this helpful : )

akash-kumar-saw avatar Sep 22 '23 21:09 akash-kumar-saw

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Jan 28 '24 23:01 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle rotten
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

k8s-triage-robot avatar Feb 27 '24 23:02 k8s-triage-robot