Showing content from https://github.com/kubernetes-sigs/kubebuilder/releases below:
Website Navigation
Releases · kubernetes-sigs/kubebuilder · GitHub
v4.6.0
Changes since v4.5.2
⚠️ Breaking Changes
✨ New Features
- (go-v4): Enable
import-shadowing
linter (#4700)
- (go-v4): Add new Makefile target to create a cluster name for e2e tests (#4673)
- (go-v4): Upgrade Go version to
v1.24.0
(#4585)
- (go-v4): Update
golangci-lint
to v2.0.2
and GitHub Action to v8
(#4752,#4801)
- (go-v4): Upgrade controller-tools from
v0.17.2
to v0.18.0
(#4804,#4770)
- (API, CLI, go/v4): Add
cliVersion
field to PROJECT
file to track CLI binary version used in scaffolds (#4621, #4821)
🐛 Bug Fixes
- (go-v4): Wrap test command execution errors with
%w
for better error tracing (#4694)
- (go-v4): Improve
main.go
scaffolding to reduce err
scope using :=
(#4585)
- (helm/v1-alpha): Add control-plane labels to metrics service and ServiceMonitor templates (#4777)
- (helm/v1-alpha): Append project name to webhook service name to avoid name collisions (#4808)
- (go-v4): Fix staticcheck linter issues (ST1005, QF1008) in scaffolds and tutorials (#4779)
- (go-v4): Fix incorrect Webhook import aliasing in
cmd/main.go
(#4781)
- (go-v4): Revert unintended addition of explicit
docker.io
prefix in Dockerfile (#4818)
- (go-v4): Improve comment in
/config/rbac/kustomization.yaml
by rendering project name instead of using template var (#4819)
- (go-v4): Remove redundant/noisy
godebug
default lines in the go.mod
file (#4787)
Thanks to all our contributors! 🎉
What's Changed
- 📖 bump sigs.k8s.io/kubebuilder/v4 from 4.5.1 to 4.5.2 in /docs/book/src/simple-external-plugin-tutorial/testdata/sampleexternalplugin/v1 by @dependabot in #4683
- 🌱 (chore): add gofumpt to golangci-lint configuration by @kersten in #4672
- 🌱 (chore): unify import alias for network-policy by @kersten in #4684
- 🌱 (chore): normalize error messages and wrap errors using %w by @kersten in #4685
- 📖 Fix path for samples in the Getting Started tutorial by @fferrann in #4695
- 🌱 (chore): normalize error messages and wrap errors using %w by @kersten in #4686
- 🌱 (chore): wrap file and I/O errors with '%w' in 'pkg' by @kersten in #4689
- 🌱 (chore): remove unnecessary blank lines across plugin configuration and options by @kersten in #4690
- 📖 Improve error format in the design docs for API Versioning in Kubebuilder by @kersten in #4693
- 🌱 (chore): avoid shadowing of 'config' and 'resource' in golang/v4 plugins by @kersten in #4649
- 🌱 (chore): normalize error messages and wrap errors using %w by @kersten in #4687
- 🌱 (chore): wrap errors with '%w' and normalize formatting in 'kustomize/v2' by @kersten in #4688
- 🌱 (chore): wrap error with %w in test_context.go for improved diagnostics by @kersten in #4692
- 🐛 (go/v4): wrap test command execution errors with %w in test utils by @kersten in #4694
- 🌱 (chore): avoid shadowing of 'config', 'store', and 'resource' in cli/alpha/generate by @kersten in #4697
- 🌱 (chore) add comment to clarify usage context of ReplaceRegexInFile by @kersten in #4656
- 🌱 (chore): fix improper usage of errors.As in scaffold tests by @kersten in #4696
- 🌱 (chore): improve readability of test case for alternative delimiters by @kersten in #4698
- 🌱 (chore): enable shadow checks via import-shadowing linter by @kersten in #4661
- 🌱 (chore): refactor unit tests to isolate mutable test data in CLI spec to improve maintainability by @kersten in #4701
- 🌱 (chore): enable 'asciicheck' and 'bidichk' for improved code safety and clarity by @kersten in #4699
- ✨ (go/v4): enable 'import-shadowing' linter by @kersten in #4700
- 🌱 (chore): refactor unit tests to isolate mutable state with BeforeEach for pkg/cli by @kersten in #4702
- 🌱 (chore): refactor unit tests to isolate mutable state with BeforeEach for pkg/config/store by @kersten in #4703
- 🌱 (chore): refactor unit tests to isolate mutable state with BeforeEach in pkg/config by @kersten in #4704
- 🌱 (chore): refactor unit tests to isolate mutable state with BeforeEach in pkg/machinery tests by @kersten in #4705
- 🌱 (chore): refactor stage unit tests with Ginkgo conventions and simplify logic in stage_test.go by @kersten in #4706
- 🌱 (chore): refactor unit tests to isolate mutable state with BeforeEach in resource-related tests by @kersten in #4707
- 🌱 (chore): refactor shared setup logic in plugins into BeforeEach to isolate test state by @kersten in #4708
- 🌱 (chore): enable 'whitespace' linter in golangci-lint config by @kersten in #4691
- 🌱 (chore): refactor shared setup logic in plugin into BeforeEach to isolate test state by @kersten in #4709
- 🌱 fix (ci): fix lint issue: shadow: declaration of pluginCfg shadows declaration by @camilamacedo86 in #4725
- 📖 Updated 404 page details in TODO.md and updated the book by @Kuzuri247 in #4674
- 🐛 (go/v4) Update main.go scaffold to follow Go best practices by reducing the scope of err using short variable declarations (:=) by @koba1t in #4627
- 📖 Updated migration pages by @Kuzuri247 in #4676
- 🌱 Use dynamic controller-runtime version in doc generator to make easier update the version by @p-shah256 in #4713
- 🌱 (chore): enable ginkgolinter forbid-spec-pollution to enforce isolated test specs by @kersten in #4710
- 🌱 (chore): enable ginkgolinter forbid-focus-container by @nunnatsa in #4714
- 📖 Fixed grammatical errors in designs doc by @Kuzuri247 in #4716
- 🌱 (chore): replace errors.As() with MatchError() in error assertions by @kersten in #4723
- 🌱 Fix golangci-lint wrong configurations by @nunnatsa in #4726
- 🌱 (chore): simplify test variable declarations for CLI tests by @kersten in #4731
- 🌱 (chore): replace '%v' with '%w' in deploy-image v1alpha1 plugin errors by @kersten in #4732
- 🌱 (chore): wrap errors using '%w' and improve formatting in golang plugin by @kersten in #4729
- 🌱 (chore): improve error wrapping for external plugin discovery and config loading by @kersten in #4744
- 🌱 (chore): wrap plugin and util error returns for better context by @kersten in #4745
- 🌱 (chore): check and return error from os.WriteFile when writing litout.json by @kersten in https://gith...
Read more v4.5.2
changes since v4.5.1
✨ New Features
Note: This release includes minor version upgrades for key dependencies.
- (go-v4): Upgraded
controller-runtime
from v0.20.2
to v0.20.4
(#4604, #4678)
- (go-v4): Upgraded
kustomize
from v5.5.0
to v5.6.0
(#4620)
🐛 Bug Fixes
- (CLI): Fixed Kubebuilder installation using
go install
to ensure proper setup (#4581)
- (CLI): Allowed
kubebuilder alpha generate
to proceed even when legacy plugins (go/v2, go/v3) are unavailable (#4572)
- (helm/v1-alpha): Skipped empty directories during Helm chart generation to avoid invalid output (#4586)
- (helm/v1-alpha): Avoided scaffolding webhook manifests for projects that do not use webhooks (#4584)
- (go-v4): Made Kind integration in the Makefile configurable, aligning with the standard used for other variables (#4615)
- (go-v4): Fixed indentation of import statements in generated test files (#4623)
- (go-v4): Fixed minor typo in e2e test suite comments (#4662)
- (go-v4): Prevented shadowing of the standard
log
package by aliasing it as logf
(#4646)
- (grafana/v1alpha): Prevented shadowing of the
err
variable in generated Grafana plugin code (#4653)
Thanks to all our contributors! 🎉
What's Changed
- 📖 : Bump sigs.k8s.io/kubebuilder/v4 from 4.5.0 to 4.5.1 in /docs/book/src/simple-external-plugin-tutorial/testdata/sampleexternalplugin/v1 by @dependabot in #4579
- 🐛 Fix Kubebuilder Installation with go install by @migueleliasweb in #4581
- 🌱 (ci): improve PR title validation for a better security by @camilamacedo86 in #4583
- 🐛 (helm/v1-alpha): Skip empty directories in chart generation by @camilamacedo86 in #4586
- 🌱 Upgrade Goreleaser + fix deprecation on release.yml by @migueleliasweb in #4587
- 🌱 Add Makefile target to sync Kubernetes version by @akagami-harsh in #4589
- 🌱 fix PR title check by @camilamacedo86 in #4596
- 🌱 Bump golang.org/x/text from 0.22.0 to 0.23.0 by @dependabot in #4594
- 🌱 Bump golang.org/x/tools from 0.30.0 to 0.31.0 by @dependabot in #4593
- 🌱Bump github.com/onsi/ginkgo/v2 from 2.22.2 to 2.23.0 by @dependabot in #4595
- 📖 Add link to Watching Secondary Resources Owned by the Controller by @guettli in #4590
- 📖 Update Single Group to Multi-Group Documentation to Add Webhooks Details 📖 by @GunaKKIBM in #4601
- 📖 fix incorrect reference to "deploy-image-plugin" in docs. by @mo3et in #4599
- 📖 Update README.md with minor changes by @chethanm99 in #4603
- ✨ Upgrade controller-runtime from v0.20.2 to v0.20.3 by @vitorfloriano in #4604
- 📖 Update code-generate-image-plugin.md and gvks.md by @chethanm99 in #4607
- 📖 Update CONTRIBUTING-ROLES.md with minor changes by @chethanm99 in #4605
- 📖 docs: fix incorrect json tag in API example. by @mo3et in #4609
- 🌱 Bump github.com/spf13/afero from 1.12.0 to 1.14.0 by @dependabot in #4616
- 🐛 Make the Kind integration in the Makefile configurable like the other variables. by @kersten in #4615
- 🐛 Allow 'kubebuilder alpha generate' rescaffolds work with no longer supported/available plugins ( go/v3 and go/v2 ) by @sarthaksarthak9 in #4572
- 🌱 Fix: ensure tha cmd/verdion.go is properly updated to return this value for go modules by @camilamacedo86 in #4619
- 🌱 Bump github.com/onsi/ginkgo/v2 from 2.23.0 to 2.23.1 by @dependabot in #4622
- ✨ (go/v4): Upgrade kustomize version from v5.5.0 to v5.6.0 by @camilamacedo86 in #4620
- 🌱 Bump github.com/onsi/ginkgo/v2 from 2.23.1 to 2.23.2 by @dependabot in #4626
- 📖 Remove outdated test examples by @fiunchinho in #4624
- 🐛 (go/v4): fix indentation of imports in test files by @kersten in #4623
- 🌱 Bump github.com/onsi/ginkgo/v2 from 2.23.2 to 2.23.3 by @dependabot in #4628
- 🌱 Bump github.com/onsi/gomega from 1.36.2 to 1.36.3 by @dependabot in #4629
- 🌱 fix: avoid variable shadowing by renaming loop variable 'plugin' by @kersten in #4640
- 🌱 fix: resolve shadowed variable issue in literate.go by @kersten in #4641
- 🌱 (chore): avoid variable shadowing by renaming local 'alpha' variable by @kersten in #4642
- 🌱 (chore): rename local 'config' variable to avoid collision with imported package by @kersten in #4639
- 🌱 (chore): rename local 'resource' variable to avoid shadowing import by @kersten in #4645
- 🌱 fix(docs): correct typo in comments across multiple files by @kersten in #4634
- 🌱 (chore): avoid variable shadowing by renaming local 'errors' variable by @kersten in #4643
- 🐛 (go/v4): fix typo in e2e test suite comments by @kersten in #4662
- 🌱 (chore): improve readability of test case for alternative delimiters by @kersten in #4671
- 🌱 (chore): group const declarations into blocks for clarity by @kersten in #4669
- 🌱 (chore): avoid shadowing of 'config', 'err', and patch error in helm and deploy-image scaffolds by @kersten in #4660
- 🌱 (chore): use octal notation for file and directory modes by @kersten in #4663
- 🌱 (chore): remove unnecessary trailing newlines and redundant blank lines by @kersten in #4664
- 🌱 (chore): simplify test variable declarations for CLI tests by @kersten in #4665
- 🌱 (chore): simplify variable declarations by adding var blocks by @kersten in #4666
- 🌱 (chore): simplify variable declarations by removing unnecessary var blocks by @kersten in #4667
- 🌱 (chore): fix formatting for multi-line function signatures by @kersten in #4668
- 🌱 (chore): avoid shadowing of 'err' in CLI options, YAML store, and external plugin helpers by @kersten in #4658
- 🌱 (chore): avoid shadowing of 'err' and related variables in E2E and external plugin tests by @kersten in #4659
- 🌱 (chore): avoid shadowing of 'fmt' in regexError helper by @kersten in #4648
- 🌱 (chore): avoid shadowing of 'config', 'resource', and 'err' in kustomize/v2 scaffolds by @kersten in #4651
- 🌱 (chore): avoid shadowing of 'pluginConfig' in config v3 implementation and tests by @kersten in #4652
- 🌱 (chore): avoid shadowing of 'err' in version parsing for plugin and config packages by @kersten in #4657
- 🌱 (chore): avoid 'fs' shadowing and rename 'isPluginExectuable' to 'isPluginExecutable' by @kersten in #4647
- 🌱 (chore): clean up var declarations in grafana scaffolder and cronjob doc generator by @kersten in #4670
- ✨ Upgrade controller-runtime v0.20.3 to v0.20.4 by @camilamacedo86 in #4678
- 🐛 (helm/v1-alpha): not scaffold webhooks conditiona...
Read more v4.5.1
changes since v4.5.0
✨ New Features
Note: This release includes only minor version updates.
- (go-v4): Upgraded
controller-runtime
from v0.20.0
to v0.20.2
(#4528, #4570)
- (go-v4): Upgraded
controller-gen
from v0.17.1
to v0.17.2
(#4553)
🐛 Bug Fixes
- (go-v4): Aligned webhook suite tests with controller suite tests (#4449)
- (go-v4): Fixed project initialization in directories containing other files. Now, initialization is only prevented for directories with explicitly unwanted files (#4510)
- (go-v4, kustomize/v2, helm/v1-alpha): Fixed Prometheus integration by adding the
serverName
field to ServiceMonitor
, ensuring proper certificate validation with the metrics server (#4536, #4558)
- (CLI): Fixed
kubebuilder alpha generate
by using --repo
information tracked in the PROJECT
file. Fix generation of projects outside of GOPATH
(#4559)
- (go-v4, deploy-image/v1-alpha): Fixed handling of missing boilerplate files by raising a warning instead of failing. Previously, the process would terminate with an error, but it now issues a warning and continues execution (#4518).
- (go-v4): e2e tests: Removed Prometheus dependency as part of cleanup and fixes, since it is optional and not required (#4529)
Thanks to all our contributors! 🎉
What's Changed
New Contributors
Full Changelog: v4.5.0...v4.5.1
v4.5.0
changes since v4.4.0
⚠️ Breaking Changes
-
(go-v4): Upgrade controller-runtime from v0.19.4
to v0.20.0
and add support for Kubernetes 1.32 (#4492). See the controller-runtime release notes to learn more about the breaking changes introduced.
(Projects using webhooks):
Controller-runtime removed the deprecated webhook.Validator
and webhook.Defaulter
interfaces. Additionally, webhooks should no longer reside under the api
directory. Kubebuilder projects have not scaffolded webhooks in this directory or used the deprecated interfaces since v4.3.0.
If you are using these interfaces or the legacy apis
directory for webhooks, please refer to the v4.3.0 release notes, which provide guidance on updating your projects to align with the current standards.
To assist with migration or reduce the burden on users, Kubebuilder has introduced a flag option to allow scaffolding webhooks using the new interfaces in the legacy path. For now, you can scaffold webhooks in the legacy path (under api
) by using the command kubebuilder create webhook [OPTIONS] --legacy=true
. For reference, you can look at the CronJob Tutorial sample webhooks implementation.
✨ New Features
- (go-v4): Upgrade controller-gen from
v0.17.0
to v0.17.1
(#4493)
- (go-v4): Upgrade GolangCI Lint from
v1.62.2
to v1.63.4
(#4494)
- (go-v4): e2e tests: upgrade cert-manager version used from
v1.16.0
to v1.16.3
(#4497)
- (go-v4): e2e tests: follow cert-manager org name changes (#4505)
🐛 Bug Fixes
- (CLI) Ensure minimal golang version
1.23.0
(#4491)
- (helm/alpha-v1): Fix YAML lint in the ServiceMonitor file (#4502)
- (alpha generate command): Fix scenario where the output-dir path is not informed; default to the current directory (#4500)
- (alpha generate command): Allow re-creating projects with webhooks for external-apis (#4501)
- (go-v4): Use explicit
docker.io
prefix for Docker Hub images (#4513)
Thanks to all our contributors! 🎉
What's Changed
- 📖 Add helm-plugin to the summary of available plugins by @camilamacedo86 in #4485
- 🐛 Update golang version to 1.23.0 in init validation logic by @dmvolod in #4491
- 📖 Bump sigs.k8s.io/kubebuilder/v4 from 4.3.1 to 4.4.0 in /docs/book/src/simple-external-plugin-tutorial/testdata/sampleexternalplugin/v1 by @dependabot in #4488
- ⚠️ Upgrade controller-runtime from v0.19.4 to v0.20.0 and k8s deps from 1.31 to 1.32 by @camilamacedo86 in #4492
- ✨ Upgrade controller-gen from v0.17.0 to v0.17.1 by @camilamacedo86 in #4493
- ✨ Upgrade GolangCI Lint from v1.62.2 to v1.63.4 by @camilamacedo86 in #4494
- ✨ e2e tests: upgrade cert-manager version used from
v1.16.0
to v1.16.3
by @camilamacedo86 in #4497
- 🐛 (helm/alpha-v1): fix yaml lint in the ServiceMonitor file by @camilamacedo86 in #4502
- 🌱 CLI: Remove unused doc.go by @camilamacedo86 in #4504
- 🐛 fix: kubebuilder alpha generate command to allow re-create projects with webhooks for external-apis by @camilamacedo86 in #4501
- ✨ (go/v4): Follow cert-manager org name changes by @zchee in #4505
- 🌱 (ci): Add GH action to validate generated helm charts for tutorials by @akagami-harsh in #4472
- 🌱 fix: alpha generate command. If the output-dir path is not informed than it should be the current directory by @camilamacedo86 in #4500
- 🐛 Use explicit docker.io prefix for Docker Hub images by @pl4nty in #4513
New Contributors
Full Changelog: v4.4.0...v4.5.0
v4.4.0
changes since v4.3.1
✨ New Features
🐛 Bug Fixes
- (go/v4): Fixed an issue where GitHub Actions workflows were overwritten by commands, ensuring users can now customize workflows freely without their changes being overridden. (#4379)
- (go/v4): Resolved linting issues in generated scaffolds. (#4384)
- (kustomize/v2, go/v4): Fixed CA injection for conversion webhooks. Previously, the CA injection patch was not accurate; The injection should occur only for CRDs, which are conversion types and not for all CRDs when a webhook with
--conversion
option is scaffolded. The issue goes back to release 3.5.0
(where to replace vars for replacements was done and the kustomize/v2-alpha
plugin was introduced). It was not previously found, likely because conversion webhook features were incomplete, which is addressed in this release. Now, users can use the tool to generate the conversion webhooks properly (#4254). (#4282)
- (go/v4): Ensure that schemas are added before starting EnvTest-based suite tests for webhooks and controllers (#4466)
- (go/v4): e2e-tests: cleanup by removing calls to call make generate and manifests (#4471)
Thanks to all our contributors! 🎉
What's Changed
Read more v4.3.1
changes since v4.3.0
✨ New Features
Note: Only minor version updates were applied in this release.
- (go/v4): Upgraded
controller-runtime
from v0.19.0
to v0.19.1
. (#4234)
- (go/v4): Updated
kustomize
from v5.4.3
to v5.5.0
(#4235)
- (go/v4): Upgraded
golangci-lint
from v1.59
to v1.61
with minor adjustments for lint rules. (#4236)
🐛 Bug Fixes
- (kustomize/v2, go/v4): Corrected the generation of manifests under
config/crd/patches
to ensure the /convert
service patch is only created for webhooks configured with --conversion
. (#4280)
- (go/v4): Fixed path configuration for webhook markers generated for core types with non-"core" group values, ensuring accurate path handling in core-type webhooks. (#4301)
- (go/v4): Resolved misleading comments regarding metrics configuration for certs in
cmd/main.go
, providing clarity on secure metrics setup. (#4245)
- (go/v4): Enabled the
--make=false
option for webhook creation, ensuring consistency with other command options and improved flexibility. (#4275)
- (kustomize/v2, go/v4): Moved the
cert-manager
uncomment block to the top of kustomization.yaml
to enhance visibility (#4283)
- (Impact only for library users): ⚠️ Restructured internal layout to move
main.go
boilerplate into the cmd/
directory. This change is relevant for users consuming the framework as a library and Kubebuilder maintainers only, providing a cleaner separation of code. (#4246)
Thanks to all our contributors! 🎉
What's Changed
New Contributors
Full Changelog: v4.3.0...v4.3.1
v4.3.0
changes since v4.2.0
⚠️ Important Notice:
(Only projects using webhooks are impacted by)
Controller runtime has deprecated the webhook.Validator
and webhook.Defaulter
interfaces, and they will no longer be provided in future versions. Therefore, projects must adopt the new CustomValidator
and CustomDefaulter
interfaces to remain compatible with controller-runtime v0.20.0
and upper versions. For more details, refer to controller-runtime/issues/2641.
Furthermore, webhooks should no longer reside under the api
directory. Instead, they should be relocated to internal/webhook
. For now, you can scaffold webhooks in the legacy path (under api
) by using the command kubebuilder create webhook [OPTIONS] --legacy=true
, which scaffolds using the CustomValidator
and CustomDefaulter
interfaces. However, please note that this flag is deprecated and will be removed in upcoming releases.
Steps to Migrate:
-
Move Webhook Files to the Internal Directory:
Depending on your project structure, move the webhook files:
-
Single Group Layout: Move from api/<version>
to internal/webhook/<version>
.
Before:
api/
├── <version>/
│ ├── <kind>_webhook.go
│ ├── <kind>_webhook_test.go
│ └── webhook_suite_test.go
After:
internal/
├── webhook/
│ └── <version>/
│ ├── <kind>_webhook.go
│ ├── <kind>_webhook_test.go
│ └── webhook_suite_test.go
-
Multigroup Layout: Move from api/<group>/<version>
to internal/webhook/<group>/<version>
.
Before:
api/
├── <group>/
│ └── <version>/
│ ├── <kind>_webhook.go
│ ├── <kind>_webhook_test.go
│ └── webhook_suite_test.go
After:
internal/
├── webhook/
│ └── <group>/
│ └── <version>/
│ ├── <kind>_webhook.go
│ ├── <kind>_webhook_test.go
│ └── webhook_suite_test.go
-
Update Imports:
After moving the files, ensure that all references to webhooks are updated in your main.go
and other files. For example, update the import:
-
Replace Deprecated Interfaces with Custom Ones:
Replace webhook.Validator
and webhook.Defaulter
with the new CustomValidator
and CustomDefaulter
interfaces:
-
Before:
var _ webhook.Validator = &MyResource{}
func (r *MyResource) ValidateCreate() error { ... }
func (r *MyResource) ValidateUpdate() error { ... }
func (r *MyResource) ValidateDelete() error { ... }
var _ webhook.Defaulter = &MyResource{}
func (r *MyResource) Default() { ... }
-
After:
var _ webhook.CustomValidator = &MyResource{}
func (v *MyResource) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) {
myResource, ok := obj.(*MyResource)
if !ok { return nil, fmt.Errorf("expected MyResource, got %T", obj) }
return nil, validateMyResource(myResource)
}
func (v *MyResource) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) {
myResource, ok := newObj.(*MyResource)
if !ok { return nil, fmt.Errorf("expected MyResource, got %T", newObj) }
return nil, validateMyResource(myResource)
}
func (v *MyResource) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) {
myResource, ok := obj.(*MyResource)
if !ok { return nil, fmt.Errorf("expected MyResource, got %T", obj) }
return nil, nil
}
var _ webhook.CustomDefaulter = &MyResource{}
func (d *MyResource) Default(ctx context.Context, obj runtime.Object) error {
myResource, ok := obj.(*MyResource)
if !ok { return fmt.Errorf("expected MyResource, got %T", obj) }
// Defaulting logic
return nil
}
Example: See the tutorial: CronJob Webhook Example.
Note: You might want to use the Upgrade Assistance to re-scaffold your project and then apply your code changes on top, ensuring that all necessary updates are addressed. Also,
⚠️ Breaking Changes
- (Only projects using webhooks are impacted by) (go/v4): Replaced the deprecated
webhook.Validator
and webhook.Defaulter
interfaces with CustomValidator
and CustomDefaulter
. Projects using the old interfaces must migrate to ensure compatibility with future versions. (#4060)
- (Only projects using webhooks are impacted by) (go/v4): Webhooks are now decoupled from the API directory. Webhook files should be moved from
api/<version>
or api/<group>/<version>
to internal/webhook/<version>
or internal/webhook/<group>/<version>
. This restructuring improves project organization. (#4150)
- (Impact only for library users): Removed the
APIPackagePathLegacy
method, which has been obsolete since release 4.0.0. This change cleans up unused code. (#4182)
- (Impact only for library users): cleanup/refactor: Alpha Generate command. Move code source implementation to internal since this alpha feature is not designed to be imported by other tools (#4180)
- (Impact only for library users): Removed the redundant
HasFragment
method, favoring HasFileContentWith
to reduce duplication and simplify the codebase. (#4191)
✨ New Features
- (go/v4): Added DevContainer support, making development in environments like GitHub Workspaces easier by removing the need for local setup. (#4078)
- (go/v4): The e2e test scaffolding has been improved with a comprehensive set of tests under
e2e/tests
, covering the manager and webhooks. These tests are designed to fail when not run against clusters using Kind, and they avoid re-installing Prometheus and Cert-Manager if already present. See the final scaffolded tests in the samples under testdata here. Key improvements include:
- Added checks to detect existing Prometheus and Cert-Manager installations to prevent re-installation. (#4117)
- Enhanced e2e tests to ensure proper execution with Kind and clarified usage. (#4106)
- Ensured
make manifests
and make generate
are run as part of the e2e tests. (#4122)
- Aligned
make test-e2e
with make test
for consistent behavior. (#4125)
- Improved tests to validate metrics endpoints and ensure proper metric exposure, including guidance for using metrics in reconciliation validation. (#4131)
- Added support for scaffolded e2e webhook tests with the
+kubebuilder:scaffold:e2e-webhooks-checks
marker. (#4121)
- Simplified Gomega assertions for better readability and improved error handling and logging in
e2e/test.go
. (#4141, #4158, #4166, #4175)
- (go/v4): Improved the webhook tests by adding examples. Also, enhanced the CronJob tutorial to clarify usage and validate changes. (#4130)
- (deploy-image/v1alpha): Improved the tests scaffolded for controllers to ensure better coverage. (#4197)
- (go/v4): Added support for scaffolding controllers and webhooks for External Types, making it easier to work with external resources in projects. (#4171, #4203, #4217)
- (go/v4): Add Support for Scaffolding Webhooks for Core Types (#4210)
- (go/v4): Upgraded the cert-manager version used in tests from
v1.14.4
to v1.16.0
for better compatibility and features. (#4209)
- (deploy-image/v1-alpha1): Added comments to clarify how resource watching and reconciliation logic works in the scaffolded code. (#4102)
- (go/v4): Upgrade controller-tools version from v0.16.1 to v0.16.4 (#4215)
- (go/v4): Upgrade Prometheus Operator version used on the tests from v0.72.0 to 0.77.1 (#4212)
🐛 Bug Fixes
- (deploy-image/v1-alpha1): Corrected a typo, replacing
typeNamespaceName
with typeNamespacedName
to ensure accurate variable naming. (#4100)
- (deploy-image/v1-alpha1): Fixed sample code to apply correct labels to resources, improving consistency in the scaffolded examples. (#4101)
- (go/v4): Resolved linter issues in the scaffold, adding
nolint
where necessary to prevent failures for specific cases that should not fail during checks. (#4111)
- (deploy-image/v1-alpha1): Addressed additional linter issues to enhance code quality. (#4112)
- (go/v4): Fixed linter issues to pass stricter checks like
godot
, gofumpt
, and nlreturn
, ensuring better code formatting and style. (#4133)
- (go/v4): Removed duplicate webhook names in multi-version APIs, resolving conflicts when using the same webhook names across different API versions. (#4145)
- (go/v4): Improved webhook test templates by adding examples, providing clearer guidance for testing webhooks. (#4151)
- (go/v4): Ensured unique controller names to fix naming conflicts in multigroup layouts, improving support for projects with multiple groups. (#4162)
- (go/v4): Fixed the
HasResource
package method to stop once a match is found, improving performance and accuracy in resource handling. (#4190)
- (go/v4, kustomize/v2): Simplified s...
Read more v4.2.0
changes since v4.1.1
⚠️ Important Notice:
The artefacts for ENVTEST from k8s 1.31
are exclusively available at: Controller Tools Releases. Kubebuilder no longer builds and promote the ENVTEST artefacts at the old location https://storage.googleapis.com/kubebuilder-tools which is deprecated and can no longer be ensured by Kubebuilder maintainers. You should ensure that your projects are using the new location. For further information, see: #4082
This update is fully transparent for Kubebuilder users assuming that they properly update their scaffolds to use setup-envtest from controller-runtime branch release-0.19
.
# To know the available versions check:
# - https://github.com/kubernetes-sigs/controller-tools/blob/main/envtest-releases.yaml
ENVTEST_K8S_VERSION = 1.31.0
# Controller-Runtime branch `release-0.19` has the implementation of the setup-envtest's code responsible
# for downloading the tarball from the correct location.
ENVTEST_VERSION ?= release-0.19
...
.PHONY: envtest
envtest: $(ENVTEST) ## Download setup-envtest locally if necessary.
$(ENVTEST): $(LOCALBIN)
$(call go-install-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest,$(ENVTEST_VERSION))
✨ New Features
- (go/v4, kustomize/v2): Add support to protect project with network policies (#3853)
- (go/v4): Add support to k8s 1.31 (#4080)
- (go/v4): Upgrading controller-runtime from v0.18.4 to v0.19.0 (#4080)
- (go/v4): Upgrading controller-tools from v0.15.0 to v0.16.1 (#4080)
- (go/v4, kustomize/v2): Upgrade kustomize from v5.4.2 to v5.4.3 (#4084)
🐛 Bug Fixes
- (go/v4): Add missing cancel context to controller's suite-test (#4067)
- ⚠️ (Only relevant for users of Kubebuilder as a library): ImplementWebhooks should only be used by the e2e tests and should be under its package. Therefore, this method is no longer served under
pkg/plugin/util
(#4065)
What's Changed (Full Changelog)
New Contributors
Full Changelog: v4.1.1...v4.2.0
v4.1.1
changes since v4.1.0
✨ New Features
- (go/v4): Upgrade golangci-lint from
v1.57.2
to v1.59.1
(#4030)
- (go/v4): makefile: create unversioned symlinks for configurable binaries tools (#4013)
- (kustomize/v2, go/v4): upgrade kustomize version from
v5.4.1
to v5.4.2
(#4029)
- (Only relevant for users of Kubebuilder as a library): Add new CLI option and allow access to underlying CLI command (#4011)
🐛 Bug Fixes
- (go/v4): Fix security concerns by only enabling FilterProvider to protect the metrics endpoint with authn/authz when secureMetrics is true (#4022)
- (go/v4): Align Go Version in go.mod Template to 1.22.0 (#4012)
- (go/v4): Small cleanup in the main.go to keep all variables used defined on top of the file (#4036)
- (go/v4): Fix golang documentation of the method LoadImageToKindClusterWithName scaffold in the e2e tests (#4034)
- (go/v4): Fix validation used to ensure Kind versions pattern (#3986)
- (kustomize/v2, go/v4): Add missing labels for config/default/manager_webhook_patch.yaml (#4028)
Note Based on the changes, it seems appropriate to release these updates as version 4.1.1 rather than 4.2.0. The new features are minor improvements which only affect new projects and do not introduce breaking changes or significant new functionality for existing users.
What's Changed (Full Changelog)
- 🌱 Bump golang.org/x/tools from 0.22.0 to 0.23.0 by @dependabot in #4007
- ✨ (Only relevant for users of Kubebuilder as a library) - Add new cli option and allow access to underlying cli command by @beatrausch in #4011
- 🐛 Align Go Version in go.mod Template to 1.22.0 by @camilamacedo86 in #4012
- 📖 Upgrade controller-gen used to generated the docs and remove redirects for artefact images by @camilamacedo86 in #4010
- ✨ Makefile: Create Version-Agnostic Symlinks for Specified Versioned Binaries by @schrej in #4013
- 📖 docs: correct typo in migration guide by @Gearheads in #4015
- 📖 clarify in note that metrics are protected by default via controller-runtime feature by @camilamacedo86 in #4026
- 📖 Update roadmap_2024.md - with the latest changes and by order the tasks adding what was done at the bottom of the page by @camilamacedo86 in #4027
- 🐛 (kustomize/v2,go/v4): add missing labels for config/default/manager_webhook_patch.yaml by @camilamacedo86 in #4028
- ✨ (kustomize/v2,go/v4): upgrade kustomize version from v5.4.1 to v5.4.2 by @camilamacedo86 in #4029
- ✨ Upgrade golangci-lint from v1.57.2 to v1.59.1 by @camilamacedo86 in #4030
- 🌱 Update release.yml - Update goreleaser from 1.11.2 to v2.1.0 by @camilamacedo86 in #4031
- 🌱 Update Makefile - Remove makefile target to test legacy project no longer supported by @camilamacedo86 in #4032
- 📖 Update test examples not to set Status on create by @hsadoyan in #4016
- 🐛 Fix validation used to ensure Kind versions pattern by @Kavinjsir in #3986
- 🐛 Fix golang documentation of the method LoadImageToKindClusterWithName scaffold in the e2e tests by @fengshunli in #4034
- 🐛 Fix security concerns by only enabling FilterProvider to protect the metrics endpoint with authn/authz when secureMetrics is true by @alex-kattathra-johnson in #4022
- 🐛 cleanup/enhancement: keep all variables used defined on top of
main.go
by @fengshunli in #4036
- 🌱 fix error faced during release process by ensuring dist directory is cleaned before running GoReleaser by @camilamacedo86 in #4040
- 🌱 Upgrade goreleaser by @camilamacedo86 in #4041
New Contributors
Full Changelog: v4.1.0...v4.1.1
v4.1.0
changes since v4.0.0
✨ New Features
This protection is similar to what was previously done via kube-rbac-proxy
, which usage was discontinued in the project. Please, ensure that you no longer use the image gcr.io/kubebuilder/kube-rbac-proxy
. ⚠️ Images provided under gcr.io/kubebuilder/
All images previously built and promoted will stop being available sometime in early 2025**.
- Upgrade controller-runtime from v0.18.2 to v0.18.4 (#3957) (#3972)
- Add revive golangci linter with comment-spacings rule (#3960)
- (Only relevant for users of Kubebuilder as a library) Allow usage of custom marker names (#3993)
🐛 Bug Fixes
- Corrected the
generate
command to respect the --namespaced=false
flag for APIs. (#3970)
🎉 Thanks to all our contributors!
What's Changed (Full Changelog)
New Contributors
Full Changelog: v4.0.0...v4.1.0
RetroSearch is an open source project built by @garambo
| Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4