SimpleK8sWatch 0.0.3

dotnet add package SimpleK8sWatch --version 0.0.3
                    
NuGet\Install-Package SimpleK8sWatch -Version 0.0.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SimpleK8sWatch" Version="0.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SimpleK8sWatch" Version="0.0.3" />
                    
Directory.Packages.props
<PackageReference Include="SimpleK8sWatch" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SimpleK8sWatch --version 0.0.3
                    
#r "nuget: SimpleK8sWatch, 0.0.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SimpleK8sWatch@0.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SimpleK8sWatch&version=0.0.3
                    
Install as a Cake Addin
#tool nuget:?package=SimpleK8sWatch&version=0.0.3
                    
Install as a Cake Tool

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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