Repository navigation
fix(cli): point the conversion webhook at the operator service - #1357
Merged
Merged
Conversation
Collaborator
Author
End-to-end test in OrbStack (Kubernetes v1.36.5)
kubeops generate operator conv-test examples/ConversionWebhookOperator/ConversionWebhookOperator.csproj \
--out ./final --docker-image conversion-webhook-operator --docker-image-tag test
kubectl apply -k ./final
Not part of this PR: for about 5 seconds right after the rollout, a conversion failed with |
kimpenhaus
marked this pull request as ready for review
November 28, 2026 23:41
kimpenhaus
added a commit
that referenced
this pull request
Nov 28, 2026
…oks (#1358) ## Summary Since #639 (v8.0.0), the conversion webhook API (`ConversionWebhook<TEntity>`, `IEntityConverter`, the review types) carried `[RequiresPreviewFeatures]`. It is a stability marker of KubeOps, not a .NET preview feature: #639 used it to allow breaking changes outside major versions. The API has been in use unchanged for three years, and KubeOps follows semantic versioning, so the marker only costs users an opt-in (`EnablePreviewFeatures` or `[RequiresPreviewFeatures]` on their own webhooks, otherwise CA2252 fails the build). - Removed the attribute from `src/KubeOps.Operator.Web/Webhooks/Conversion`, the CA2252 suppressions in `WebhookLoader` and the CLI, and `EnablePreviewFeatures` from the CLI, the tests and the example. - Docs: removed the preview warnings from `webhooks.mdx` and the package README; one line in `migration.mdx`. Not breaking: an existing opt-in in a user project keeps compiling. Note: #1357 adds a conversion webhook with `[RequiresPreviewFeatures]` to the CLI test operator; whichever PR is merged second, the attribute is removed there afterwards. ## Checks - `/code-review` (medium): no bugs; Release build of the solution without warnings on net10.0 and net11.0. - `/simplify`: no leftover references in `src`, `test`, `examples`, `docs`, generator or templates. - `/security-review`: not applicable, only compile-time markers are removed. - `dotnet format --verify-no-changes`; unit tests pass: `KubeOps.Operator.Web.Test` (172), `KubeOps.Cli.Test` (100), `KubeOps.Generator.Test` (124), `KubeOps.Abstractions.Test` (330).
The generated CRD pointed its conversion webhook at the service "service" without a namespace, so the API server rejected the CRD. It now points at the operator service in the operator namespace, and the CLI generates a kustomizeconfig.yaml with a name reference, as kustomize does not rename a service reference in a CRD on its own. The webhook deployment no longer sets hostPort 5001, which kept a rolling update from starting the new pod on the node of the old one.
kimpenhaus
force-pushed
the
fix/cli-conversion-webhook
branch
from
November 28, 2026 23:51
5fa0870 to
ab4ed85
Compare
kimpenhaus
enabled auto-merge (squash)
November 28, 2026 23:52
|
🎉 This PR is included in version 15.0.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
This was referenced Dec 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
kubeops generate operatorproduced an unusable conversion webhook for CRDs with a[ConversionWebhook]. Checkedagainst Kubernetes 1.36 (OrbStack) with
examples/ConversionWebhookOperator:service: { name: service }(no namespace)spec.conversion.webhookClientConfig.service.name: Required value(the namespace is missing)name: operatorservice "operator" not found: kustomize prefixes the service to<name>-operator, but does not rename a service reference in a CRDname: <name>-operator,namespace: <name>-systemChanges:
CrdGenerator): the conversion webhook points at theoperatorservice in the operator namespace(
--namespaceor<name>-system); kustomize replaces the namespace with the one of the kustomization.kustomizeconfig.yaml(newKustomizeConfigGenerator): anameReferencefromServicetospec/conversion/webhook/clientConfig/service/nameofCustomResourceDefinition, listed underconfigurationsinthe
kustomization.yaml(as kubebuilder does). Kustomize renames this reference for validation and mutationwebhooks on its own, but not for CRDs. Only generated when a conversion webhook exists; written with LF.
KustomizationConfig.Configurations(KubeOps.Abstractions): new nullable property, additive.hostPort: 5001. It came in with chore(deps): updated k8s KubernetesClient to v18.0.5 #976 (v9.11.9), wherenew(5001, name: "https")(thecontainerPort) becameHostPort = 5001; fix: webhook name generation for resources without a group and missing container port in webhook deployment generation #1061 addedContainerPortbut kept it.With it, a rolling update cannot start the new pod on the node of the old one (seen in OrbStack), and at most one
pod runs per node. The service reaches the pod through
targetPort: https. Anyone who reached the webhook through<node-ip>:5001loses that.operatoris a shared constant (WebhookDeploymentGenerator.ServiceName) for the service, thewebhook configurations and the CRD.
Tests: the CLI test operator had no conversion webhook, which is why
Should_Generate_Installer_The_Api_Server_Accepts(server dry run) never saw such a CRD. It now has a
v2version with a conversion webhook (same CRD).Should_Point_Webhooks_At_The_Generated_Servicechecks that the rendered CRD points at the rendered service andnamespace,
Should_Wire_The_Generated_Deploymentthat no port has ahostPort.Docs:
cli.mdxsays to apply the manifests withkubectl apply -k.Rebased onto #1358: the test conversion webhook no longer needs
[RequiresPreviewFeatures].Checks
/code-review(medium): no blocking bug. Fixed: the test converter setsapiVersion/kind(the test entities arenot partial);
kustomizeconfig.yamlwith LF; docs on applying CRD files without kustomize;hostPortremoval notedhere. Not part of this PR (pre-existing): a
[ConversionWebhook(group, plural)]with an own route is not reflectedin the CRD path.
/simplify: shared constant for the service name; oneCrdGeneratorcall instead of two./security-review: no findings; dropping thehostPortno longer binds the webhook port on the node.dotnet build -c Releasewithout warnings,dotnet format --verify-no-changes,KubeOps.Cli.Testunit tests (100)and integration tests (8 per TFM) against OrbStack pass.