diff --git a/src/CAVerifierServer.Silo/Extensions/OrleansHostExtensions.cs b/src/CAVerifierServer.Silo/Extensions/OrleansHostExtensions.cs index 26b0eff..645fcae 100644 --- a/src/CAVerifierServer.Silo/Extensions/OrleansHostExtensions.cs +++ b/src/CAVerifierServer.Silo/Extensions/OrleansHostExtensions.cs @@ -24,9 +24,18 @@ public static IHostBuilder UseOrleans(this IHostBuilder hostBuilder) throw new ArgumentNullException(nameof(configSection), "The OrleansServer node is missing"); return hostBuilder.UseOrleans(siloBuilder => { + var isRunningInKubernetes = configSection.GetValue("isRunningInKubernetes"); + var advertisedIP = isRunningInKubernetes ? Environment.GetEnvironmentVariable("POD_IP") :configSection.GetValue("AdvertisedIP"); + var clusterId = isRunningInKubernetes ? Environment.GetEnvironmentVariable("ORLEANS_CLUSTER_ID") : configSection.GetValue("ClusterId"); + var serviceId = isRunningInKubernetes ? Environment.GetEnvironmentVariable("ORLEANS_SERVICE_ID") : configSection.GetValue("ServiceId"); + //Configure OrleansSnapshot siloBuilder - .ConfigureEndpoints(advertisedIP:IPAddress.Parse(configSection.GetValue("AdvertisedIP")),siloPort: configSection.GetValue("SiloPort"), gatewayPort: configSection.GetValue("GatewayPort"), listenOnAnyHostAddress: true) + //.ConfigureEndpoints(advertisedIP:IPAddress.Parse(configSection.GetValue("AdvertisedIP")),siloPort: configSection.GetValue("SiloPort"), gatewayPort: configSection.GetValue("GatewayPort"), listenOnAnyHostAddress: true) + .ConfigureEndpoints(advertisedIP: IPAddress.Parse(advertisedIP), + siloPort: configSection.GetValue("SiloPort"), + gatewayPort: configSection.GetValue("GatewayPort"), listenOnAnyHostAddress: true) + .UseMongoDBClient(configSection.GetValue("MongoDBClient")) .UseMongoDBClustering(options => { @@ -54,8 +63,8 @@ public static IHostBuilder UseOrleans(this IHostBuilder hostBuilder) }) .Configure(options => { - options.ClusterId = configSection.GetValue("ClusterId"); - options.ServiceId = configSection.GetValue("ServiceId"); + options.ClusterId = clusterId; + options.ServiceId = serviceId; }) // .AddMemoryGrainStorage("PubSubStore") .ConfigureApplicationParts(parts => parts.AddFromApplicationBaseDirectory())