File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -371,11 +371,16 @@ func modifyConversionWebhooks(crds []*apiextensionsv1.CustomResourceDefinition,
371371 if crds [i ].Spec .PreserveUnknownFields {
372372 continue
373373 }
374- // Continue if the GroupKind isn't registered as being convertible.
374+ // Continue if the GroupKind isn't registered as being convertible,
375+ // and remove any existing conversion webhooks if they exist.
376+ // This is to prevent the CRD from being rejected by the apiserver, usually
377+ // manifests that are generated by controller-gen will have a conversion
378+ // webhook set, but we don't want to enable it if the type isn't registered.
375379 if _ , ok := convertibles [schema.GroupKind {
376380 Group : crds [i ].Spec .Group ,
377381 Kind : crds [i ].Spec .Names .Kind ,
378382 }]; ! ok {
383+ crds [i ].Spec .Conversion = nil
379384 continue
380385 }
381386 if crds [i ].Spec .Conversion == nil {
You can’t perform that action at this time.
0 commit comments