feat:Remove unnecessary code

This commit is contained in:
geffzhang 2019-01-31 07:30:27 +08:00
parent 246f2046b3
commit a92dfca36d
5 changed files with 6 additions and 12 deletions

View File

@ -18,9 +18,8 @@ If you have services deployed in kubernetes you will normally use the naming ser
The following example shows how to set up a ReRoute that will work in kubernetes. The most important thing is the ServiceName which is made up of the The following example shows how to set up a ReRoute that will work in kubernetes. The most important thing is the ServiceName which is made up of the
kubernetes service name. We also need to set up the ServiceDiscoveryProvider in kubernetes service name. We also need to set up the ServiceDiscoveryProvider in
GlobalConfiguration. The example here shows a typical configuration. It assumes kubernetes api server is running on 192.168.0.13 and that the api service is on port 443. GlobalConfiguration. The example here shows a typical configuration. It assumes kubernetes api server is running on 192.168.0.13 and that api service is on port 443.
The example below is taken from the samples folder so please check it if this doesnt make sense!
.. code-block:: json .. code-block:: json
@ -45,7 +44,7 @@ The example below is taken from the samples folder so please check it if this do
} }
} }
You also can use Ocelot polls kubernetes for latest service information rather than per request. If you want to poll kubernetes for the latest services rather than per request (default behaviour) then you need to set the following configuration. You use Ocelot to poll kubernetes for latest service information rather than per request. If you want to poll kubernetes for the latest services rather than per request (default behaviour) then you need to set the following configuration.
"ServiceDiscoveryProvider": { "ServiceDiscoveryProvider": {
"Host": "192.168.0.13", "Host": "192.168.0.13",

View File

@ -5,7 +5,6 @@ EXPOSE 80
FROM microsoft/dotnet:2.1-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/Ocelot.csproj", "../../src/Ocelot/"]
COPY ["../../src/Ocelot.Provider.Kubernetes/Ocelot.Provider.Kubernetes.csproj", "../../src/Ocelot.Provider.Kubernetes/"] 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"

View File

@ -9,8 +9,6 @@
} }
], ],
"GlobalConfiguration": { "GlobalConfiguration": {
"RequestIdKey": "OcRequestId",
"AdministrationPath": "/administration",
"ServiceDiscoveryProvider": { "ServiceDiscoveryProvider": {
"Host": "192.168.0.13", "Host": "192.168.0.13",
"Port": 443, "Port": 443,

View File

@ -25,7 +25,8 @@ namespace Ocelot.Provider.Kubernetes
public async Task<List<Service>> Get() public async Task<List<Service>> Get()
{ {
var service = await kubeApi.ServicesV1().Get(kubeRegistryConfiguration.KeyOfServiceInK8s, kubeRegistryConfiguration.KubeNamespace); var service = await kubeApi.ServicesV1()
.Get(kubeRegistryConfiguration.KeyOfServiceInK8s, kubeRegistryConfiguration.KubeNamespace);
var services = new List<Service>(); var services = new List<Service>();
if (IsValid(service)) if (IsValid(service))
{ {

View File

@ -11,9 +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>();
return GetkubeProvider(provider, config, name, factory); return GetkubeProvider(provider, config, name, factory);
}; };
private static ServiceDiscovery.Providers.IServiceDiscoveryProvider GetkubeProvider(IServiceProvider provider, Configuration.ServiceProviderConfiguration config, string name, IOcelotLoggerFactory factory) private static ServiceDiscovery.Providers.IServiceDiscoveryProvider GetkubeProvider(IServiceProvider provider, Configuration.ServiceProviderConfiguration config, string name, IOcelotLoggerFactory factory)
@ -30,7 +28,6 @@ namespace Ocelot.Provider.Kubernetes
}; };
var k8sServiceDiscoveryProvider = new Kube(k8sRegistryConfiguration, factory, kubeClientFactory); var k8sServiceDiscoveryProvider = new Kube(k8sRegistryConfiguration, factory, kubeClientFactory);
if (config.Type?.ToLower() == "pollkube") if (config.Type?.ToLower() == "pollkube")
{ {
return new PollKube(config.PollingInterval, factory, k8sServiceDiscoveryProvider); return new PollKube(config.PollingInterval, factory, k8sServiceDiscoveryProvider);