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

CronJob make install failed. #1466

Closed
chenyg0911 opened this issue Apr 8, 2020 · 9 comments
Closed

CronJob make install failed. #1466

chenyg0911 opened this issue Apr 8, 2020 · 9 comments
Labels
kind/support Categorizes issue or PR as a support question.

Comments

@chenyg0911
Copy link

follow the qiuck start book to build CronJob, when run make install , It failed with:

controller-gen "crd:trivialVersions=true" rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
kustomize build config/crd | kubectl apply -f -
The CustomResourceDefinition "cronjobs.batch.tutorial.kubebuilder.io" is invalid: 
* spec.validation.openAPIV3Schema.properties[spec].properties[jobTemplate].properties[spec].properties[template].properties[spec].properties[initContainers].items.properties[ports].items.properties[protocol].default: Required value: this property is in x-kubernetes-list-map-keys, so it must have a default or be a required property
* spec.validation.openAPIV3Schema.properties[spec].properties[jobTemplate].properties[spec].properties[template].properties[spec].properties[containers].items.properties[ports].items.properties[protocol].default: Required value: this property is in x-kubernetes-list-map-keys, so it must have a default or be a required property
Makefile:30: recipe for target 'install' failed
make: *** [install] Error 1
kubebuilder version
Version: version.Version{KubeBuilderVersion:"2.3.0", KubernetesVendor:"1.16.4", GitCommit:"800f63a7e41a6a8016d4cb9d583e1705b0812c9d", BuildDate:"2020-02-28T19:15:41Z", GoOs:"unknown", GoArch:"unknown"}
@chenyg0911 chenyg0911 added the kind/support Categorizes issue or PR as a support question. label Apr 8, 2020
@chenyg0911
Copy link
Author

switch test it on k8s v1.16.7. it worked. the error is under k8s v1.18.

@aryann
Copy link

aryann commented May 12, 2020

I am also running into this problem.

@chenyg0911 could you share with me the command you used to downgrade your Kubernetes APIs?

I've included my go.mod and the errors I'm getting running make install.

module tutorial

go 1.13

require (
        github.com/go-logr/logr v0.1.0
        github.com/onsi/ginkgo v1.11.0
        github.com/onsi/gomega v1.8.1
        github.com/robfig/cron v1.2.0
        k8s.io/api v0.17.2
        k8s.io/apimachinery v0.17.2
        k8s.io/client-go v0.17.2
        sigs.k8s.io/controller-runtime v0.5.0
)

The CustomResourceDefinition "cronjobs.batch.kubebuildertutorial.kubebuilder.io" is invalid: 
* spec.validation.openAPIV3Schema.properties[spec].properties[jobTemplate].properties[spec].properties[template].properties[spec].properties[initContainers].items.properties[ports].items.properties[protocol].default: Required value: this property is in x-kubernetes-list-map-keys, so it must have a default or be a required property
* spec.validation.openAPIV3Schema.properties[spec].properties[jobTemplate].properties[spec].properties[template].properties[spec].properties[containers].items.properties[ports].items.properties[protocol].default: Required value: this property is in x-kubernetes-list-map-keys, so it must have a default or be a required property
make: *** [Makefile:30: install] Error 1

@aryann
Copy link

aryann commented May 12, 2020

Oops... I didn't read the error message well enough and didn't realize that the problem is with the server version of Kubernetes, not the linked Go libraries.

I restarted my minikube using:

minikube start --kubernetes-version=v1.16.7

as a workaround.

@Colstuwjx
Copy link

I don't think it's a good idea to do this workaround. We're using the latest kubebuilder version, and it even need lower version kubernetes release!

Should we update the tutorial code and fix this issue?

@mingliangguo
Copy link

I ran into the exact same issue with the latest tutorial. And I also saw some discussions about the same issue in kubernetes-sigs/controller-tools#444

Does it mean this will not be fixed in kubebuilder until the issue is fixed in controller-tools?

@zzxwill
Copy link

zzxwill commented Sep 17, 2020

Hit the same issue.

@yaa110
Copy link

yaa110 commented Oct 7, 2020

Same issue with k8s 1.19.

I think the issue should be reopened.

@ddlees
Copy link

ddlees commented Oct 19, 2020

@mingliangguo @zzxwill @yaa110 You can create a kustomize patch to get around this pretty trivially. That said, the controller-tools project merged a fix for this with #480; however, it is not in a release at this point in time.

Workaround:

config/crd/patches/k8s_list_map_keys.yaml

- op: replace
  path: /spec/validation/openAPIV3Schema/properties/spec/properties/jobTemplate/properties/spec/properties/template/properties/spec/properties/initContainers/items/properties/ports/items/required
  value:
  - containerPort
  - protocol

- op: replace
  path: /spec/validation/openAPIV3Schema/properties/spec/properties/jobTemplate/properties/spec/properties/template/properties/spec/properties/containers/items/properties/ports/items/required
  value:
  - containerPort
  - protocol

config/crd/kustomization.yaml

...
patchesJson6902:
- target:
    group: apiextensions.k8s.io
    version: v1beta1
    kind: CustomResourceDefinition
    name: cronjobs.batch.tutorial.kubebuilder.io
  path: patches/k8s_list_map_keys.yaml
...

nateinaction added a commit to nateinaction/kubebuilder-testing that referenced this issue Nov 6, 2020
hhiroshell added a commit to hhiroshell/cronjob-controller that referenced this issue Nov 10, 2020
@camilamacedo86
Copy link
Member

The workaround #1466 (comment) shows valid for projects built with v2 go plugin. If you use the go/v3-alpha plugin it should be solved as well. ( kubebuilder init --plugins=go/v3-alpha )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/support Categorizes issue or PR as a support question.
Projects
None yet
Development

No branches or pull requests

8 participants