GossNet.Discovery.Kubernetes
0.3.0
See the version list below for details.
dotnet add package GossNet.Discovery.Kubernetes --version 0.3.0
NuGet\Install-Package GossNet.Discovery.Kubernetes -Version 0.3.0
<PackageReference Include="GossNet.Discovery.Kubernetes" Version="0.3.0" />
<PackageVersion Include="GossNet.Discovery.Kubernetes" Version="0.3.0" />
<PackageReference Include="GossNet.Discovery.Kubernetes" />
paket add GossNet.Discovery.Kubernetes --version 0.3.0
#r "nuget: GossNet.Discovery.Kubernetes, 0.3.0"
#:package GossNet.Discovery.Kubernetes@0.3.0
#addin nuget:?package=GossNet.Discovery.Kubernetes&version=0.3.0
#tool nuget:?package=GossNet.Discovery.Kubernetes&version=0.3.0
GossNet.Discovery.Kubernetes
Kubernetes-based node discovery for GossNet.Protocol.
Ships separately so the Kubernetes client dependency stays out of the core package.
This is not merely a preference: KubernetesClient publishes no netstandard2.0
asset, so folding it into GossNet.Protocol would force every consumer of the core
package off netstandard2.0.
Target frameworks: net8.0, net10.0.
Installation
dotnet add package GossNet.Discovery.Kubernetes
Usage
Give each gossip pod a shared label and expose its own IP through the downward API:
env:
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
using GossNet.Discovery.Kubernetes;
using GossNet.Protocol;
var k8sOptions = new KubernetesDiscoveryOptions
{
LabelSelector = "app=gossnet",
ReadyOnly = true
};
var configuration = new GossNetConfiguration
{
// The address peers reach this node on, so it can exclude itself.
Hostname = Environment.GetEnvironmentVariable("POD_IP")!,
Port = 9055,
DiscoveryProviderFactory = cfg => new KubernetesNodeDiscovery(cfg, k8sOptions)
};
using var node = new GossNetNode<MyMessage>(configuration);
node.Start();
DiscoveryProviderFactory is used rather than DiscoveryProvider because the provider
needs the node's own address and port to exclude itself — the pod running the node
matches its own label selector.
Options
| Option | Default | Description |
|---|---|---|
LabelSelector |
required | Selector identifying the gossip pods |
Namespace |
the pod's own | Namespace to search |
Port |
the node's own port | Port neighbours listen on |
FieldSelector |
none | Extra field selector |
ReadyOnly |
true |
Only return pods that are Running and Ready |
KubeConfigPath |
none | Explicit kubeconfig; otherwise in-cluster config with kubeconfig fallback |
CacheDuration |
30 seconds | How long a resolved neighbour list is reused |
Pods without an assigned IP are skipped. If the API server cannot be reached, a
NodeDiscoveryException is thrown rather than returning an empty neighbour list.
RBAC
The service account needs permission to list pods in the namespace:
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: gossnet-discovery
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["list"]
License
MIT. See LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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 is compatible. 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. |
-
net10.0
- GossNet.Protocol (>= 0.3.0)
- KubernetesClient (>= 19.0.2)
-
net8.0
- GossNet.Protocol (>= 0.3.0)
- KubernetesClient (>= 19.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.