Muonroi.Kubernetes 2.0.2

dotnet add package Muonroi.Kubernetes --version 2.0.2
                    
NuGet\Install-Package Muonroi.Kubernetes -Version 2.0.2
                    
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="Muonroi.Kubernetes" Version="2.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Muonroi.Kubernetes" Version="2.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Muonroi.Kubernetes" />
                    
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 Muonroi.Kubernetes --version 2.0.2
                    
#r "nuget: Muonroi.Kubernetes, 2.0.2"
                    
#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 Muonroi.Kubernetes@2.0.2
                    
#: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=Muonroi.Kubernetes&version=2.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Muonroi.Kubernetes&version=2.0.2
                    
Install as a Cake Tool

Muonroi.Kubernetes

Kubernetes runtime configurations and environment utilities for the Muonroi ecosystem.

NuGet License

Overview

Muonroi.Kubernetes provides foundational configuration primitives for Muonroi Building Block applications running within Kubernetes environments. It is designed to act as a central source of truth for runtime orchestration parameters, allowing services to adapt their behaviors based on the specific flavor or configuration of the Kubernetes cluster they are deployed to.

While currently lightweight, this package establishes the configuration contracts (KubernetesConfigs and KubernetesClusterType) necessary for downstream integrations—such as dynamic service discovery, Kubernetes-native leader election, and automated health check bindings.

Features

  • Standardized Configuration Section: Exposes KubernetesConfigs which binds directly to the standard KubernetesConfigs section in appsettings.json.
  • Cluster Type Awareness: Includes the KubernetesClusterType enumeration to differentiate between standard Upstream Kubernetes (K8S), lightweight Edge Kubernetes (K3S), and managed Amazon EKS (Eks), enabling environment-specific optimizations.

Installation

dotnet add package Muonroi.Kubernetes

Quick Start

1. Configuration Setup

Add the configuration section to your appsettings.json or environment variables:

{
  "KubernetesConfigs": {
    "ClusterType": "Eks",
    "ClusterEndpoint": "https://<eks-id>.gr7.us-east-1.eks.amazonaws.com"
  }
}

Or via environment variables: KubernetesConfigs__ClusterType=K3S

2. Binding Configuration

Bind the configuration model during your application startup:

using Muonroi.Kubernetes.Kubernetes;

var builder = WebApplication.CreateBuilder(args);

// Bind the configuration to the DI container via IOptions
builder.Services.Configure<KubernetesConfigs>(
    builder.Configuration.GetSection(KubernetesConfigs.SectionName));

3. Usage

Inject IOptions<KubernetesConfigs> into your services to adapt logic based on the cluster type.

using Microsoft.Extensions.Options;
using Muonroi.Kubernetes.Kubernetes;

public class ClusterAwareMetricsPublisher
{
    private readonly KubernetesConfigs _k8sConfigs;

    public ClusterAwareMetricsPublisher(IOptions<KubernetesConfigs> options)
    {
        _k8sConfigs = options.Value;
    }

    public async Task PublishMetricsAsync()
    {
        if (_k8sConfigs.ClusterType == KubernetesClusterType.Eks)
        {
            // Publish to AWS CloudWatch via IAM Roles for Service Accounts (IRSA)
            await PublishToCloudWatchAsync();
        }
        else
        {
            // Fallback to standard Prometheus scraping format
            ExposePrometheusEndpoint();
        }
    }
    
    private Task PublishToCloudWatchAsync() => Task.CompletedTask;
    private void ExposePrometheusEndpoint() { }
}

API Reference

KubernetesConfigs

The central configuration record for Kubernetes-specific settings.

  • SectionName: Constant "KubernetesConfigs" used for configuration binding.
  • ClusterType: Enum indicating the distribution of Kubernetes (KubernetesClusterType). Defaults to K8S.
  • ClusterEndpoint: Optional API server endpoint URL string.

KubernetesClusterType

Enum defining supported Kubernetes distributions:

  • K8S: Standard upstream Kubernetes (Default).
  • K3S: Lightweight Kubernetes distribution (e.g., for edge or local environments).
  • Eks: Amazon Elastic Kubernetes Service.

Ecosystem Combinations

Works great standalone. Becomes significantly more powerful when combined.

+ ServiceDiscovery.Consul → K8s cluster type drives which discovery backend is active

Switch between native K8s DNS and Consul depending on the environment.

+ Http → HttpClient service discovery resolves addresses from K8s DNS

Extend HTTP clients to resolve http://my-service directly to K8s service boundaries.

+ Resilience → K8s pod restarts trigger circuit-breaker half-open retry automatically

Tune Polly resilience strategies based on known Kubernetes deployment and rollout behavior.

+ Observability → K8s pod/namespace metadata added to all OTel resource attributes

Enrich your telemetry spans with k8s.pod.name and k8s.namespace.name automatically.

+ Secrets → KubernetesSecretProvider reads from mounted K8s secret volumes

Read infrastructure secrets directly from /etc/secrets rather than environment variables.

Full Stack

csharp // combined registration builder.Services.Configure<KubernetesConfigs>(builder.Configuration.GetSection(KubernetesConfigs.SectionName)); builder.Services.AddServiceDiscovery(); builder.Services.AddMuonroiObservability(options => options.EnrichWithKubernetes());

Samples

  • samples/KubernetesDeployment/
  • samples/ServiceDiscovery/

License

Apache 2.0 — see LICENSE-APACHE.

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

    • No dependencies.

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
2.0.2 108 8/26/2026
2.0.1 105 8/26/2026
2.0.0 111 8/14/2026