feat:fix kube config

This commit is contained in:
geffzhang 2019-01-20 13:17:57 +08:00
parent 23248b080e
commit c212604b85
8 changed files with 53 additions and 13 deletions

View File

@ -1,10 +1,13 @@
FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
WORKDIR /app WORKDIR /app
EXPOSE 80 EXPOSE 80
FROM microsoft/dotnet:2.2-sdk AS build FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src WORKDIR /src
COPY ["ApiGateway/ApiGateway.csproj", "ApiGateway/"] COPY ["ApiGateway/ApiGateway.csproj", "ApiGateway/"]
COPY ["../../src/Ocelot.Provider.Polly/Ocelot.Provider.Polly.csproj", "../../src/Ocelot.Provider.Polly/"]
COPY ["../../src/Ocelot/Ocelot.csproj", "../../src/Ocelot/"]
COPY ["../../src/Ocelot.Provider.Kubernetes/Ocelot.Provider.Kubernetes.csproj", "../../src/Ocelot.Provider.Kubernetes/"]
RUN dotnet restore "ApiGateway/ApiGateway.csproj" RUN dotnet restore "ApiGateway/ApiGateway.csproj"
COPY . . COPY . .
WORKDIR "/src/ApiGateway" WORKDIR "/src/ApiGateway"

View File

@ -1,7 +1,7 @@
{ {
"ReRoutes": [ "ReRoutes": [
{ {
"DownstreamPathTemplate": "/api/Category", "DownstreamPathTemplate": "/api/values",
"DownstreamScheme": "http", "DownstreamScheme": "http",
"UpstreamPathTemplate": "/Category", "UpstreamPathTemplate": "/Category",
"ServiceName": "DownstreamService", "ServiceName": "DownstreamService",
@ -21,7 +21,7 @@
"Host": "localhost", "Host": "localhost",
"Port": 8001, "Port": 8001,
"Namesapce": "dev", "Namesapce": "dev",
"Type": "k8s" "Type": "kube"
} }
} }
} }

View File

@ -0,0 +1,22 @@
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 80
FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src
COPY ["ApiGateway/ApiGateway.csproj", "ApiGateway/"]
COPY ["../../src/Ocelot.Provider.Polly/Ocelot.Provider.Polly.csproj", "../../src/Ocelot.Provider.Polly/"]
COPY ["../../src/Ocelot/Ocelot.csproj", "../../src/Ocelot/"]
COPY ["../../src/Ocelot.Provider.Kubernetes/Ocelot.Provider.Kubernetes.csproj", "../../src/Ocelot.Provider.Kubernetes/"]
RUN dotnet restore "ApiGateway/ApiGateway.csproj"
COPY . .
WORKDIR "/src/ApiGateway"
RUN dotnet build "ApiGateway.csproj" -c Release -o /app
FROM build AS publish
RUN dotnet publish "ApiGateway.csproj" -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "ApiGateway.dll"]

View File

@ -1,8 +1,8 @@
FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
WORKDIR /app WORKDIR /app
EXPOSE 80 EXPOSE 80
FROM microsoft/dotnet:2.2-sdk AS build FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src WORKDIR /src
COPY ["DownstreamService/DownstreamService.csproj", "DownstreamService/"] COPY ["DownstreamService/DownstreamService.csproj", "DownstreamService/"]
RUN dotnet restore "DownstreamService/DownstreamService.csproj" RUN dotnet restore "DownstreamService/DownstreamService.csproj"

View File

@ -0,0 +1,15 @@
FROM microsoft/dotnet:2.1-sdk
ARG BUILD_CONFIGURATION=Debug
ENV ASPNETCORE_ENVIRONMENT=Development
ENV DOTNET_USE_POLLING_FILE_WATCHER=true
EXPOSE 80
WORKDIR /src
COPY ["DownstreamService/DownstreamService.csproj", "DownstreamService/"]
RUN dotnet restore "DownstreamService/DownstreamService.csproj"
COPY . .
WORKDIR "/src/DownstreamService"
RUN dotnet build --no-restore "DownstreamService.csproj" -c $BUILD_CONFIGURATION
ENTRYPOINT ["dotnet", "run", "--no-build", "--no-launch-profile", "-c", "$BUILD_CONFIGURATION", "--"]

View File

@ -11,7 +11,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ocelot.Provider.Kubernetes"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ocelot.Provider.Polly", "..\..\src\Ocelot.Provider.Polly\Ocelot.Provider.Polly.csproj", "{323055CB-BF62-4A31-A619-A4444B633CDB}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ocelot.Provider.Polly", "..\..\src\Ocelot.Provider.Polly\Ocelot.Provider.Polly.csproj", "{323055CB-BF62-4A31-A619-A4444B633CDB}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DownstreamService", "DownstreamService\DownstreamService.csproj", "{86FFAE3C-648F-4CDE-A260-37C8EBFBF4F2}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DownstreamService", "DownstreamService\DownstreamService.csproj", "{86FFAE3C-648F-4CDE-A260-37C8EBFBF4F2}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution

View File

@ -10,14 +10,14 @@ using System.Threading.Tasks;
namespace Ocelot.Provider.Kubernetes namespace Ocelot.Provider.Kubernetes
{ {
public class KubeProvider : IServiceDiscoveryProvider public class Kube : IServiceDiscoveryProvider
{ {
private KubeRegistryConfiguration kubeRegistryConfiguration; private KubeRegistryConfiguration kubeRegistryConfiguration;
private IOcelotLoggerFactory factory; private IOcelotLoggerFactory factory;
private IKubeApiClient kubeApi; private IKubeApiClient kubeApi;
private IKubeApiClientFactory kubeClientFactory; private IKubeApiClientFactory kubeClientFactory;
public KubeProvider(KubeRegistryConfiguration kubeRegistryConfiguration, IOcelotLoggerFactory factory, IKubeApiClientFactory kubeClientFactory) public Kube(KubeRegistryConfiguration kubeRegistryConfiguration, IOcelotLoggerFactory factory, IKubeApiClientFactory kubeClientFactory)
{ {
this.kubeRegistryConfiguration = kubeRegistryConfiguration; this.kubeRegistryConfiguration = kubeRegistryConfiguration;
this.factory = factory; this.factory = factory;

View File

@ -11,7 +11,7 @@ namespace Ocelot.Provider.Kubernetes
public static ServiceDiscoveryFinderDelegate Get = (provider, config, name) => public static ServiceDiscoveryFinderDelegate Get = (provider, config, name) =>
{ {
var factory = provider.GetService<IOcelotLoggerFactory>(); var factory = provider.GetService<IOcelotLoggerFactory>();
if (config.Type?.ToLower() == "k8s") if (config.Type?.ToLower() == "kube")
{ {
return GetkubeProvider(provider, config, name, factory); return GetkubeProvider(provider, config, name, factory);
} }
@ -31,7 +31,7 @@ namespace Ocelot.Provider.Kubernetes
AllowInsecure = true // Don't validate server certificate AllowInsecure = true // Don't validate server certificate
}; };
var k8sServiceDiscoveryProvider = new KubeProvider(k8sRegistryConfiguration, factory, kubeClientFactory); var k8sServiceDiscoveryProvider = new Kube(k8sRegistryConfiguration, factory, kubeClientFactory);
return k8sServiceDiscoveryProvider; return k8sServiceDiscoveryProvider;
} }