Repository navigation
Description
Is your feature request related to a problem? Please describe.
Several internal components hardcode the construction of Kubernetes resources, making it impossible for users to customize the shape of these resources without replacing entire subsystems:
CrdInstallerhardcodesV1CustomResourceDefinitiongeneration via the transpilerKubeOpsEventPublisherFactory.Create()hardcodesCorev1Eventconstruction inlineWebhookServiceBasehardcodesV1MutatingWebhookConfigurationandV1ValidatingWebhookConfigurationconstruction
For example, a user who needs to add custom labels to webhook configurations, set a specific failurePolicy, or modify CRD metadata before installation has no extension point — they must fork or replace the entire hosting service.
Describe the solution you would like
Extract resource-building logic into public interfaces in KubeOps.Abstractions, with default implementations registered via TryAdd in DI. This follows the existing IEventPublisherFactory pattern and lets users register their own implementation before calling the operator builder to win. The default implementation for these abstractions should be public classes with virtual methods. The typical customization workflow would be to derive from the default implementation.
Three new interfaces:
-
ICrdResourceFactory(KubeOps.Abstractions.Crds) —V1CustomResourceDefinition CreateCrd(Type entityType). The default implementation calls the staticTranspilemethod,CrdGeneratortakesICrdResourceFactoryvia constructor injection and invokes it where it previously invokedTranspile. -
IEventResourceFactory(KubeOps.Abstractions.Events) —Corev1Event CreateEvent(IKubernetesObject<V1ObjectMeta> entity, string reason, string message, EventType type). Default implementation moves theCorev1Eventconstruction out ofKubeOpsEventPublisherFactory. The existingIEventPublisherFactoryremains as the coarse-grained override; this is the fine-grained hook for just the resource shape without reimplementing the fetch/save lifecycle. -
IWebhookConfigurationFactory(KubeOps.Abstractions.Webhooks) — two methods:CreateMutatingConfiguration(...)andCreateValidatingConfiguration(...), accepting typed registration DTOs (MutatingWebhookRegistration/ValidatingWebhookRegistrationcarrying entity metadata, hook type name, base URI, CA bundle). The default implementation moves the LINQ pipelines out ofWebhookServiceBase.RegisterMutators()/RegisterValidators(). Conversion webhook registration (RegisterConverters) is excluded since it patches existing CRDs rather than creating standalone configuration objects.
All defaults should be registered with TryAddSingleton / TryAddTransient so that user-registered implementations win.
Additional Context
This is a non-breaking change: default implementations preserve current behavior exactly, all existing tests should pass unchanged.
The pattern is already established in the codebase — IEventPublisherFactory is registered with TryAddTransient in OperatorBuilder and is fully replaceable. This proposal extends the same idiom to the remaining resource-generating components.
Actual use cases for this feature:
- Deploying the same operator in different namespaces.
- Adding custom metadata to the resources created.
- Improving developer workflows, especially when switching between local cluster vs shared development cluster.
Activity
BalassaMarton commentedon May 12, 2026
I edited the
ICrdResourceFactoryinterface so that it doesn't addSystem.Reflection.MetadataLoadContextto the dependencies of theAbstractionspackage. My PR is underway.feat: Add extension points for resource generation
feat: Add extension points for resource generation
feat: Add extension points for resource generation (dotnet#1118)