CommunityCodierung & Entwicklunggithub.com

akka-net-management

Akka.Management für Cluster-Bootstrap, Service-Discovery (Kubernetes, Azure, Config), Health Checks und dynamische Cluster-Bildung ohne statische Seed-Knoten.

Was ist akka-net-management?

Dieses Skill beschreibt die Verwendung von Akka.Management und Akka.Cluster.Bootstrap zur dynamischen Cluster-Bildung in Akka.NET. Es ersetzt statische Seed-Knoten durch Service Discovery, was besonders in Kubernetes- und Cloud-Umgebungen mit Auto-Scaling nützlich ist. Das Skill unterstützt mehrere Discovery-Provider: Kubernetes API, Azure Table Storage und HOCON-basierte Konfiguration. Es behandelt die Architektur, NuGet-Pakete, Akka.Hosting-Konfiguration, Health-Endpunkte und Fehlerbehebung. Zusätzlich wird die Integration mit .NET Aspire gezeigt. Entwickler können mit diesem Skill Produktionscluster aufbauen, die automatisch Knoten finden und sich bei Skalierung oder Ausfällen selbst heilen.

Funktioniert mit~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Aaronontheweb/dotnet-skills/tree/main/skills/akka-management

Installed? Explore more Codierung & Entwicklung skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

In Ihrer bevorzugten KI fragen

Öffnet einen neuen Chat, in dem dieser Agent-Skill bereits geladen ist.

Dokumentation

Akka.NET Verwaltung und Service Discovery

Wann dieses Skill verwenden

Verwenden Sie dieses Skill, wenn:

  • Akka.NET Cluster in Kubernetes oder Cloud-Umgebungen bereitgestellt werden
  • Statische Seed-Knoten durch dynamische Service Discovery ersetzt werden sollen
  • Cluster Bootstrap für automatische Formation konfiguriert wird
  • Health-Endpunkte für Load Balancer eingerichtet werden
  • Eine Integration mit Azure Table Storage, Kubernetes API oder konfigurationsbasierter Discovery erforderlich ist

Referenzdateien

Überblick

Akka.Management stellt HTTP-Endpunkte für die Clusterverwaltung bereit und integriert sich mit Akka.Cluster.Bootstrap, um eine dynamische Clusterbildung mittels Service Discovery anstelle statischer Seed-Knoten zu ermöglichen.

Warum Akka.Management verwenden?

AnsatzVorteileNachteile
Statische Seed-KnotenEinfach, keine AbhängigkeitenSkaliert nicht, erfordert bekannte IPs
Akka.ManagementDynamische Discovery, skaliert auf N KnotenMehr Konfiguration, externe Abhängigkeiten

Statische Seed-Knoten verwenden für: Entwicklung, Einzelknoten-Bereitstellungen, feste Infrastruktur.

Akka.Management verwenden für: Kubernetes, Auto-Scaling-Gruppen, dynamische Umgebungen, Produktionscluster.


Architektur

┌─────────────────────────────────────────────────────────────┐
│                    Cluster Bootstrap                         │
│  ┌─────────────┐    ┌─────────────┐    ┌─────────────┐     │
│  │  Knoten 1   │    │  Knoten 2   │    │  Knoten 3   │     │
│  │             │    │             │    │             │     │
│  │ Management  │◄──►│ Management  │◄──►│ Management  │     │
│  │ HTTP :8558  │    │ HTTP :8558  │    │ HTTP :8558  │     │
│  └──────┬──────┘    └──────┬──────┘    └──────┬──────┘     │
│         │                  │                  │             │
│         └──────────────────┼──────────────────┘             │
│                            │                                │
│                    ┌───────▼───────┐                        │
│                    │   Discovery   │                        │
│                    │   Provider    │                        │
│                    └───────────────┘                        │
│                            │                                │
└────────────────────────────┼────────────────────────────────┘
                             │
              ┌──────────────┼──────────────┐
              │              │              │
        ┌─────▼─────┐ ┌──────▼─────┐ ┌─────▼──────┐
        │ Kubernetes│ │   Azure    │ │   Config   │
        │    API    │ │   Tables   │ │   (HOCON)  │
        └───────────┘ └────────────┘ └────────────┘

Erforderliche NuGet-Pakete

<ItemGroup>
  <!-- Kernverwaltung -->
  <PackageReference Include="Akka.Management" />
  <PackageReference Include="Akka.Management.Cluster.Bootstrap" />

  <!-- Wählen Sie EINEN Discovery-Provider -->
  <PackageReference Include="Akka.Discovery.KubernetesApi" />    <!-- Für Kubernetes -->
  <PackageReference Include="Akka.Discovery.Azure" />            <!-- Für Azure -->
  <PackageReference Include="Akka.Discovery.Config.Hosting" />   <!-- Für statische Konfiguration -->
</ItemGroup>

Akka.Hosting Konfiguration

Grundlegende Einrichtung mit Modusauswahl

public static class AkkaConfiguration
{
    public static IServiceCollection ConfigureAkka(
        this IServiceCollection services,
        Action<AkkaConfigurationBuilder, IServiceProvider>? additionalConfig = null)
    {
        services.AddOptions<AkkaSettings>()
            .BindConfiguration("AkkaSettings")
            .ValidateDataAnnotations()
            .ValidateOnStart();

        return services.AddAkka("MySystem", (builder, sp) =>
        {
            var settings = sp.GetRequiredService<IOptions<AkkaSettings>>().Value;
            var configuration = sp.GetRequiredService<IConfiguration>();

            ConfigureNetwork(builder, settings, configuration);
            ConfigureHealthChecks(builder);

            additionalConfig?.Invoke(builder, sp);
        });
    }

    private static void ConfigureNetwork(
        AkkaConfigurationBuilder builder,
        AkkaSettings settings,
        IConfiguration configuration)
    {
        if (settings.ExecutionMode == AkkaExecutionMode.LocalTest)
            return;

        builder.WithRemoting(settings.RemoteOptions);

        if (settings.ClusterBootstrapOptions.Enabled)
            ConfigureAkkaManagement(builder, settings, configuration);
        else
            builder.WithClustering(settings.ClusterOptions);
    }
}

Akka.Management Konfiguration

private static void ConfigureAkkaManagement(
    AkkaConfigurationBuilder builder,
    AkkaSettings settings,
    IConfiguration configuration)
{
    var mgmtOptions = settings.AkkaManagementOptions;
    var bootstrapOptions = settings.ClusterBootstrapOptions;

    // WICHTIG: Seed-Knoten löschen, wenn Akka.Management verwendet wird
    settings.ClusterOptions.SeedNodes = [];

    builder
        .WithClustering(settings.ClusterOptions)
        .WithAkkaManagement(setup =>
        {
            setup.Http.HostName = mgmtOptions.HostName;
            setup.Http.Port = mgmtOptions.Port;
            setup.Http.BindHostName = "0.0.0.0";
            setup.Http.BindPort = mgmtOptions.Port;
        })
        .WithClusterBootstrap(options =>
        {
            options.ContactPointDiscovery.ServiceName = bootstrapOptions.ServiceName;
            options.ContactPointDiscovery.PortName = bootstrapOptions.PortName;
            options.ContactPointDiscovery.RequiredContactPointsNr = bootstrapOptions.RequiredContactPointsNr;
            options.ContactPointDiscovery.Interval = bootstrapOptions.ContactPointProbingInterval;
            options.ContactPointDiscovery.StableMargin = bootstrapOptions.StableMargin;
            options.ContactPointDiscovery.ContactWithAllContactPoints = bootstrapOptions.ContactWithAllContactPoints;
            options.ContactPoint.FilterOnFallbackPort = bootstrapOptions.FilterOnFallbackPort;
            options.ContactPoint.ProbeInterval = bootstrapOptions.BootstrapperDiscoveryPingInterval;
        });

    // Den Discovery-Provider konfigurieren
    ConfigureDiscovery(builder, settings, configuration);
}

Siehe discovery-providers.md für vollständigen Konfigurations-, Kubernetes- und Azure-Discovery-Einrichtungscode.

Siehe configuration-reference.md für die vollständigen stark typisierten Konfigurationsmodellklassen.


Health-Endpunkte

Akka.Management stellt Health-Endpunkte für Load Balancer und Orchestratoren bereit:

EndpunktZweckGibt 200 zurück wenn
/aliveLebendigkeitActorSystem läuft
/readyBereitschaftCluster-Mitglied ist Up
/cluster/membersDebugGibt Cluster-Mitgliedschaft zurück

ASP.NET Core Health Check Integration

// Akka Health Checks registrieren
builder.Services.AddHealthChecks();

// In der Akka-Konfiguration
builder
    .WithActorSystemLivenessCheck()     // Fügt „akka-liveness" Health Check hinzu
    .WithAkkaClusterReadinessCheck();   // Fügt „akka-cluster-readiness" Health Check hinzu

// Endpunkte definieren
app.MapHealthChecks("/health/live", new HealthCheckOptions
{
    Predicate = check => check.Tags.Contains("liveness")
});

app.MapHealthChecks("/health/ready", new HealthCheckOptions
{
    Predicate = check => check.Tags.Contains("readiness")
});

Fehlerbehebung

Cluster bildet sich nicht

Symptome: Knoten bleiben als separate Einzelknoten-Cluster.

Checkliste:

  1. Alle Knoten verwenden denselben ServiceName
  2. RequiredContactPointsNr entspricht der tatsächlichen Replikatanzahl
  3. Discovery-Provider ist korrekt konfiguriert
  4. Netzwerk erlaubt Verkehr auf dem Verwaltungsport (8558)
  5. Für Kubernetes: RBAC-Berechtigungen sind gesetzt

Split Brain

Symptome: Es bilden sich mehrere Cluster anstelle eines einzigen.

Lösungen:

  1. Setzen Sie ContactWithAllContactPoints = true
  2. Erhöhen Sie StableMargin für langsamere Umgebungen
  3. Für Aspire: Setzen Sie FilterOnFallbackPort = false (dynamische Ports)
  4. Für Kubernetes: Setzen Sie FilterOnFallbackPort = true (feste Ports)

Azure Discovery Probleme

Symptome: Knoten können einander nicht über Azure Tables finden.

Checkliste:

  1. Verbindungszeichenfolge ist gültig
  2. Storage-Konto erlaubt Tabellenoperationen
  3. Alle Knoten verwenden denselben ServiceName
  4. Firewall erlaubt Zugriff auf Azure Storage

Aspire Integration

Ausführliche Aspire-spezifische Muster finden Sie im Skill akka-net-aspire-configuration.

Kurzreferenz für Aspire:

// In AppHost
appBuilder
    .WithEndpoint(name: "remote", protocol: ProtocolType.Tcp,
        env: "AkkaSettings__RemoteOptions__Port")
    .WithEndpoint(name: "management", protocol: ProtocolType.Tcp,
        env: "AkkaSettings__AkkaManagementOptions__Port")
    .WithEnvironment("AkkaSettings__ClusterBootstrapOptions__Enabled", "true")
    .WithEnvironment("AkkaSettings__ClusterBootstrapOptions__DiscoveryMethod", "AzureTableStorage")
    .WithEnvironment("AkkaSettings__ClusterBootstrapOptions__FilterOnFallbackPort", "false");

Zusammenfassung: Wann was verwenden

SzenarioDiscovery-MethodeFilterOnFallbackPort
Lokale Entwicklung (einzelner Knoten)Keine (Seed-Knoten verwenden)N/A
Aspire Multi-KnotenAzureTableStoragefalse
KubernetesKubernetestrue
Azure VMs/VMSSAzureTableStoragetrue
Feste InfrastrukturConfigtrue
AWS ECS/EC2AWS Discovery-Pluginstrue

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

akka-hosting-actor-patterns

Patterns for building entity actors with Akka.Hosting - GenericChildPerEntityParent, message extractors, cluster sharding abstraction, akka-reminders, and ITimeProvider. Supports both local testing and clustered production modes.

akka-net-aspire-configuration

Configure Akka.NET with .NET Aspire for local development and production deployments. Covers actor system setup, clustering, persistence, Akka.Management integration, and Aspire orchestration patterns.

akka-net-best-practices

Critical Akka.NET best practices including EventStream vs DistributedPubSub, supervision strategies, error handling, Props vs DependencyResolver, work distribution patterns, and cluster/local mode abstractions for testability.

akka-net-testing-patterns

Write unit and integration tests for Akka.NET actors using modern Akka.Hosting.TestKit patterns. Covers dependency injection, TestProbes, persistence testing, and actor interaction verification. Includes guidance on when to use traditional TestKit.

api-design

Design stable, compatible public APIs using extend-only design principles. Manage API compatibility, wire compatibility, and versioning for NuGet packages and distributed systems.

aspire-configuration

Configure Aspire AppHost to emit explicit app config via environment variables; keep app code free of Aspire clients and service discovery.

aspire-integration-testing

Write integration tests using .NET Aspire

aspire-service-defaults

Create a shared ServiceDefaults project for Aspire applications. Centralizes OpenTelemetry, health checks, resilience, and service discovery configuration across all services.

crap-analysis

Analyze code coverage and CRAP (Change Risk Anti-Patterns) scores to identify high-risk code. Use OpenCover format with ReportGenerator for Risk Hotspots showing cyclomatic complexity and untested code paths.

csharp-concurrency-patterns

Choosing the right concurrency abstraction in .NET - from async/await for I/O to Channels for producer/consumer to Akka.NET for stateful entity management. Avoid locks and manual synchronization unless absolutely necessary.

database-performance

Database access patterns for performance. Separate read/write models, avoid N+1 queries, use AsNoTracking, apply row limits, and never do application-side joins. Works with EF Core and Dapper.

dependency-injection-patterns

Organize DI registrations using IServiceCollection extension methods. Group related services into composable Add* methods for clean Program.cs and reusable configuration in tests.

dotnet-devcert-trust

Diagnose and fix .NET HTTPS dev certificate trust issues on Linux. Covers the full certificate lifecycle from generation to system CA bundle inclusion, with distro-specific guidance for Ubuntu, Fedora, Arch, and WSL2.

dotnet-local-tools

Managing local .NET tools with dotnet-tools.json for consistent tooling across development environments and CI/CD pipelines.

dotnet-project-structure

Modern .NET project structure including .slnx solution format, Directory.Build.props, central package management, SourceLink, version management with RELEASE_NOTES.md, and SDK pinning with global.json.

dotnet-slopwatch

Use Slopwatch to detect LLM reward hacking in .NET code changes. Run after every code modification to catch disabled tests, suppressed warnings, empty catch blocks, and other shortcuts that mask real problems.

efcore-patterns

Entity Framework Core best practices including NoTracking by default, query splitting for navigation collections, migration management, dedicated migration services, and common pitfalls to avoid.

ilspy-decompile

Understand implementation details of .NET code by decompiling assemblies. Use when you want to see how a .NET API works internally, inspect NuGet package source, view framework implementation, or understand compiled .NET binaries.

mailpit-integration

Test email sending locally using Mailpit with .NET Aspire. Captures all outgoing emails without sending them. View rendered HTML, inspect headers, and verify delivery in integration tests.

marketplace-publishing

Workflow for publishing skills and agents to the dotnet-skills Claude Code marketplace. Covers adding new content, updating plugin.json, validation, and release tagging.

Verwandte Skills