Browse Source

Merge pull request #80 from abpframework/gterdem/ocelot_config

eShopOnAbp: Introduce ocelot.json
ipaddr
Galip Tolga Erdem 5 years ago
committed by GitHub
parent
commit
f6923fcf73
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      etc/k8s/eshoponabp/charts/gateway-web-public/templates/gateway-web-public-configmap.yaml
  2. 4
      etc/k8s/eshoponabp/charts/gateway-web-public/templates/gateway-web-public-deployment.yaml
  3. 5
      etc/k8s/eshoponabp/charts/gateway-web/templates/gateway-web-configmap.yaml
  4. 4
      etc/k8s/eshoponabp/charts/gateway-web/templates/gateway-web-deployment.yaml
  5. 15
      gateways/web-public/src/EShopOnAbp.WebPublicGateway/Program.cs
  6. 99
      gateways/web-public/src/EShopOnAbp.WebPublicGateway/appsettings.json
  7. 100
      gateways/web-public/src/EShopOnAbp.WebPublicGateway/ocelot.json
  8. 14
      gateways/web/src/EShopOnAbp.WebGateway/Program.cs
  9. 89
      gateways/web/src/EShopOnAbp.WebGateway/appsettings.json
  10. 90
      gateways/web/src/EShopOnAbp.WebGateway/ocelot.json
  11. 24
      shared/EShopOnAbp.Shared.Hosting.Gateways/GatewayHostBuilderExtensions.cs

5
etc/k8s/eshoponabp/charts/gateway-web-public/templates/gateway-web-public-configmap.yaml

@ -3,8 +3,11 @@ kind: ConfigMap
metadata: metadata:
name: {{ .Release.Name }}-{{ .Chart.Name }}-configmap name: {{ .Release.Name }}-{{ .Chart.Name }}-configmap
data: data:
appsettings.json: |- ocelot.json: |-
{ {
"GlobalConfiguration": {
"BaseUrl": "{{ .Values.config.globalConfigurationBaseUrl }}"
},
"Routes": [ "Routes": [
{ {
"ServiceKey": "Identity Service", "ServiceKey": "Identity Service",

4
etc/k8s/eshoponabp/charts/gateway-web-public/templates/gateway-web-public-deployment.yaml

@ -22,8 +22,8 @@ spec:
containerPort: 443 containerPort: 443
volumeMounts: volumeMounts:
- name: config-volume - name: config-volume
mountPath: /app/appsettings.json mountPath: /app/ocelot.json
subPath: appsettings.json subPath: ocelot.json
env: env:
- name: App__SelfUrl - name: App__SelfUrl
value: "{{ .Values.config.selfUrl }}" value: "{{ .Values.config.selfUrl }}"

5
etc/k8s/eshoponabp/charts/gateway-web/templates/gateway-web-configmap.yaml

@ -3,8 +3,11 @@ kind: ConfigMap
metadata: metadata:
name: {{ .Release.Name }}-{{ .Chart.Name }}-configmap name: {{ .Release.Name }}-{{ .Chart.Name }}-configmap
data: data:
appsettings.json: |- ocelot.json: |-
{ {
"GlobalConfiguration": {
"BaseUrl": "{{ .Values.config.globalConfigurationBaseUrl }}"
},
"Routes": [ "Routes": [
{ {
"ServiceKey": "Identity Service", "ServiceKey": "Identity Service",

4
etc/k8s/eshoponabp/charts/gateway-web/templates/gateway-web-deployment.yaml

@ -22,8 +22,8 @@ spec:
containerPort: 443 containerPort: 443
volumeMounts: volumeMounts:
- name: config-volume - name: config-volume
mountPath: /app/appsettings.json mountPath: /app/ocelot.json
subPath: appsettings.json subPath: ocelot.json
env: env:
- name: App__SelfUrl - name: App__SelfUrl
value: "{{ .Values.config.selfUrl }}" value: "{{ .Values.config.selfUrl }}"

15
gateways/web-public/src/EShopOnAbp.WebPublicGateway/Program.cs

@ -3,6 +3,8 @@ using Serilog;
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace EShopOnAbp.WebPublicGateway; namespace EShopOnAbp.WebPublicGateway;
@ -17,10 +19,19 @@ public class Program
try try
{ {
Log.Information($"Starting {assemblyName}."); Log.Information($"Starting {assemblyName}.");
var app = await ApplicationBuilderHelper.BuildApplicationAsync<EShopOnAbpWebPublicGatewayModule>(args);
var builder = WebApplication.CreateBuilder(args);
builder.Host
.AddAppSettingsSecretsJson()
.AddOcelotJson()
.UseAutofac()
.UseSerilog();
await builder.AddApplicationAsync<EShopOnAbpWebPublicGatewayModule>();
var app = builder.Build();
await app.InitializeApplicationAsync(); await app.InitializeApplicationAsync();
await app.RunAsync(); await app.RunAsync();
return 0; return 0;
} }
catch (Exception ex) catch (Exception ex)

99
gateways/web-public/src/EShopOnAbp.WebPublicGateway/appsettings.json

@ -17,104 +17,7 @@
} }
}, },
"AllowedHosts": "*", "AllowedHosts": "*",
"Routes": [
{
"ServiceKey": "Account Service",
"DownstreamPathTemplate": "/api/account/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44330
}
],
"UpstreamPathTemplate": "/api/account/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"ServiceKey": "Administration Service",
"DownstreamPathTemplate": "/api/abp/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44353
}
],
"UpstreamPathTemplate": "/api/abp/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ],
"QoSOptions": {
"ExceptionsAllowedBeforeBreaking": 3,
"DurationOfBreak": 3000,
"TimeoutValue": 2500
}
},
{
"ServiceKey": "Catalog Service",
"DownstreamPathTemplate": "/api/catalog/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44354
}
],
"UpstreamPathTemplate": "/api/catalog/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ],
"QoSOptions": {
"ExceptionsAllowedBeforeBreaking": 3,
"DurationOfBreak": 3000,
"TimeoutValue": 2500
}
},
{
"ServiceKey": "Basket Service",
"DownstreamPathTemplate": "/api/basket/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44355
}
],
"UpstreamPathTemplate": "/api/basket/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ],
"QoSOptions": {
"ExceptionsAllowedBeforeBreaking": 3,
"DurationOfBreak": 3000,
"TimeoutValue": 2500
}
},
{
"ServiceKey": "Ordering Service",
"DownstreamPathTemplate": "/api/ordering/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44356
}
],
"UpstreamPathTemplate": "/api/ordering/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"ServiceKey": "Payment Service",
"DownstreamPathTemplate": "/api/payment/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44357
}
],
"UpstreamPathTemplate": "/api/payment/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
}
],
"GlobalConfiguration": {
"BaseUrl": "https://localhost:44373"
},
"Redis": { "Redis": {
"Configuration": "localhost:6379" "Configuration": "localhost:6379"
}, },

