Complex jsonpath expression not supported by : CustomResourceDefinition.additionalPrinterColumns

34 views
Skip to first unread message

cmou...@redhat.com

unread,
Oct 25, 2018, 9:08:53 AM10/25/18
to Kubernetes developer/contributor discussion
Hi,

Since k8s 3.11, we can customize and define the columns [1] to be used to display the result of the output of the command "kubectl get crd"

Example

kind: CustomResourceDefinition
metadata:
spec:
  version: v1alpha1
  names:
    kind: Component
    listKind: ComponentList
    plural: components
    singular: component
    shortNames:
      - cp
    # categories is a list of grouped resources the custom resource belongs to.
    categories:
      - all
  scope: Namespaced
  additionalPrinterColumns:
  - name: Runtime
    type: string
    description: "The runtime's technology/framework such as : Spring Boot, Eclipse Vert.x, ...."
    JSONPath: .spec.runtime
  - name: Version
    type: string
    description: "The version of the runtime"
    JSONPath: .spec.version
  - name: Service
    type: string
    description: "The service created from the catalog"
    JSONPath: .spec.services[0].name
  - name: Link Type
    type: string
    description: "The relation which exists between a component and a service, ..."
    JSONPath: .spec.link.kind


Result

kubectl apply -f component-link.yml && kubectl get cp
NAME                  RUNTIME   VERSION   SERVICE   LINK TYPE   AGE
my-spring-boot-link                                 Secret      0s


Unfortunately, we can't define complex expressions as defined within the k8s's doc [2] 

  - name: Link To
    type: string
    JSONPath: "{.spec.link.kind}{.spec.link.targetcomponentname}"

The CustomResourceDefinition "components.component.k8s.io" is invalid: spec.columns[4].path: Invalid value: "'{.spec.link.kind}{.spec.link.targetcomponentname}'": must be a simple json path starting with .


Is it a limitation ? Will such complex expressions been supported in a next release ?


Best regards

Charles

Clayton Coleman

unread,
Oct 25, 2018, 10:11:04 AM10/25/18
to cmou...@redhat.com, Kubernetes developer/contributor discussion
It’s a deliberate limitation right now - we are concerned with what complex expressions might cost on the server

Can you give some examples of the expressions you wanted to use?  It’s not unreasonable that we broaden the allowed set.
--
You received this message because you are subscribed to the Google Groups "Kubernetes developer/contributor discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-de...@googlegroups.com.
To post to this group, send email to kuberne...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kubernetes-dev/bdb07d3d-5dcc-4572-93ba-61fd026a012a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

cmou...@redhat.com

unread,
Oct 25, 2018, 12:30:19 PM10/25/18
to Kubernetes developer/contributor discussion
Here are an example 

type Link struct {
 
Name             string
 
TargetComponentName string
 
Kind               string
 
Ref                 string
}

Yaml example

targetcomponentname: runtime-a
kind
: Secret
ref: my-postgresql-db


could be displayed with one field as such

ColumnName: "Link To"
FieldAndText: ' .spec.link.kind/.spec.link.ref ' usedBy ' .spec.link.targetcomponentname '

NAME                 RUNTIME       VERSION    SERVICE PLAN             LINK TO
runtime
-a            spring-boot   1.5.16                    
service
-a                                     dh-postgresql-apb/dev
link
-a                                                                 'secret/my-postgresql-db' usedBy 'runtime-a'

  
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages