Description
Hi folks,
we define CRD with fields defined in k8s.io/api
, such as:
import (
v1 "k8s.io/api/core/v1"
)
type CloneSetSpec struct {
// ...
Template v1.PodTemplateSpec `json:"template"`
// ...
VolumeClaimTemplates []v1.PersistentVolumeClaim `json:"volumeClaimTemplates,omitempty"`
}
For this kind:
-
With controller-tools
v0.1.x
, the CRD yaml is generated like this.This is ok, all structs defined in
k8s.io/api
are all generated without properties. It is because controller-gen in this version will ignore fork8s.io/api
https://github.com/kubernetes-sigs/controller-tools/blob/release-0.1/pkg/internal/codegen/parse/crd.go#L457 -
But with controller-tools higher than
v0.2.x
, the CRD yaml is generated like this.It generates properties for structs defined in
k8s.io/api
, which not only makes the CRD yaml much bigger, but also causes incorrect validation.
Problems we have found:
- For
VolumeClaimTemplates []v1.PersistentVolumeClaim
, it requires user to definedataSource
inv1.PersistentVolumeClaim
, which should be optional. (Issue) - For
Template v1.PodTemplateSpec
, it will returnThe CloneSet "demo" is invalid: type: Required value
when we definedownwardAPI
intemplate.spec.volumes
.
So, could we skip to generate properties for structs defined in k8s.io/api
, just like the v0.1.x
did?