Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kubernetes hosting integration #6707

Merged
merged 6 commits into from
Sep 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<MicrosoftBuildVersion>16.4.0</MicrosoftBuildVersion>
<MicrosoftCodeAnalysisVersion>3.4.0</MicrosoftCodeAnalysisVersion>
<MicrosoftCSharpVersion>4.7.0</MicrosoftCSharpVersion>
<MicrosoftBclAsyncInterfacesVersion>1.1.0</MicrosoftBclAsyncInterfacesVersion>
<MicrosoftBclAsyncInterfacesVersion>1.1.1</MicrosoftBclAsyncInterfacesVersion>
<MicrosoftNETFrameworkReferenceAssembliesVersion>1.0.0</MicrosoftNETFrameworkReferenceAssembliesVersion>
<MicrosoftBclHashCodeVersion>1.0.0</MicrosoftBclHashCodeVersion>

Expand All @@ -76,6 +76,7 @@
<MicrosoftExtensionsLoggingVersion>3.0.0</MicrosoftExtensionsLoggingVersion>
<MicrosoftExtensionsObjectPoolVersion>3.0.0</MicrosoftExtensionsObjectPoolVersion>
<MicrosoftExtensionsOptionsVersion>3.0.0</MicrosoftExtensionsOptionsVersion>
<MicrosoftExtensionsHttpVersion>3.0.0</MicrosoftExtensionsHttpVersion>
<MicrosoftExtensionsHostingAbstractionsVersion>3.0.0</MicrosoftExtensionsHostingAbstractionsVersion>
<MicrosoftExtensionsHostingVersion>3.0.0</MicrosoftExtensionsHostingVersion>

Expand Down Expand Up @@ -107,6 +108,7 @@
<NSubstituteAnalyzersCSharpVersion>1.0.10</NSubstituteAnalyzersCSharpVersion>
<ZooKeeperNetExVersion>3.4.12.1</ZooKeeperNetExVersion>
<StackExchangeRedis>2.0.601</StackExchangeRedis>
<KubernetesClientVersion>2.0.29</KubernetesClientVersion>

<!-- Test related packages -->
<FluentAssertionsVersion>4.19.4</FluentAssertionsVersion>
Expand Down
19 changes: 17 additions & 2 deletions Orleans.sln
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Orleans.Connections.Securit
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Orleans.GrainDirectory.AzureStorage", "src\Azure\Orleans.GrainDirectory.AzureStorage\Orleans.GrainDirectory.AzureStorage.csproj", "{16B9B850-ED3B-4B45-B0F2-3F802D44F382}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orleans.GrainDirectory.Redis", "src\Orleans.GrainDirectory.Redis\Orleans.GrainDirectory.Redis.csproj", "{CCEF897C-F4F8-48F0-8F95-CC1487EE2936}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Orleans.GrainDirectory.Redis", "src\Orleans.GrainDirectory.Redis\Orleans.GrainDirectory.Redis.csproj", "{CCEF897C-F4F8-48F0-8F95-CC1487EE2936}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tester.Redis", "test\Extensions\Tester.Redis\Tester.Redis.csproj", "{F13247A0-70C9-4200-9CB1-2002CB8105E0}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tester.Redis", "test\Extensions\Tester.Redis\Tester.Redis.csproj", "{F13247A0-70C9-4200-9CB1-2002CB8105E0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Orleans.Hosting.Kubernetes", "src\Orleans.Hosting.Kubernetes\Orleans.Hosting.Kubernetes.csproj", "{D1214CD3-EB99-4420-9E30-A50ACFD66A48}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -1206,6 +1208,18 @@ Global
{F13247A0-70C9-4200-9CB1-2002CB8105E0}.Release|x64.Build.0 = Release|Any CPU
{F13247A0-70C9-4200-9CB1-2002CB8105E0}.Release|x86.ActiveCfg = Release|Any CPU
{F13247A0-70C9-4200-9CB1-2002CB8105E0}.Release|x86.Build.0 = Release|Any CPU
{D1214CD3-EB99-4420-9E30-A50ACFD66A48}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D1214CD3-EB99-4420-9E30-A50ACFD66A48}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D1214CD3-EB99-4420-9E30-A50ACFD66A48}.Debug|x64.ActiveCfg = Debug|Any CPU
{D1214CD3-EB99-4420-9E30-A50ACFD66A48}.Debug|x64.Build.0 = Debug|Any CPU
{D1214CD3-EB99-4420-9E30-A50ACFD66A48}.Debug|x86.ActiveCfg = Debug|Any CPU
{D1214CD3-EB99-4420-9E30-A50ACFD66A48}.Debug|x86.Build.0 = Debug|Any CPU
{D1214CD3-EB99-4420-9E30-A50ACFD66A48}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D1214CD3-EB99-4420-9E30-A50ACFD66A48}.Release|Any CPU.Build.0 = Release|Any CPU
{D1214CD3-EB99-4420-9E30-A50ACFD66A48}.Release|x64.ActiveCfg = Release|Any CPU
{D1214CD3-EB99-4420-9E30-A50ACFD66A48}.Release|x64.Build.0 = Release|Any CPU
{D1214CD3-EB99-4420-9E30-A50ACFD66A48}.Release|x86.ActiveCfg = Release|Any CPU
{D1214CD3-EB99-4420-9E30-A50ACFD66A48}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1307,6 +1321,7 @@ Global
{16B9B850-ED3B-4B45-B0F2-3F802D44F382} = {4C5D66BF-EE1C-4DD8-8551-D1B7F3768A34}
{CCEF897C-F4F8-48F0-8F95-CC1487EE2936} = {FE2E08C6-9C3B-4AEE-AE07-CCA387580D7A}
{F13247A0-70C9-4200-9CB1-2002CB8105E0} = {082D25DB-70CA-48F4-93E0-EC3455F494B8}
{D1214CD3-EB99-4420-9E30-A50ACFD66A48} = {FE2E08C6-9C3B-4AEE-AE07-CCA387580D7A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7BFB3429-B5BB-4DB1-95B4-67D77A864952}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using AutoMapper.Configuration.Annotations;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Orleans.Configuration;
using System;
using System.Net;

namespace Orleans.Hosting.Kubernetes
{
internal class ConfigureKubernetesHostingOptions :
IConfigureOptions<ClusterOptions>,
IConfigureOptions<SiloOptions>,
IPostConfigureOptions<EndpointOptions>,
IConfigureOptions<KubernetesHostingOptions>
{
private readonly IServiceProvider _serviceProvider;

public ConfigureKubernetesHostingOptions(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
}

public void Configure(KubernetesHostingOptions options)
{
options.Namespace = Environment.GetEnvironmentVariable(KubernetesHostingOptions.PodNamespaceEnvironmentVariable);
options.PodName = Environment.GetEnvironmentVariable(KubernetesHostingOptions.PodNameEnvironmentVariable);
options.PodIP = Environment.GetEnvironmentVariable(KubernetesHostingOptions.PodIPEnvironmentVariable);
}

public void Configure(ClusterOptions options)
{
options.ServiceId = Environment.GetEnvironmentVariable(KubernetesHostingOptions.ServiceIdEnvironmentVariable);
options.ClusterId = Environment.GetEnvironmentVariable(KubernetesHostingOptions.ClusterIdEnvironmentVariable);
}

public void Configure(SiloOptions options)
{
options.SiloName = Environment.GetEnvironmentVariable(KubernetesHostingOptions.PodNameEnvironmentVariable);
}

public void PostConfigure(string name, EndpointOptions options)
{
// Use PostConfigure to give the developer an opportunity to set SiloPort and GatewayPort using regular
// Configure methods without needing to worry about ordering with respect to the UseKubernetesHosting call.
if (options.AdvertisedIPAddress is null)
{
var hostingOptions = _serviceProvider.GetRequiredService<IOptions<KubernetesHostingOptions>>().Value;
var podIp = IPAddress.Parse(hostingOptions.PodIP);
options.AdvertisedIPAddress = podIp;
}

if (options.SiloListeningEndpoint is null)
{
options.SiloListeningEndpoint = new IPEndPoint(IPAddress.Any, options.SiloPort);
}

if (options.GatewayListeningEndpoint is null && options.GatewayPort > 0)
{
options.GatewayListeningEndpoint = new IPEndPoint(IPAddress.Any, options.GatewayPort);
}
}
}
}
Loading