![]() |
VOOZH | about |
dotnet add package KubeOps.Operator --version 11.3.0
NuGet\Install-Package KubeOps.Operator -Version 11.3.0
<PackageReference Include="KubeOps.Operator" Version="11.3.0" />
<PackageVersion Include="KubeOps.Operator" Version="11.3.0" />Directory.Packages.props
<PackageReference Include="KubeOps.Operator" />Project file
paket add KubeOps.Operator --version 11.3.0
#r "nuget: KubeOps.Operator, 11.3.0"
#:package KubeOps.Operator@11.3.0
#addin nuget:?package=KubeOps.Operator&version=11.3.0Install as a Cake Addin
#tool nuget:?package=KubeOps.Operator&version=11.3.0Install as a Cake Tool
The KubeOps.Operator package provides a framework for building Kubernetes operators in .NET. Built on top of the Kubernetes client libraries for .NET, it offers abstractions and utilities for implementing operators that manage custom resources in a Kubernetes cluster.
Install the package from NuGet:
dotnet add package KubeOps.Operator
After installation, you can create entities, controllers, finalizers, and other components to implement your operator.
All resources must be registered with the operator builder to be recognized by the SDK and used as operator resources. The KubeOps.Generator provides convenience methods to register all components at once.
You'll need to use the Generic Host to run your operator. For a plain operator without webhooks, ASP.NET is not required (unlike v7).
using KubeOps.Operator;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
var builder = Host.CreateApplicationBuilder(args);
builder.Logging.SetMinimumLevel(LogLevel.Trace);
builder.Services
.AddKubernetesOperator()
.RegisterComponents();
using var host = builder.Build();
await host.RunAsync();
When using the KubeOps.Generator, you can use the RegisterComponents function:
builder.Services
.AddKubernetesOperator()
.RegisterComponents();
Alternatively, you can register resources manually:
builder.Services
.AddKubernetesOperator()
.AddController<TestController, V1TestEntity>()
.AddFinalizer<FirstFinalizer, V1TestEntity>("first")
.AddFinalizer<SecondFinalizer, V1TestEntity>("second");
To create an entity, implement the IKubernetesObject<V1ObjectMeta> interface. The SDK provides convenience classes to help with initialization, status, and spec properties.
[KubernetesEntity(Group = "testing.dev", ApiVersion = "v1", Kind = "TestEntity")]
public sealed class V1TestEntity :
CustomKubernetesEntity<V1TestEntity.EntitySpec, V1TestEntity.EntityStatus>
{
public override string ToString()
=> $"Test Entity ({Metadata.Name}): {Spec.Username} ({Spec.Email})";
public class EntitySpec
{
public string Username { get; set; } = string.Empty;
public string Email { get; set; } = string.Empty;
}
public class EntityStatus
{
public string Status { get; set; } = string.Empty;
}
}
A controller reconciles a specific entity type. Implement controllers using the IEntityController<TEntity> interface. You can reconcile custom entities or other Kubernetes resources as long as they are registered with the operator. For guidance on reconciling external resources, refer to the documentation.
Example controller implementation:
using KubeOps.Abstractions.Reconciliation;
using KubeOps.Abstractions.Reconciliation.Controller;
using KubeOps.Abstractions.Rbac;
using KubeOps.KubernetesClient;
using Microsoft.Extensions.Logging;
[EntityRbac(typeof(V1TestEntity), Verbs = RbacVerb.All)]
public sealed class V1TestEntityController : IEntityController<V1TestEntity>
{
private readonly IKubernetesClient _client;
private readonly ILogger<V1TestEntityController> _logger;
public V1TestEntityController(
IKubernetesClient client,
ILogger<V1TestEntityController> logger)
{
_client = client;
_logger = logger;
}
public async Task<ReconciliationResult<V1TestEntity>> ReconcileAsync(V1TestEntity entity, CancellationToken cancellationToken)
{
_logger.LogInformation("Reconciling entity {Entity}.", entity);
// Update status to indicate reconciliation in progress
entity.Status.Status = "Reconciling";
entity = await _client.UpdateStatus(entity);
// Update status to indicate reconciliation complete
entity.Status.Status = "Reconciled";
await _client.UpdateStatus(entity);
return ReconciliationResult<V1TestEntity>.Success(entity);
}
public Task<ReconciliationResult<V1TestEntity>> DeletedAsync(V1TestEntity entity, CancellationToken cancellationToken)
{
_logger.LogInformation("Entity {Entity} deleted.", entity);
return Task.FromResult(ReconciliationResult<V1TestEntity>.Success(entity));
}
}
This controller:
DeletedAsync method for handling deletion eventsCAUTION: Always use the returned values from modifying actions of the Kubernetes client. Failure to do so will result in "HTTP CONFLICT" errors due to the resource version field in the entity.
NOTE: Do not update the entity itself in the reconcile loop. It is considered bad practice to update entities while reconciling them. However, the status may be updated. To update entities before they are reconciled (e.g., to validate or transform values), use webhooks instead.
A finalizer is a mechanism for asynchronous cleanup in Kubernetes. Implement finalizers using the IEntityFinalizer<TEntity> interface.
KubeOps provides automatic finalizer attachment and detachment to ensure proper resource cleanup.
If you need special handling this automation can be disabled by configuration.
Finalizers then are attached using an EntityFinalizerAttacher and are called when the entity is marked for deletion.
using KubeOps.Abstractions.Reconciliation;
using KubeOps.Abstractions.Reconciliation.Finalizer;
public sealed class FinalizerOne : IEntityFinalizer<V1TestEntity>
{
public Task<ReconciliationResult<V1TestEntity>> FinalizeAsync(V1TestEntity entity, CancellationToken cancellationToken)
{
// Implement cleanup logic here
return Task.FromResult(ReconciliationResult<V1TestEntity>.Success(entity));
}
}
NOTE: The controller's
DeletedAsyncmethod will be called after all finalizers are removed.
For more information, visit the documentation.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 1 NuGet packages that depend on KubeOps.Operator:
| Package | Downloads |
|---|---|
|
KubeOps.Operator.Web
This is an operator sdk written in c#. It enables a developer to create a custom controller for CRDs (CustomResourceDefinitions) that runs on kubernetes. This operator uses ASP.net to support webhooks and external access to the operator. |
Showing the top 1 popular GitHub repositories that depend on KubeOps.Operator:
| Repository | Stars |
|---|---|
|
josephnhtam/live-streaming-server-net
A .NET implementation of RTMP live streaming server, supporting HTTP-FLV, WebSocket-FLV, HLS, Kubernetes, cloud storage services integration and more.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 11.4.0-prerelease.1 | 0 | 6/18/2026 |
| 11.3.1-prerelease.1 | 0 | 6/18/2026 |
| 11.3.0 | 133 | 6/16/2026 |
| 11.3.0-prerelease.2 | 44 | 6/16/2026 |
| 11.3.0-prerelease.1 | 80 | 6/12/2026 |
| 11.2.1-prerelease.5 | 50 | 6/12/2026 |
| 11.2.1-prerelease.4 | 46 | 6/12/2026 |
| 11.2.1-prerelease.3 | 56 | 6/12/2026 |
| 11.2.1-prerelease.2 | 52 | 6/12/2026 |
| 11.2.1-prerelease.1 | 51 | 6/12/2026 |
| 11.2.0 | 1,494 | 6/2/2026 |
| 11.2.0-prerelease.2 | 58 | 6/2/2026 |
| 11.2.0-prerelease.1 | 74 | 6/2/2026 |
| 11.1.1-prerelease.4 | 58 | 6/2/2026 |
| 11.1.1-prerelease.3 | 55 | 6/2/2026 |
| 11.1.1-prerelease.2 | 60 | 5/30/2026 |
| 11.1.1-prerelease.1 | 63 | 5/26/2026 |
| 11.1.0 | 1,095 | 5/26/2026 |
| 11.1.0-prerelease.1 | 63 | 5/21/2026 |
| 11.0.1-prerelease.1 | 59 | 5/20/2026 |
'## [11.3.0](https://github.com/dotnet/dotnet-operator-sdk/compare/v11.2.0...v11.3.0) (2026-06-16)
### Features
* support attribute inheritance in transpiler ([#1129](https://github.com/dotnet/dotnet-operator-sdk/issues/1129)) ([cadb22f](https://github.com/dotnet/dotnet-operator-sdk/commit/cadb22ff47de9745d53d6bd204c994861e7422b6)), closes [#1025](https://github.com/dotnet/dotnet-operator-sdk/issues/1025) [#806](https://github.com/dotnet/dotnet-operator-sdk/issues/806)
### Bug Fixes
* **transpiler:** add validation for circular type references ([#1141](https://github.com/dotnet/dotnet-operator-sdk/issues/1141)) ([f6227e4](https://github.com/dotnet/dotnet-operator-sdk/commit/f6227e424de08caef8622c59e4a425a0ca40e7a4)), closes [#351](https://github.com/dotnet/dotnet-operator-sdk/issues/351)
* **watcher:** add deletion tracking state to allow status updates during finalization when using ByGeneration strategy ([#1127](https://github.com/dotnet/dotnet-operator-sdk/issues/1127)) ([129377b](https://github.com/dotnet/dotnet-operator-sdk/commit/129377b972f622cfd097e626af44e3784b394dc0))
### Dependencies
* **core:** update aspire monorepo ([#1153](https://github.com/dotnet/dotnet-operator-sdk/issues/1153)) ([e033805](https://github.com/dotnet/dotnet-operator-sdk/commit/e033805ddf86e3f11aa3e98a5ef965e9fff3fe03))
* **core:** update aspire monorepo to 13.4.3 ([#1143](https://github.com/dotnet/dotnet-operator-sdk/issues/1143)) ([b9f0575](https://github.com/dotnet/dotnet-operator-sdk/commit/b9f05758f24345cd6a95125468f43aac0a4b57e9))
* **core:** update opentelemetry-dotnet monorepo to 1.16.0 ([#1145](https://github.com/dotnet/dotnet-operator-sdk/issues/1145)) ([30a871e](https://github.com/dotnet/dotnet-operator-sdk/commit/30a871e558defb0c7b241ffde95b405c7cfd40c8))
* **core:** update spectre-console monorepo to 0.57.0 ([#1146](https://github.com/dotnet/dotnet-operator-sdk/issues/1146)) ([371dcae](https://github.com/dotnet/dotnet-operator-sdk/commit/371dcaedbd3e80638b693d72a0acf989bf7234e6))
* **test:** update dotnet monorepo ([#1144](https://github.com/dotnet/dotnet-operator-sdk/issues/1144)) ([a41b074](https://github.com/dotnet/dotnet-operator-sdk/commit/a41b074145fd03ba793fee4250ae5d2005f4b433))
* **tools:** update dependency nuget-license to v4.0.11 ([#1154](https://github.com/dotnet/dotnet-operator-sdk/issues/1154)) ([dd7a833](https://github.com/dotnet/dotnet-operator-sdk/commit/dd7a833461252c2cdec191fb08f73f132c077598))
### Documentation
* update Aspire operator docs ([#1149](https://github.com/dotnet/dotnet-operator-sdk/issues/1149)) ([a93865e](https://github.com/dotnet/dotnet-operator-sdk/commit/a93865ef5468f62b352b5fd5d88f97b0f13306f9))
'