SimpleK8sWatch 0.0.3
dotnet add package SimpleK8sWatch --version 0.0.3
NuGet\Install-Package SimpleK8sWatch -Version 0.0.3
<PackageReference Include="SimpleK8sWatch" Version="0.0.3" />
<PackageVersion Include="SimpleK8sWatch" Version="0.0.3" />
<PackageReference Include="SimpleK8sWatch" />
paket add SimpleK8sWatch --version 0.0.3
#r "nuget: SimpleK8sWatch, 0.0.3"
#:package SimpleK8sWatch@0.0.3
#addin nuget:?package=SimpleK8sWatch&version=0.0.3
#tool nuget:?package=SimpleK8sWatch&version=0.0.3
SimpleK8sWatch
.NET standard 2.1 (C#) providing an easy to use watcher for kubernetes events.
Why
Because I don't like the approach of handling kubernetes watches in the official kubernetes client library for c# (https://github.com/kubernetes-client/csharp).
What
Just a rather simple wrapper around a kubernetes watch with the following features:
- Keeps an always-up-to-date cache of all entities received by a watcher. Cache can be retrieved synchronously without any delay and without accesses to the kubernetes API.
- Automatically attempts reconnect (every 10 seconds) when connection is lost
- Compares entities on event retrieval, only triggers a c# event if the entity really changed.
- Dependency injection friendly
How
See SimpleK8sWatchExamples/Program.cs for a minimal example. Basically, you get a typed watcher
new WatchedResource<V1ConfigMap, V1ConfigMapList>, you need to pass the requested entity type and the kubernetes type of a list of the same entities.
In the constructor, you need to pass a method from the kubernetes library that is used to initialize a watch to this entity type: (doWatch, limit) => k8S.ListNamespacedConfigMapWithHttpMessagesAsync(ns, watch: doWatch, limit: limit), logger)
SimpleK8sWatch will call this method in different ways, therefore you need to let SimpleK8sWatch know how to pass the required parameters (doWatch and limit).
You need a fully working "Kubernetes" object. How to properly initialize this object is different for a lot of kubernetes providers, but usually rather easy to find out. The example code contains the most simple approach by just using the credentials from your local ".kube/config"-file.
Who
Tobias Braun, tobi.braun (at) gmail (dot) com
What else
I've created this library for my personal use. Feel free to use it as you like, but don't take me responsible if it isn't doing what you expected...
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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 was computed. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- KubernetesClient (>= 7.0.8)
- Microsoft.Extensions.Configuration.Binder (>= 6.0.0)
- Microsoft.Extensions.Logging.Console (>= 6.0.0)
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 |
|---|---|---|
| 0.0.3 | 675 | 1/29/2022 |