Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make kubectl explain print the Kind and APIVersion of the resource #55689

Merged

Conversation

luksa
Copy link
Contributor

@luksa luksa commented Nov 14, 2017

What this PR does / why we need it:
Kubectl explain currently doesn't print out the Kind and APIversion of the resource being explained. When running kubectl explain hpa.spec, for example, there is no way of knowing whether you're looking at the autoscaling/v1 or the autoscaling/v2beta1 version.
Also, kubectl explain is often used as a reference when writing YAML/JSON object manifests. It allows you to look up everything except the API version. Currently, you either need to know the API Version of a resource by heart or look it up in the online API docs.
This PR fixes both problems by having kubectl explain print out the full Kind and APIVersion of the resource it is explaining.

Here are a few examples of the new output:

$ kubectl explain deploy
KIND:     Deployment
VERSION:  extensions/v1beta1

DESCRIPTION:
...


$ kubectl explain hpa.spec
KIND:     HorizontalPodAutoscaler
VERSION:  autoscaling/v1

RESOURCE: spec <Object>

DESCRIPTION:
...


$ kubectl explain hpa.spec.maxReplicas
KIND:     HorizontalPodAutoscaler
VERSION:  autoscaling/v1

FIELD:    maxReplicas <integer>

DESCRIPTION:
...


$ kubectl explain hpa.spec --recursive
KIND:     HorizontalPodAutoscaler
VERSION:  autoscaling/v1

RESOURCE: spec <Object>

DESCRIPTION:
     behaviour of autoscaler. More info:
     https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status.

     specification of a horizontal pod autoscaler.

FIELDS:
   maxReplicas	<integer>
   minReplicas	<integer>
   scaleTargetRef	<Object>
      apiVersion	<string>
      kind	<string>
      name	<string>
   targetCPUUtilizationPercentage	<integer>

Release note:

Kubectl explain now prints out the Kind and API version of the resource being explained

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 14, 2017
@dims
Copy link
Member

dims commented Nov 14, 2017

/ok-to-test

@kubernetes/sig-cli-maintainers

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Nov 14, 2017
@mengqiy
Copy link
Member

mengqiy commented Nov 18, 2017

Printer change
/assign @fabianofranz @juanvallejo

/unassign

@juanvallejo
Copy link
Contributor

@fabianofranz this lgtm

@fabianofranz
Copy link
Contributor

/lgtm
/approve no-issue
/sig cli

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/cli Categorizes an issue or PR as relevant to SIG CLI. labels Nov 27, 2017
@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 27, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fabianofranz, luksa

Associated issue requirement bypassed by: fabianofranz

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to @fejta).

Review the full test history for this PR.

@k8s-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-github-robot k8s-github-robot merged commit 761fdea into kubernetes:master Dec 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/cli Categorizes an issue or PR as relevant to SIG CLI. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants