kubernetes-sigs / kubebuilder

Kubebuilder - SDK for building Kubernetes APIs using CRDs
http://book.kubebuilder.io
Apache License 2.0
7.88k stars 1.45k forks source link

OpenAPI Schema Validation Errors for imagePullSecrets and hostAliases for CronjobTutorial sample with controller-runtime v0.18.3 and Kubernetes 1.30 #3917

Closed camilamacedo86 closed 5 months ago

camilamacedo86 commented 5 months ago

What broke? What's expected?

Problem Description

After upgrading the controller-runtime version from v0.17.3 to v0.18.3 (which means upgrade k8s api from 1.29 to 1.30), we encountered validation errors when running make test-book due to changes in Kubernetes 1.30. The issue stems from the addition of the// +listType=atomic marker to the imagePullSecrets and hostAliases fields in the k8s.io/api/batch/v1 API used in the cronjob tutorial. This marker results in OpenAPI schema validation errors when the CRD is generated with x-kubernetes-list-type: atomic.

Kubernetes Issue Reference: kubernetes/kubernetes#124540

See the error faced:

      unable to install CRDs onto control plane: unable to create CRD instances: unable to create CRD "cronjobs.batch.tutorial.kubebuilder.io": CustomResourceDefinition.apiextensions.k8s.io "cronjobs.batch.tutorial.kubebuilder.io" is invalid: [spec.validation.openAPIV3Schema.properties[spec].properties[jobTemplate].properties[spec].properties[template].properties[spec].properties[imagePullSecrets].items.properties[name].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[hostAliases].items.properties[ip].default: Required value: this property is in x-kubernetes-list-map-keys, so it must have a default or be a required property]

Therefore, we commented the test called in the makefile target .PHONY: test-book. When we be able to update controller-runtime within an upper version that us using a k8s version with the fix we should uncomment the test and ensure that all is fine.

What is required to do here:

Reproducing this issue

No response

KubeBuilder (CLI) Version

rc-4.0.0

PROJECT version

master

Plugin versions

No response

Other versions

No response

Extra Labels

No response

camilamacedo86 commented 5 months ago

For more info see the diff of the PR: https://github.com/kubernetes-sigs/kubebuilder/pull/3912/files

ManuelMueller1st commented 4 months ago

I get the same error trying to run make install during the tutorial using KubeBuilderVersion:"4.0.0". Is there anything I must do to get the fix applied?

caffe-in commented 4 months ago

I get the same error trying to run make install during the tutorial using KubeBuilderVersion:"4.0.0". Is there anything I must do to get the fix applied?

I upate the controller-runtime to v0.18.3 using "go get sigs.k8s.io/controller-runtime@v0.18.3" in terminal and it works