100
gateways/web-public/src/EShopOnAbp.WebPublicGateway/ocelot.json

@ -0,0 +1,100 @@
{
"GlobalConfiguration": {
"BaseUrl": "https://localhost:44373"
},
"Routes": [
{
"ServiceKey": "Account Service",
"DownstreamPathTemplate": "/api/account/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44330
}
],
"UpstreamPathTemplate": "/api/account/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"ServiceKey": "Administration Service",
"DownstreamPathTemplate": "/api/abp/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44353
}
],
"UpstreamPathTemplate": "/api/abp/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ],
"QoSOptions": {
"ExceptionsAllowedBeforeBreaking": 3,
"DurationOfBreak": 3000,
"TimeoutValue": 2500
}
},
{
"ServiceKey": "Catalog Service",
"DownstreamPathTemplate": "/api/catalog/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44354
}
],
"UpstreamPathTemplate": "/api/catalog/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ],
"QoSOptions": {
"ExceptionsAllowedBeforeBreaking": 3,
"DurationOfBreak": 3000,
"TimeoutValue": 2500
}
},
{
"ServiceKey": "Basket Service",
"DownstreamPathTemplate": "/api/basket/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44355
}
],
"UpstreamPathTemplate": "/api/basket/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ],
"QoSOptions": {
"ExceptionsAllowedBeforeBreaking": 3,
"DurationOfBreak": 3000,
"TimeoutValue": 2500
}
},
{
"ServiceKey": "Ordering Service",
"DownstreamPathTemplate": "/api/ordering/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44356
}
],
"UpstreamPathTemplate": "/api/ordering/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"ServiceKey": "Payment Service",
"DownstreamPathTemplate": "/api/payment/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44357
}
],
"UpstreamPathTemplate": "/api/payment/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
}
]
}

14
gateways/web/src/EShopOnAbp.WebGateway/Program.cs

@ -3,6 +3,8 @@ using Serilog;
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace EShopOnAbp.WebGateway; namespace EShopOnAbp.WebGateway;
@ -17,10 +19,18 @@ public class Program
try try
{ {
Log.Information($"Starting {assemblyName}."); Log.Information($"Starting {assemblyName}.");
var app = await ApplicationBuilderHelper.BuildApplicationAsync<EShopOnAbpWebGatewayModule>(args); var builder = WebApplication.CreateBuilder(args);
builder.Host
.AddAppSettingsSecretsJson()
.AddOcelotJson()
.UseAutofac()
.UseSerilog();
await builder.AddApplicationAsync<EShopOnAbpWebGatewayModule>();
var app = builder.Build();
await app.InitializeApplicationAsync(); await app.InitializeApplicationAsync();
await app.RunAsync(); await app.RunAsync();
return 0; return 0;
} }
catch (Exception ex) catch (Exception ex)

89
gateways/web/src/EShopOnAbp.WebGateway/appsettings.json

@ -17,94 +17,7 @@
} }
}, },
"AllowedHosts": "*", "AllowedHosts": "*",
"Routes": [
{
"ServiceKey": "Identity Service",
"DownstreamPathTemplate": "/api/identity/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44351
}
],
"UpstreamPathTemplate": "/api/identity/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"ServiceKey": "Account Service",
"DownstreamPathTemplate": "/api/account/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44330
}
],
"UpstreamPathTemplate": "/api/account/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"ServiceKey": "Administration Service",
"DownstreamPathTemplate": "/api/abp/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44353
}
],
"UpstreamPathTemplate": "/api/abp/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ],
"QoSOptions": {
"ExceptionsAllowedBeforeBreaking": 3,
"DurationOfBreak": 5000,
"TimeoutValue": 2500
}
},
{
"ServiceKey": "Administration Service",
"DownstreamPathTemplate": "/api/feature-management/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44353
}
],
"UpstreamPathTemplate": "/api/feature-management/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"ServiceKey": "Administration Service",
"DownstreamPathTemplate": "/api/permission-management/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44353
}
],
"UpstreamPathTemplate": "/api/permission-management/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"ServiceKey": "Administration Service",
"DownstreamPathTemplate": "/api/setting-management/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44353
}
],
"UpstreamPathTemplate": "/api/setting-management/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
}
],
"GlobalConfiguration": {
"BaseUrl": "https://localhost:44372"
},
"Redis": { "Redis": {
"Configuration": "localhost:6379" "Configuration": "localhost:6379"
}, },

90
gateways/web/src/EShopOnAbp.WebGateway/ocelot.json

@ -0,0 +1,90 @@
{
"GlobalConfiguration": {
"BaseUrl": "https://localhost:44372"
},
"Routes": [
{
"ServiceKey": "Identity Service",
"DownstreamPathTemplate": "/api/identity/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44351
}
],
"UpstreamPathTemplate": "/api/identity/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"ServiceKey": "Account Service",
"DownstreamPathTemplate": "/api/account/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44330
}
],
"UpstreamPathTemplate": "/api/account/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"ServiceKey": "Administration Service",
"DownstreamPathTemplate": "/api/abp/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44353
}
],
"UpstreamPathTemplate": "/api/abp/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ],
"QoSOptions": {
"ExceptionsAllowedBeforeBreaking": 3,
"DurationOfBreak": 5000,
"TimeoutValue": 2500
}
},
{
"ServiceKey": "Administration Service",
"DownstreamPathTemplate": "/api/feature-management/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44353
}
],
"UpstreamPathTemplate": "/api/feature-management/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"ServiceKey": "Administration Service",
"DownstreamPathTemplate": "/api/permission-management/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44353
}
],
"UpstreamPathTemplate": "/api/permission-management/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"ServiceKey": "Administration Service",
"DownstreamPathTemplate": "/api/setting-management/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44353
}
],
"UpstreamPathTemplate": "/api/setting-management/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
}
]
}

24
shared/EShopOnAbp.Shared.Hosting.Gateways/GatewayHostBuilderExtensions.cs

@ -0,0 +1,24 @@
using Microsoft.Extensions.Configuration;
namespace Microsoft.Extensions.Hosting;
public static class AbpHostingHostBuilderExtensions
{
public const string AppOcelotJsonPath = "ocelot.json";
public static IHostBuilder AddOcelotJson(
this IHostBuilder hostBuilder,
bool optional = true,
bool reloadOnChange = true,
string path = AppOcelotJsonPath)
{
return hostBuilder.ConfigureAppConfiguration((_, builder) =>
{
builder.AddJsonFile(
path: AppOcelotJsonPath,
optional: optional,
reloadOnChange: reloadOnChange
);
});
}
}
Loading…
Cancel
Save