Skip to content

Commit

Permalink
add config for k8s
Browse files Browse the repository at this point in the history
  • Loading branch information
sunny-k123 committed Nov 21, 2024
1 parent f1738a6 commit 0573e8f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/CAVerifierServer.Silo/Extensions/OrleansHostExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>("isRunningInKubernetes");
var advertisedIP = isRunningInKubernetes ? Environment.GetEnvironmentVariable("POD_IP") :configSection.GetValue<string>("AdvertisedIP");
var clusterId = isRunningInKubernetes ? Environment.GetEnvironmentVariable("ORLEANS_CLUSTER_ID") : configSection.GetValue<string>("ClusterId");
var serviceId = isRunningInKubernetes ? Environment.GetEnvironmentVariable("ORLEANS_SERVICE_ID") : configSection.GetValue<string>("ServiceId");

//Configure OrleansSnapshot
siloBuilder
.ConfigureEndpoints(advertisedIP:IPAddress.Parse(configSection.GetValue<string>("AdvertisedIP")),siloPort: configSection.GetValue<int>("SiloPort"), gatewayPort: configSection.GetValue<int>("GatewayPort"), listenOnAnyHostAddress: true)
//.ConfigureEndpoints(advertisedIP:IPAddress.Parse(configSection.GetValue<string>("AdvertisedIP")),siloPort: configSection.GetValue<int>("SiloPort"), gatewayPort: configSection.GetValue<int>("GatewayPort"), listenOnAnyHostAddress: true)
.ConfigureEndpoints(advertisedIP: IPAddress.Parse(advertisedIP),

Check warning on line 35 in src/CAVerifierServer.Silo/Extensions/OrleansHostExtensions.cs

View workflow job for this annotation

GitHub Actions / publish (CAVerifierServer.Silo)

Possible null reference argument for parameter 'ipString' in 'IPAddress IPAddress.Parse(string ipString)'.
siloPort: configSection.GetValue<int>("SiloPort"),
gatewayPort: configSection.GetValue<int>("GatewayPort"), listenOnAnyHostAddress: true)

.UseMongoDBClient(configSection.GetValue<string>("MongoDBClient"))
.UseMongoDBClustering(options =>
{
Expand Down Expand Up @@ -54,8 +63,8 @@ public static IHostBuilder UseOrleans(this IHostBuilder hostBuilder)
})
.Configure<ClusterOptions>(options =>
{
options.ClusterId = configSection.GetValue<string>("ClusterId");
options.ServiceId = configSection.GetValue<string>("ServiceId");
options.ClusterId = clusterId;
options.ServiceId = serviceId;
})
// .AddMemoryGrainStorage("PubSubStore")
.ConfigureApplicationParts(parts => parts.AddFromApplicationBaseDirectory())
Expand Down

0 comments on commit 0573e8f

Please sign in to comment.