kubectl: additionalPrinterColumns for CRD's doesn't work in k8s 1.11 for columns with array data

Kubernetes version (use kubectl version): 1.11 (server-side printing)

Environment:

  • Cloud provider or hardware configuration: GKE

Bug Reproduce using the following steps:

  1. Create CRD:

crd.yaml

apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  name: foos.example.istio.io
spec:
  group: example.istio.io
  names:
    kind: Foo
    listKind: FooList
    plural: foos
    singular: foo
  scope: Namespaced
  version: v1alpha1
  additionalPrinterColumns:
  - JSONPath: .spec.servers[*].hosts
    name: hosts
    type: string

$ kubectl apply -f crd.yaml
  1. Create an instance of the CRD:

crd-instance.yaml

apiVersion: example.istio.io/v1alpha1
kind: Foo
metadata:
  name: foo0
spec:
  servers:
  - hosts:
    - foo.example.com
    - bar.example.com
  - hosts:
    - baz.example.com
$ kubectl apply -f crd-instance.yaml
  1. Print instance of CRD:
$ kubectl get foos foo0
NAME      HOSTS
foo0      [foo.example.com bar.example.com]

EXPECTED

Notice that only the first array of hosts is printed (missing second array [baz.example.com]). We would expect that both arrays would have been printed. If we specifically request the JSONPath, then it prints correctly.

$ kubectl get foos foo0 -o jsonpath='{.spec.servers[*].hosts}'
[foo.example.com bar.example.com] [baz.example.com]

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 6
  • Comments: 40 (19 by maintainers)

Commits related to this issue

Most upvoted comments

/remove-lifecycle stale

Ping