Re: [kubernetes/kubernetes] "kubectl explain" should be able to explain "apiservices" and "customresourcedefinition" (#49465)

22 views
Skip to first unread message

k8s-ci-robot

unread,
Jul 24, 2017, 11:07:41 AM7/24/17
to kubernetes/kubernetes, k8s-mirror-cli-bugs, Team mention

@xiangpengzhao: Reiterating the mentions to trigger a notification:
@kubernetes/sig-cli-bugs.

In response to this:

@kubernetes/sig-cli-bugs

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.


You are receiving this because you are on a team that was mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

Chao Xu

unread,
Jul 27, 2017, 5:16:05 PM7/27/17
to kubernetes/kubernetes, k8s-mirror-cli-bugs, Team mention

cc @mbohlool

Mehdy Bohlool

unread,
Jul 27, 2017, 5:17:27 PM7/27/17
to kubernetes/kubernetes, k8s-mirror-cli-bugs, Team mention

This look like a problem with old swagger 1.2. We do not aggregate swagger 1.2 spec. When kubectl move to OpenAPI, it should by fix this by design.

Kubernetes Submit Queue

unread,
Oct 3, 2017, 10:28:06 PM10/3/17
to kubernetes/kubernetes, k8s-mirror-cli-bugs, Team mention

Closed #49465 via #53228.

k8s-ci-robot

unread,
Jan 16, 2018, 2:41:55 PM1/16/18
to kubernetes/kubernetes, k8s-mirror-cli-bugs, Team mention

@nikhita: you can't re-open an issue/PR unless you authored it or you are assigned to it.

In response to this:

This is still not fixed (even after kubectl moving to OpenAPI).

There are two problems here:

  1. kubectl uses groups registered into a group registry. This can be fixed by:
--- a/pkg/kubectl/cmd/explain.go
+++ b/pkg/kubectl/cmd/explain.go
@@ -26,7 +26,6 @@ import (
	"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
	cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
	"k8s.io/kubernetes/pkg/kubectl/explain"
-	"k8s.io/kubernetes/pkg/kubectl/scheme"
	"k8s.io/kubernetes/pkg/kubectl/util/i18n"
)

@@ -91,7 +90,6 @@ func RunExplain(f cmdutil.Factory, out, cmdErr io.Writer, cmd *cobra.Command, ar
		return err
	}

-	// TODO: We should deduce the group for a resource by discovering the supported resources at server.
	fullySpecifiedGVR, groupResource := schema.ParseResourceArg(inModel)
	gvk := schema.GroupVersionKind{}
	if fullySpecifiedGVR != nil {
@@ -104,20 +102,12 @@ func RunExplain(f cmdutil.Factory, out, cmdErr io.Writer, cmd *cobra.Command, ar
		}
	}

-	if len(apiVersionString) == 0 {
-		groupMeta, err := scheme.Registry.Group(gvk.Group)
-		if err != nil {
-			return err
-		}
-		apiVersion = groupMeta.GroupVersion
-
-	} else {
-		apiVersion, err = schema.ParseGroupVersion(apiVersionString)
-		if err != nil {
+	if len(apiVersionString) != 0 {
+		if apiVersion, err = schema.ParseGroupVersion(apiVersionString); err != nil {
			return err
		}
+		gvk = apiVersion.WithKind(gvk.Kind)
	}
-	gvk = apiVersion.WithKind(gvk.Kind)

	resources, err := f.OpenAPISchema()
	if err != nil {

However, after this it gives:

error: Couldn't find resource for "apiextensions.k8s.io/v1beta1, Kind=CustomResourceDefinition"
  1. This occurs because of incorrect openAPI schema. The schema does not contain apiextensions and apiregisteration.

kubectl explain looks up the gvk of the resource in question from a list of resources:

https://github.com/kubernetes/kubernetes/blob/ff626a35fe35f6d219a3f95b39df7afd4cab9b6b/pkg/kubectl/cmd/util/openapi/openapi.go#L71-L77

It gets the gvk here:

https://github.com/kubernetes/kubernetes/blob/ff626a35fe35f6d219a3f95b39df7afd4cab9b6b/pkg/kubectl/cmd/util/openapi/openapi.go#L59

parseGroupVersionKind finds the gvk through groupVersionKindExtensionKey:

https://github.com/kubernetes/kubernetes/blob/ff626a35fe35f6d219a3f95b39df7afd4cab9b6b/pkg/kubectl/cmd/util/openapi/openapi.go#L83-L87

Here, groupVersionKindExtensionKey is "x-kubernetes-group-version-kind" and is the key used to lookup the GroupVersionKind value for an object definition from the definition's "extensions" map.

However, we do not generate x-kubernetes- extensions for apiextensions-apiserver and aggregator yet (#52741), due to which it fails.

/reopen

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.

Nikhita Raghunath

unread,
Jan 16, 2018, 2:42:16 PM1/16/18
to kubernetes/kubernetes, k8s-mirror-cli-bugs, Team mention

Peter (XiangPeng) Zhao

unread,
Jan 16, 2018, 9:57:35 PM1/16/18
to kubernetes/kubernetes, k8s-mirror-cli-bugs, Team mention

k8s-ci-robot

unread,
Jan 16, 2018, 9:57:39 PM1/16/18
to kubernetes/kubernetes, k8s-mirror-cli-bugs, Team mention

Reopened #49465.

fejta-bot

unread,
Apr 17, 2018, 12:54:52 AM4/17/18
to kubernetes/kubernetes, k8s-mirror-cli-bugs, Team mention

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

Nikhita Raghunath

unread,
Apr 17, 2018, 2:24:24 AM4/17/18
to kubernetes/kubernetes, k8s-mirror-cli-bugs, Team mention

/remove-lifecycle stale

Nikhita Raghunath

unread,
Jun 1, 2018, 5:36:47 AM6/1/18
to kubernetes/kubernetes, k8s-mirror-cli-bugs, Team mention

Looks like the blocker was fixed in #64174 🎉

I will move forward with the fix.

Nikhita Raghunath

unread,
Jun 1, 2018, 5:37:19 AM6/1/18
to kubernetes/kubernetes, k8s-mirror-cli-bugs, Team mention

/assign

fejta-bot

unread,
Aug 30, 2018, 5:57:38 AM8/30/18
to kubernetes/kubernetes, k8s-mirror-cli-bugs, Team mention

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

Nikhita Raghunath

unread,
Sep 3, 2018, 1:57:34 PM9/3/18
to kubernetes/kubernetes, k8s-mirror-cli-bugs, Team mention

/remove-lifecycle stale

Jordan Liggitt

unread,
Nov 24, 2018, 11:42:47 AM11/24/18
to kubernetes/kubernetes, k8s-mirror-cli-bugs, Team mention

Closed #49465.

Jordan Liggitt

unread,
Nov 24, 2018, 11:42:55 AM11/24/18
to kubernetes/kubernetes, k8s-mirror-cli-bugs, Team mention

fixed in 1.11 in #64174

Reply all
Reply to author
Forward
0 new messages