kubectl icon indicating copy to clipboard operation
kubectl copied to clipboard

Support `kubectl config get-contexts` JSON output

Open hclihn opened this issue 1 year ago • 7 comments
trafficstars

What would you like to be added: Please add support for config get-contexts JSON output.

Why is this needed: Currently, config get-contexts can only output column-oriented format or the name field (using -o=name). However, when the cluster/context name contains space(s) which is true for our company's implementation, it makes the parsing of the output very challenging. If the command output can support a JSON format, then it's relatively easier to use existing tools to parse it, regardless if the cluster/context name contains space(s) or not.

hclihn avatar Jun 25 '24 17:06 hclihn

Sounds to me a reasonable ask.

ardaguclu avatar Jun 26 '24 13:06 ardaguclu

I'll take a look at this.

ah8ad3 avatar Jul 04 '24 06:07 ah8ad3

@ah8ad3 before working on it, I think it would be better to wait bug scrub to triage it first.

ardaguclu avatar Jul 04 '24 06:07 ardaguclu

/triage accepted

mpuckett159 avatar Jul 17 '24 16:07 mpuckett159

/assign

TessaIO avatar Jul 17 '24 16:07 TessaIO

Is this still being worked on? I want to create a PR for this.

karan2704 avatar Jul 30 '24 17:07 karan2704

/retitle Support kubectl config get-contexts JSON output

sftim avatar Aug 08 '24 11:08 sftim

I will finish this.

/assign

tchap avatar May 23 '25 13:05 tchap

This was discussed during SIG-CLI on 5/28, and based on further investigation we agreed that the functionality proposed is already available through:

kubectl config view -o jsonpath='{.contexts}'

tchap avatar May 28 '25 16:05 tchap

We are not planning to add this functionality for now /close

ardaguclu avatar May 30 '25 14:05 ardaguclu

@ardaguclu: Closing this issue.

In response to this:

We are not planning to add this functionality for now /close

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-sigs/prow repository.

k8s-ci-robot avatar May 30 '25 14:05 k8s-ci-robot