KubeOps.Operator.Web
8.0.0-pre.20
See the version list below for details.
dotnet add package KubeOps.Operator.Web --version 8.0.0-pre.20
NuGet\Install-Package KubeOps.Operator.Web -Version 8.0.0-pre.20
<PackageReference Include="KubeOps.Operator.Web" Version="8.0.0-pre.20" />
paket add KubeOps.Operator.Web --version 8.0.0-pre.20
#r "nuget: KubeOps.Operator.Web, 8.0.0-pre.20"
// Install KubeOps.Operator.Web as a Cake Addin #addin nuget:?package=KubeOps.Operator.Web&version=8.0.0-pre.20&prerelease // Install KubeOps.Operator.Web as a Cake Tool #tool nuget:?package=KubeOps.Operator.Web&version=8.0.0-pre.20&prerelease
KubeOps Operator Web
The KubeOps Operator Web package provides a webserver to enable webhooks for your Kubernetes operator.
Usage
To enable webhooks and external access to your operator, you need to
use ASP.net. The project file needs to reference Microsoft.NET.Sdk.Web
instead of Microsoft.NET.Sdk
and the Program.cs
needs to be changed.
To allow webhooks, the MVC controllers need to be registered and mapped.
The basic Program.cs
setup looks like this:
using KubeOps.Operator;
var builder = WebApplication.CreateBuilder(args);
builder.Services
.AddKubernetesOperator()
.RegisterComponents();
builder.Services
.AddControllers();
var app = builder.Build();
app.UseRouting();
app.MapControllers();
await app.RunAsync();
Note the .AddControllers
and .MapControllers
call.
Without them, your webhooks will not be reachable.
Validation Hooks
To create a validation webhook, first create a new class
that implements the ValidationWebhook<T>
base class.
Then decorate the webhook with the ValidationWebhookAttribute
to set the route correctly.
After that setup, you may overwrite any of the following methods:
- Create
- CreateAsync
- Update
- UpdateAsync
- Delete
- DeleteAsync
The async methods take precedence over the sync methods.
An example of such a validation webhook looks like:
[ValidationWebhook(typeof(V1TestEntity))]
public class TestValidationWebhook : ValidationWebhook<V1TestEntity>
{
public override ValidationResult Create(V1TestEntity entity, bool dryRun)
{
if (entity.Spec.Username == "forbidden")
{
return Fail("name may not be 'forbidden'.", 422);
}
return Success();
}
public override ValidationResult Update(V1TestEntity oldEntity, V1TestEntity newEntity, bool dryRun)
{
if (newEntity.Spec.Username == "forbidden")
{
return Fail("name may not be 'forbidden'.");
}
return Success();
}
}
To create the validation results, use the protected
methods (Success
and Fail
)
like "normal" IActionResult
creation methods.
Mutation Hooks
TODO.
Conversion Hooks
TODO.
Installing In The Cluster
TODO.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- KubeOps.Operator (>= 8.0.0-pre.20)
-
net7.0
- KubeOps.Operator (>= 8.0.0-pre.20)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
9.1.5 | 7,323 | 9/10/2024 |
9.1.4 | 503 | 8/26/2024 |
9.1.3 | 5,037 | 6/28/2024 |
9.1.2 | 2,231 | 6/20/2024 |
9.1.1 | 2,299 | 5/22/2024 |
9.1.0 | 1,773 | 5/15/2024 |
9.0.2 | 108 | 5/13/2024 |
9.0.0 | 5,527 | 3/13/2024 |
9.0.0-pre.4 | 58 | 4/19/2024 |
9.0.0-pre.3 | 56 | 3/21/2024 |
9.0.0-pre.2 | 58 | 3/13/2024 |
9.0.0-pre.1 | 72 | 3/7/2024 |
8.0.2-pre.2 | 68 | 2/21/2024 |
8.0.2-pre.1 | 48 | 2/19/2024 |
8.0.1 | 3,974 | 2/13/2024 |
8.0.1-pre.7 | 70 | 2/12/2024 |
8.0.1-pre.6 | 67 | 2/7/2024 |
8.0.1-pre.5 | 74 | 2/5/2024 |
8.0.1-pre.4 | 59 | 1/31/2024 |
8.0.1-pre.3 | 60 | 1/26/2024 |
8.0.1-pre.2 | 55 | 1/25/2024 |
8.0.1-pre.1 | 66 | 1/18/2024 |
8.0.0 | 381 | 1/17/2024 |
8.0.0-pre.45 | 54 | 1/17/2024 |
8.0.0-pre.44 | 72 | 1/16/2024 |
8.0.0-pre.43 | 62 | 1/16/2024 |
8.0.0-pre.42 | 196 | 1/10/2024 |
8.0.0-pre.41 | 140 | 1/2/2024 |
8.0.0-pre.40 | 119 | 12/27/2023 |
8.0.0-pre.39 | 70 | 12/21/2023 |
8.0.0-pre.38 | 156 | 12/6/2023 |
8.0.0-pre.37 | 63 | 12/6/2023 |
8.0.0-pre.36 | 68 | 12/3/2023 |
8.0.0-pre.35 | 70 | 11/28/2023 |
8.0.0-pre.34 | 94 | 11/24/2023 |
8.0.0-pre.33 | 66 | 11/24/2023 |
8.0.0-pre.32 | 56 | 11/23/2023 |
8.0.0-pre.31 | 72 | 11/23/2023 |
8.0.0-pre.30 | 64 | 11/23/2023 |
8.0.0-pre.29 | 152 | 11/11/2023 |
8.0.0-pre.28 | 68 | 11/8/2023 |
8.0.0-pre.27 | 168 | 10/23/2023 |
8.0.0-pre.26 | 77 | 10/19/2023 |
8.0.0-pre.25 | 67 | 10/18/2023 |
8.0.0-pre.24 | 81 | 10/13/2023 |
8.0.0-pre.23 | 73 | 10/13/2023 |
8.0.0-pre.22 | 78 | 10/13/2023 |
8.0.0-pre.21 | 69 | 10/12/2023 |
8.0.0-pre.20 | 74 | 10/11/2023 |
8.0.0-pre.19 | 73 | 10/9/2023 |
8.0.0-pre.18 | 71 | 10/9/2023 |
8.0.0-pre.17 | 75 | 10/7/2023 |
8.0.0-pre.16 | 72 | 10/6/2023 |
8.0.0-pre.15 | 73 | 10/6/2023 |
8.0.0-pre.14 | 72 | 10/5/2023 |
8.0.0-pre.13 | 62 | 10/5/2023 |
8.0.0-pre.12 | 66 | 10/4/2023 |
8.0.0-pre.11 | 65 | 10/3/2023 |
8.0.0-pre.10 | 73 | 10/3/2023 |
8.0.0-pre.9 | 76 | 10/3/2023 |
8.0.0-pre.8 | 72 | 10/2/2023 |
8.0.0-pre.7 | 70 | 10/2/2023 |
8.0.0-pre.6 | 78 | 9/29/2023 |
8.0.0-pre.5 | 73 | 9/28/2023 |
8.0.0-pre.4 | 69 | 9/28/2023 |
8.0.0-pre.3 | 68 | 9/27/2023 |
8.0.0-pre.2 | 52 | 9/26/2023 |
8.0.0-pre.1 | 71 | 9/22/2023 |
'# [8.0.0-pre.20](https://github.com/buehler/dotnet-operator-sdk/compare/v8.0.0-pre.19...v8.0.0-pre.20) (2023-10-11)
### Features
* **web-operator:** Add validation webhooks. ([#631](https://github.com/buehler/dotnet-operator-sdk/issues/631)) ([31b2ab0](https://github.com/buehler/dotnet-operator-sdk/commit/31b2ab04910be33896675c540a53a5b4f131495b))
### BREAKING CHANGES
* **web-operator:** This overhauls the way
webhooks worked. Webhooks now run
with normal ASP.net ApiControllers.
To use a webhook, refer to the documentation.
Basically, create a subclass of the validation
webhook class and decorate it with the
correct validation attribute. Then, the
webhook will run. Other elements
like automatic install will follow this
preview release.
'