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

Fix "kubectl explain" output for Agones CRDs #1194

Closed
aLekSer opened this issue Nov 26, 2019 · 6 comments · Fixed by #2423
Closed

Fix "kubectl explain" output for Agones CRDs #1194

aLekSer opened this issue Nov 26, 2019 · 6 comments · Fixed by #2423
Assignees
Labels
area/operations Installation, updating, metrics etc good first issue These are great first issues. If you are looking for a place to start, start here! help wanted We would love help on these issues. Please come help us! kind/feature New features for Agones
Milestone

Comments

@aLekSer
Copy link
Collaborator

aLekSer commented Nov 26, 2019

Is your feature request related to a problem? Please describe.
Currently there is no option to see the description of fields using standard kubectl functionality:

kubectl explain gameservers.agones.dev
error: Couldn't find resource for "agones.dev/v1, Kind=GameServer"

Describe the solution you'd like
Output should be similar to this:

kubectl explain pods

KIND:     Pod
VERSION:  v1

DESCRIPTION:
     Pod is a collection of containers that can run on a host. This resource is
     created by clients and scheduled onto hosts.

It seems that we could update apiserver.go code to serve requests of this kind.
Describe alternatives you've considered

Additional context

@aLekSer aLekSer added the kind/feature New features for Agones label Nov 26, 2019
@aLekSer aLekSer changed the title Fix kubectl explain output for Agones CRDs Fix "kubectl explain" output for Agones CRDs Nov 26, 2019
@roberthbailey
Copy link
Member

I think this is an issue of openapi spec not existing for CRDs. Based on https://github.com/kubernetes/enhancements/blob/master/keps/sig-api-machinery/00xx-publish-crd-openapi.md it looks like once we update to 1.14 (or maybe later) this should "just work." It would be worth testing against a later k8s cluster to see what the behavior is.

@markmandel markmandel added the area/operations Installation, updating, metrics etc label Dec 5, 2019
@aLekSer
Copy link
Collaborator Author

aLekSer commented Sep 3, 2020

Partially fixed in Kubernetes 1.16:

kubectl explain fleet
KIND:     Fleet
VERSION:  agones.dev/v1

DESCRIPTION:
     <empty>

So what left is to understand where to put a description.

@aLekSer aLekSer self-assigned this Sep 3, 2020
@aLekSer
Copy link
Collaborator Author

aLekSer commented Sep 3, 2020

I was able to fix output of kubectl explain for gameserverallocationpolicies.multicluster.agones.dev.

CRD extension has been promoted to v1. We have some changes to consider, e.g
spec.validation is removed; use spec.versions[*].schema instead

spec.validation was switched to spec.versions.schema and apiextensions.k8s.io to v1 and added type: object root element in validation schema field.

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  creationTimestamp: null
  labels:
    controller-tools.k8s.io: "1.0"
    component: crd
    app: agones
    chart: agones-1.8.0
    release: agones-manual
    heritage: Helm
  name: gameserverallocationpolicies.multicluster.agones.dev
spec:
  group: multicluster.agones.dev
  versions:
  - name: v1
    served: true
    storage: true
    schema:
      openAPIV3Schema:
        type: object
        properties:
          apiVersion:
            description: 'APIVersion defines the versioned schema of this representation
              of an object. Servers should convert recognized schemas to the latest
              internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources'
            type: string
          kind:
            description: 'Kind is a string value representing the REST resource this
              object represents. Servers may infer this from the endpoint the client
              submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds'
            type: string
          metadata:
            type: object
          spec:
            properties:
              connectionInfo:
                properties:
                  secretName:
                    type: string
                  serverCa:
                    type: string
                    format: byte
                  allocationEndpoints:
                    items:
                      type: string
                    type: array
                    minItems: 1
                  clusterName:
                    type: string
                  namespace:
                    type: string
                required:
                - namespace
                type: object
              priority:
                format: int32
                minimum: 0
                type: integer
              weight:
                format: int64
                minimum: 0
                type: integer
            required:
            - priority
            - weight
            type: object
  - name: v1alpha1
    # Disable the v1alpha1 version, but include it for inplace upgrade.
    served: false
    storage: false
    schema:
      openAPIV3Schema:
        type: object
  names:
    kind: GameServerAllocationPolicy
    plural: gameserverallocationpolicies
  scope: Namespaced
status:
  acceptedNames:
    kind: ""
    plural: ""
  conditions: []
  storedVersions: []

@markmandel
Copy link
Member

We have schemas now for everything - I wonder what the output is now. Could be good to test.

@markmandel markmandel added help wanted We would love help on these issues. Please come help us! good first issue These are great first issues. If you are looking for a place to start, start here! labels Apr 22, 2021
@eminguyen
Copy link
Contributor

The output appears to be good! All of the descriptions are still <empty> though, with the exception of lists.

$ kubectl explain fleets.agones.dev
KIND:     Fleet
VERSION:  agones.dev/v1

DESCRIPTION:
     <empty>

FIELDS:
   apiVersion   <string>
     APIVersion defines the versioned schema of this representation of an
     object. Servers should convert recognized schemas to the latest internal
     value, and may reject unrecognized values. More info:
     https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources

   kind <string>
     Kind is a string value representing the REST resource this object
     represents. Servers may infer this from the endpoint the client submits
     requests to. Cannot be updated. In CamelCase. More info:
     https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds

   metadata     <Object>
     Standard object's metadata. More info:
     https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata

   spec <Object>

   status       <Object>
$ kubectl explain gameserver
KIND:     GameServer
VERSION:  agones.dev/v1

DESCRIPTION:
     <empty>

FIELDS:
   apiVersion   <string>
     APIVersion defines the versioned schema of this representation of an
     object. Servers should convert recognized schemas to the latest internal
     value, and may reject unrecognized values. More info:
     https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources

   kind <string>
     Kind is a string value representing the REST resource this object
     represents. Servers may infer this from the endpoint the client submits
     requests to. Cannot be updated. In CamelCase. More info:
     https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds

   metadata     <Object>
     Standard object's metadata. More info:
     https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata

   spec <Object> -required-

   status       <Object>

@roberthbailey
Copy link
Member

As per #1194 (comment) it seems like we are still missing the description, not just for the top level resource but also for the spec and status.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/operations Installation, updating, metrics etc good first issue These are great first issues. If you are looking for a place to start, start here! help wanted We would love help on these issues. Please come help us! kind/feature New features for Agones
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants