$npx -y skills add Aaronontheweb/dotnet-skills --skill akka-managementAkka.Management for cluster bootstrapping, service discovery (Kubernetes, Azure, Config), health checks, and dynamic cluster formation without static seed nodes.
| 1 | # Akka.NET Management and Service Discovery |
| 2 | |
| 3 | ## When to Use This Skill |
| 4 | |
| 5 | Use this skill when: |
| 6 | - Deploying Akka.NET clusters to Kubernetes or cloud environments |
| 7 | - Replacing static seed nodes with dynamic service discovery |
| 8 | - Configuring cluster bootstrap for auto-formation |
| 9 | - Setting up health endpoints for load balancers |
| 10 | - Integrating with Azure Table Storage, Kubernetes API, or config-based discovery |
| 11 | |
| 12 | ## Reference Files |
| 13 | |
| 14 | - [discovery-providers.md](discovery-providers.md): Config, Kubernetes, and Azure discovery setup with full code and deployment YAML |
| 15 | - [configuration-reference.md](configuration-reference.md): Strongly-typed configuration model classes |
| 16 | |
| 17 | ## Overview |
| 18 | |
| 19 | **Akka.Management** provides HTTP endpoints for cluster management and integrates with **Akka.Cluster.Bootstrap** to enable dynamic cluster formation using service discovery instead of static seed nodes. |
| 20 | |
| 21 | ### Why Use Akka.Management? |
| 22 | |
| 23 | | Approach | Pros | Cons | |
| 24 | |----------|------|------| |
| 25 | | Static Seed Nodes | Simple, no dependencies | Doesn't scale, requires known IPs | |
| 26 | | Akka.Management | Dynamic discovery, scales to N nodes | More configuration, external dependencies | |
| 27 | |
| 28 | **Use static seed nodes** for: Development, single-node deployments, fixed infrastructure. |
| 29 | |
| 30 | **Use Akka.Management** for: Kubernetes, auto-scaling groups, dynamic environments, production clusters. |
| 31 | |
| 32 | --- |
| 33 | |
| 34 | ## Architecture |
| 35 | |
| 36 | ``` |
| 37 | ┌─────────────────────────────────────────────────────────────┐ |
| 38 | │ Cluster Bootstrap │ |
| 39 | │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ |
| 40 | │ │ Node 1 │ │ Node 2 │ │ Node 3 │ │ |
| 41 | │ │ │ │ │ │ │ │ |
| 42 | │ │ Management │◄──►│ Management │◄──►│ Management │ │ |
| 43 | │ │ HTTP :8558 │ │ HTTP :8558 │ │ HTTP :8558 │ │ |
| 44 | │ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ │ |
| 45 | │ │ │ │ │ |
| 46 | │ └──────────────────┼──────────────────┘ │ |
| 47 | │ │ │ |
| 48 | │ ┌───────▼───────┐ │ |
| 49 | │ │ Discovery │ │ |
| 50 | │ │ Provider │ │ |
| 51 | │ └───────────────┘ │ |
| 52 | │ │ │ |
| 53 | └────────────────────────────┼────────────────────────────────┘ |
| 54 | │ |
| 55 | ┌──────────────┼──────────────┐ |
| 56 | │ │ │ |
| 57 | ┌─────▼─────┐ ┌──────▼─────┐ ┌─────▼──────┐ |
| 58 | │ Kubernetes│ │ Azure │ │ Config │ |
| 59 | │ API │ │ Tables │ │ (HOCON) │ |
| 60 | └───────────┘ └────────────┘ └────────────┘ |
| 61 | ``` |
| 62 | |
| 63 | --- |
| 64 | |
| 65 | ## Required NuGet Packages |
| 66 | |
| 67 | ```xml |
| 68 | <ItemGroup> |
| 69 | <!-- Core management --> |
| 70 | <PackageReference Include="Akka.Management" /> |
| 71 | <PackageReference Include="Akka.Management.Cluster.Bootstrap" /> |
| 72 | |
| 73 | <!-- Choose ONE discovery provider --> |
| 74 | <PackageReference Include="Akka.Discovery.KubernetesApi" /> <!-- For Kubernetes --> |
| 75 | <PackageReference Include="Akka.Discovery.Azure" /> <!-- For Azure --> |
| 76 | <PackageReference Include="Akka.Discovery.Config.Hosting" /> <!-- For static config --> |
| 77 | </ItemGroup> |
| 78 | ``` |
| 79 | |
| 80 | --- |
| 81 | |
| 82 | ## Akka.Hosting Configuration |
| 83 | |
| 84 | ### Basic Setup with Mode Selection |
| 85 | |
| 86 | ```csharp |
| 87 | public static class AkkaConfiguration |
| 88 | { |
| 89 | public static IServiceCollection ConfigureAkka( |
| 90 | this IServiceCollection services, |
| 91 | Action<AkkaConfigurationBuilder, IServiceProvider>? additionalConfig = null) |
| 92 | { |
| 93 | services.AddOptions<AkkaSettings>() |
| 94 | .BindConfiguration("AkkaSettings") |
| 95 | .ValidateDataAnnotations() |
| 96 | .ValidateOnStart(); |
| 97 | |
| 98 | return services.AddAkka("MySystem", (builder, sp) => |
| 99 | { |
| 100 | var settings = sp.GetRequiredService<IOptions<AkkaSettings>>().Value; |
| 101 | var configuration = sp.GetRequiredService<IConfiguration>(); |
| 102 | |
| 103 | ConfigureNetwork(builder, settings, configuration); |
| 104 | ConfigureHealthChecks(builder); |
| 105 | |
| 106 | additionalConfig?.Invoke(builder, sp); |
| 107 | }); |
| 108 | } |
| 109 | |
| 110 | private static void ConfigureNetwork( |
| 111 | AkkaConfigurationBuilder builder, |
| 112 | AkkaSettings settings, |
| 113 | IConfiguration configuration) |
| 114 | { |
| 115 | if (settings.ExecutionMode == AkkaExecutionMode.LocalTest) |
| 116 | return; |
| 117 | |
| 118 | builder.WithRemoting(settings.RemoteOptions); |
| 119 | |
| 120 | if (settings.ClusterBootstrapOptions.Enabled) |
| 121 | ConfigureAkkaManagement(builder, settings, configuration); |
| 122 | else |
| 123 | builder.WithClustering(settings.ClusterOptions); |
| 124 | } |
| 125 | } |
| 126 | ``` |
| 127 | |
| 128 | ### Akka.Management Configuration |
| 129 | |
| 130 | ```csharp |
| 131 | private static void Conf |