Skip to content

chore(deps): updated k8s KubernetesClient to v18.0.5 - #976

Merged
buehler merged 7 commits into
dotnet:mainfrom
kimpenhaus:k8s-client-v18
Nov 7, 2025
Merged

buehler merged 7 commits into
dotnet:mainfrom
kimpenhaus:k8s-client-v18

Conversation

@kimpenhaus

@kimpenhaus kimpenhaus commented Oct 31, 2025 •

Copy link
Copy Markdown
Collaborator

Hi Christoph @buehler ,

I've updated the k8s KubernetesClient to v18 which brings some breaking changes. Unfortunately there is no detailed changelog so I had to extract the changes by comparing v17.0.14 with v18.0.5.

Things to mention are:

  • IValidation interface was dropped - so I removed the Validation call from Transpiler/Crds.cs
image
  • Model changed from ctor arguments to property initialization

  • WatcherExt methods are marked as obsolete - but sadly the message is misleading so I have no idea yet how to replace. I will start a discussion about that with the k8s team. In the meanwhile I disabled the obsolete warning with a pragme which I will remove once I know how to chage it properly. (see: WatcherExt: Watch & WatchAsync marked as obsolete kubernetes-client/csharp#1679)

image

this will make pull request #967 obsolete

- Updated project files to use the latest version of `KubernetesClient` across the solution.
- Adjusted `Crds` logic to align with the updated library API.
…thand across tests and core classes

- Refactored entity `Metadata` and other class initializations to use object initializer shorthand consistently.
- Marked test classes as `sealed` for improved optimization and design clarity.
- Adjusted tests and core logic to align with the updated initialization style and coding standards.
- Updated object initializations across generator classes to use initializer shorthand for consistency.
- Marked generator classes as `sealed` for optimization and better design practices.
- Improved readability and alignment with modern C# coding standards.
…alizer tests

- Marked entities (`V1OperatorIntegrationTestEntity` and its sub-classes) and test classes as `sealed` for better design and optimization.
- Added null checks in finalizer integration tests to improve safety and adherence to modern C# standards.
- Disabled obsolete warning in `KubernetesClient` with a TODO for clarification.
…sts and core classes

- Updated object and dictionary initializations to improve readability.
- Applied consistent formatting to multiline constructs and private methods.
- Improved alignment with modern C# coding style.
- Adjusted formatting in `RbacGenerator` and `NamespacedOperator.Integration.Test` to enhance consistency and readability.
@buehler
buehler enabled auto-merge (squash) November 7, 2025 12:26
@buehler
buehler merged commit eff4af5 into dotnet:main Nov 7, 2025
@kimpenhaus
kimpenhaus deleted the k8s-client-v18 branch November 9, 2025 10:49
kimpenhaus added a commit that referenced this pull request Nov 28, 2026
## Summary

`kubeops generate operator` produced an unusable conversion webhook for
CRDs with a `[ConversionWebhook]`. Checked
against Kubernetes 1.36 (OrbStack) with
`examples/ConversionWebhookOperator`:

| Generated CRD | Result |
| --- | --- |
| before: `service: { name: service }` (no namespace) | the API server
rejects the CRD: `spec.conversion.webhookClientConfig.service.name:
Required value` (the namespace is missing) |
| only `name: operator` | `service "operator" not found`: kustomize
prefixes the service to `<name>-operator`, but does not rename a service
reference in a CRD |
| `name: <name>-operator`, `namespace: <name>-system` | conversion v1 ↔
v3 works |

Changes:

- **CRD** (`CrdGenerator`): the conversion webhook points at the
`operator` service in the operator namespace
(`--namespace` or `<name>-system`); kustomize replaces the namespace
with the one of the kustomization.
- **`kustomizeconfig.yaml`** (new `KustomizeConfigGenerator`): a
`nameReference` from `Service` to
`spec/conversion/webhook/clientConfig/service/name` of
`CustomResourceDefinition`, listed under `configurations` in
the `kustomization.yaml` (as kubebuilder does). Kustomize renames this
reference for validation and mutation
webhooks 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.
- **Webhook deployment**: no longer sets `hostPort: 5001`. It came in
with #976 (v9.11.9), where
`new(5001, name: "https")` (the `containerPort`) became `HostPort =
5001`; #1061 added `ContainerPort` but 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>:5001` loses that.
- The service name `operator` is a shared constant
(`WebhookDeploymentGenerator.ServiceName`) for the service, the
  webhook 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 `v2` version with a
conversion webhook (same CRD).
`Should_Point_Webhooks_At_The_Generated_Service` checks that the
rendered CRD points at the rendered service and
namespace, `Should_Wire_The_Generated_Deployment` that no port has a
`hostPort`.

Docs: `cli.mdx` says to apply the manifests with `kubectl apply -k`.

Rebased onto #1358: the test conversion webhook no longer needs
`[RequiresPreviewFeatures]`.

## Checks

- `/code-review` (medium): no blocking bug. Fixed: the test converter
sets `apiVersion`/`kind` (the test entities are
not partial); `kustomizeconfig.yaml` with LF; docs on applying CRD files
without kustomize; `hostPort` removal noted
here. Not part of this PR (pre-existing): a `[ConversionWebhook(group,
plural)]` with an own route is not reflected
  in the CRD path.
- `/simplify`: shared constant for the service name; one `CrdGenerator`
call instead of two.
- `/security-review`: no findings; dropping the `hostPort` no longer
binds the webhook port on the node.
- `dotnet build -c Release` without warnings, `dotnet format
--verify-no-changes`, `KubeOps.Cli.Test` unit tests (100)
  and integration tests (8 per TFM) against OrbStack pass.
- End-to-end test in OrbStack: see comment below.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants