Fixed missing env variables in marketing.api in k8s scripts

Added Resource path in webstatus UI when deploying with K8S
Added Liveness healthChecks
Updated k8s healthcheck configuration
This commit is contained in:
Ramón Tomás 2019-01-03 17:11:56 +01:00
parent ffca2da0b3
commit dbf175f913
35 changed files with 191 additions and 93 deletions

View File

@ -16,7 +16,7 @@ $dns = $externalDns
$ingressValuesFile="ingress_values.yaml"
if ($ingressValuesFile) {
if ($useLocalk8s) {
$ingressValuesFile="ingress_values_dockerk8s.yaml"
$dns="localhost"
}

View File

@ -14,6 +14,8 @@ inf:
db: OrderingDb # Ordering API SQL db name
identity:
db: IdentityDb # Ordering API SQL db name
marketing:
db: MarketingDb # Marketing API SQL db name
mongo:
# host: my-nosql-data # Uncomment to use specify custom mongo host. By default nosql-data is used
locations:

View File

@ -2,6 +2,7 @@
{{- $identity := include "url-of" (list .Values.app.ingress.entries.identity .) -}}
{{- $webshoppingapigw := include "url-of" (list .Values.app.ingress.entries.webshoppingapigw .) -}}
{{- $mongo := include "mongo-name" . -}}
{{- $sqlsrv := include "sql-name" . -}}
apiVersion: v1
kind: ConfigMap
@ -19,6 +20,7 @@ data:
all_EnableLoadTest: "{{ .Values.inf.misc.useLoadTest }}"
internalurls__IdentityUrl: http://{{ .Values.app.svc.identity }}
urls__IdentityUrl: {{ $identity }}
marketing__ConnectionString: mongodb://{{ $mongo }}
marketing__Database: {{ .Values.inf.mongo.marketing.database }}
marketing__ConnectionString: Server={{ $sqlsrv }};Initial Catalog={{ .Values.inf.sql.marketing.db }};User Id={{ .Values.inf.sql.common.user }};Password={{ .Values.inf.sql.common.pwd }};
marketing__MongoConnectionString: mongodb://{{ $mongo }}
marketing__MongoDatabase: {{ .Values.inf.mongo.marketing.database }}
marketing__PicBaseUrl: http://{{ $webshoppingapigw }}/api/v1/c/catalog/items/[0]/pic/

View File

@ -44,8 +44,10 @@ env:
key: urls__IdentityUrl
- name: ConnectionString
key: marketing__ConnectionString
- name: Database
key: marketing__Database
- name: MongoConnectionString
key: marketing__MongoConnectionString
- name: MongoDatabase
key: marketing__MongoDatabase
- name: PicBaseUrl
key: marketing__PicBaseUrl
# values define environment variables with a fixed value (no configmap involved) (name is name of var, and value is its value)

View File

@ -13,7 +13,9 @@ service:
ingress:
enabled: true
annotations: {}
annotations: {
}
tls: []
resources: {}
@ -32,73 +34,73 @@ env:
configmap:
- name: ApplicationInsights__InstrumentationKey
key: all__InstrumentationKey
- name: HealthChecks-UI__HealthChecks__1__Name
- name: HealthChecks-UI__HealthChecks__0__Name
key: name__mvc__hc
- name: HealthChecks-UI__HealthChecks__1__Uri
- name: HealthChecks-UI__HealthChecks__0__Uri
key: internalurls__mvc__hc
- name: HealthChecks-UI__HealthChecks__2__Name
- name: HealthChecks-UI__HealthChecks__1__Name
key: name__spa__hc
- name: HealthChecks-UI__HealthChecks__2__Uri
- name: HealthChecks-UI__HealthChecks__1__Uri
key: internalurls__spa__hc
- name: HealthChecks-UI__HealthChecks__3__Name
- name: HealthChecks-UI__HealthChecks__2__Name
key: name__apigwws__hc
- name: HealthChecks-UI__HealthChecks__3__Uri
- name: HealthChecks-UI__HealthChecks__2__Uri
key: internalurls__apigwws__hc
- name: HealthChecks-UI__HealthChecks__4__Name
- name: HealthChecks-UI__HealthChecks__3__Name
key: name__apigwwm__hc
- name: HealthChecks-UI__HealthChecks__4__Uri
- name: HealthChecks-UI__HealthChecks__3__Uri
key: internalurls__apigwwm__hc
- name: HealthChecks-UI__HealthChecks__5__Name
- name: HealthChecks-UI__HealthChecks__4__Name
key: name__apigwms__hc
- name: HealthChecks-UI__HealthChecks__5__Uri
key: internalurls__apigwms__hcç
- name: HealthChecks-UI__HealthChecks__6__Name
- name: HealthChecks-UI__HealthChecks__4__Uri
key: internalurls__apigwms__hc
- name: HealthChecks-UI__HealthChecks__5__Name
key: name__apigwmm__hc
- name: HealthChecks-UI__HealthChecks__6__Uri
- name: HealthChecks-UI__HealthChecks__5__Uri
key: internalurls__apigwmm__hc
- name: HealthChecks-UI__HealthChecks__7__Name
- name: HealthChecks-UI__HealthChecks__6__Name
key: name__apigwwsagg__hc
- name: HealthChecks-UI__HealthChecks__7__Uri
- name: HealthChecks-UI__HealthChecks__6__Uri
key: internalurls__apigwwsagg__hc
- name: HealthChecks-UI__HealthChecks__8__Name
- name: HealthChecks-UI__HealthChecks__7__Name
key: name__apigwmsagg__hc
- name: HealthChecks-UI__HealthChecks__8__Uri
- name: HealthChecks-UI__HealthChecks__7__Uri
key: internalurls__apigwmsagg__hc
- name: HealthChecks-UI__HealthChecks__9__Name
- name: HealthChecks-UI__HealthChecks__8__Name
key: name__ordering__hc
- name: HealthChecks-UI__HealthChecks__9__Uri
- name: HealthChecks-UI__HealthChecks__8__Uri
key: internalurls__ordering__hc
- name: HealthChecks-UI__HealthChecks__10__Name
- name: HealthChecks-UI__HealthChecks__9__Name
key: name__orderingbackground__hc
- name: HealthChecks-UI__HealthChecks__10__Uri
- name: HealthChecks-UI__HealthChecks__9__Uri
key: internalurls__orderingbackground__hc
- name: HealthChecks-UI__HealthChecks__11__Name
- name: HealthChecks-UI__HealthChecks__10__Name
key: name__signalrhub__hc
- name: HealthChecks-UI__HealthChecks__11__Uri
- name: HealthChecks-UI__HealthChecks__10__Uri
key: internalurls__signalrhub__hc
- name: HealthChecks-UI__HealthChecks__12__Name
- name: HealthChecks-UI__HealthChecks__11__Name
key: name__basket__hc
- name: HealthChecks-UI__HealthChecks__12__Uri
- name: HealthChecks-UI__HealthChecks__11__Uri
key: internalurls__basket__hc
- name: HealthChecks-UI__HealthChecks__13__Name
- name: HealthChecks-UI__HealthChecks__12__Name
key: name__catalog__hc
- name: HealthChecks-UI__HealthChecks__13__Uri
- name: HealthChecks-UI__HealthChecks__12__Uri
key: internalurls__catalog__hc
- name: HealthChecks-UI__HealthChecks__14__Name
- name: HealthChecks-UI__HealthChecks__13__Name
key: name__identity__hc
- name: HealthChecks-UI__HealthChecks__14__Uri
- name: HealthChecks-UI__HealthChecks__13__Uri
key: internalurls__identity__hc
- name: HealthChecks-UI__HealthChecks__15__Name
- name: HealthChecks-UI__HealthChecks__14__Name
key: name__marketing__hc
- name: HealthChecks-UI__HealthChecks__15__Uri
- name: HealthChecks-UI__HealthChecks__14__Uri
key: internalurls__marketing__hc
- name: HealthChecks-UI__HealthChecks__16__Name
- name: HealthChecks-UI__HealthChecks__15__Name
key: name__locations__hc
- name: HealthChecks-UI__HealthChecks__16__Uri
- name: HealthChecks-UI__HealthChecks__15__Uri
key: internalurls__locations__hc
- name: HealthChecks-UI__HealthChecks__17__Name
- name: HealthChecks-UI__HealthChecks__16__Name
key: name__payment__hc
- name: HealthChecks-UI__HealthChecks__17__Uri
- name: HealthChecks-UI__HealthChecks__16__Uri
key: internalurls__payment__hc
# values define environment variables with a fixed value (no configmap involved) (name is name of var, and value is its value)
values:

View File

@ -12,6 +12,7 @@
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="2.2.0" />
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" />
<PackageReference Include="Ocelot" Version="12.0.1" />
</ItemGroup>

View File

@ -8,6 +8,7 @@ using Ocelot.DependencyInjection;
using Ocelot.Middleware;
using System;
using HealthChecks.UI.Client;
using Microsoft.Extensions.Diagnostics.HealthChecks;
namespace OcelotApiGw
{
@ -26,6 +27,7 @@ namespace OcelotApiGw
var authenticationProviderKey = "IdentityApiKey";
services.AddHealthChecks()
.AddCheck("self", () => HealthCheckResult.Healthy())
.AddUrlGroup(new Uri(_cfg["CatalogUrlHC"]), name: "catalogapi-check", tags: new string[] { "catalogapi" })
.AddUrlGroup(new Uri(_cfg["OrderingUrlHC"]), name: "orderingapi-check", tags: new string[] { "orderingapi" })
.AddUrlGroup(new Uri(_cfg["BasketUrlHC"]), name: "basketapi-check", tags: new string[] { "basketapi" })
@ -93,6 +95,11 @@ namespace OcelotApiGw
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
});
app.UseHealthChecks("/liveness", new HealthCheckOptions
{
Predicate = r => r.Name.Contains("self")
});
loggerFactory.AddConsole(_cfg.GetSection("Logging"));
app.UseCors("CorsPolicy");

View File

@ -15,6 +15,7 @@
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="2.2.0" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="2.2.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="2.2.0-preview3-35497" />

View File

@ -19,6 +19,7 @@ using Polly.Extensions.Http;
using Swashbuckle.AspNetCore.Swagger;
using HealthChecks.UI.Client;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.Extensions.Diagnostics.HealthChecks;
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator
{
@ -35,6 +36,7 @@ namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator
public void ConfigureServices(IServiceCollection services)
{
services.AddHealthChecks()
.AddCheck("self", () => HealthCheckResult.Healthy())
.AddUrlGroup(new Uri(Configuration["CatalogUrlHC"]), name: "catalogapi-check", tags: new string[] { "catalogapi" })
.AddUrlGroup(new Uri(Configuration["OrderingUrlHC"]), name: "orderingapi-check", tags: new string[] { "orderingapi" })
.AddUrlGroup(new Uri(Configuration["BasketUrlHC"]), name: "basketapi-check", tags: new string[] { "basketapi" })
@ -65,6 +67,11 @@ namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
});
app.UseHealthChecks("/liveness", new HealthCheckOptions
{
Predicate = r => r.Name.Contains("self")
});
app.UseCors("CorsPolicy");
if (env.IsDevelopment())

View File

@ -20,6 +20,7 @@ using System.IdentityModel.Tokens.Jwt;
using System.Net.Http;
using HealthChecks.UI.Client;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.Extensions.Diagnostics.HealthChecks;
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator
{
@ -36,6 +37,7 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator
public void ConfigureServices(IServiceCollection services)
{
services.AddHealthChecks()
.AddCheck("self", () => HealthCheckResult.Healthy())
.AddUrlGroup(new Uri(Configuration["CatalogUrlHC"]), name: "catalogapi-check", tags: new string[] { "catalogapi" })
.AddUrlGroup(new Uri(Configuration["OrderingUrlHC"]), name: "orderingapi-check", tags: new string[] { "orderingapi" })
.AddUrlGroup(new Uri(Configuration["BasketUrlHC"]), name: "basketapi-check", tags: new string[] { "basketapi" })
@ -65,6 +67,11 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
});
app.UseHealthChecks("/liveness", new HealthCheckOptions
{
Predicate = r => r.Name.Contains("self")
});
app.UseCors("CorsPolicy");
if (env.IsDevelopment())

View File

@ -15,6 +15,7 @@
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="2.2.0" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="2.2.0-preview3-35497" />
</ItemGroup>

View File

@ -21,6 +21,7 @@
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.6.1" />
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta8" />
<PackageReference Include="Microsoft.ApplicationInsights.ServiceFabric" Version="2.1.1-beta1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.2.1" />

View File

@ -25,6 +25,7 @@ using Microsoft.eShopOnContainers.Services.Basket.API.Model;
using Microsoft.eShopOnContainers.Services.Basket.API.Services;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using RabbitMQ.Client;
@ -194,9 +195,10 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
});
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
app.Map("/liveness", lapp => lapp.Run(async ctx => ctx.Response.StatusCode = 200));
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
app.UseHealthChecks("/liveness", new HealthCheckOptions
{
Predicate = r => r.Name.Contains("self")
});
app.UseStaticFiles();
app.UseCors("CorsPolicy");
@ -322,6 +324,8 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API
{
var hcBuilder = services.AddHealthChecks();
hcBuilder.AddCheck("self", () => HealthCheckResult.Healthy());
hcBuilder
.AddRedis(
configuration["ConnectionString"],

View File

@ -30,6 +30,7 @@ using System.Data.Common;
using System.Reflection;
using HealthChecks.UI.Client;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.Extensions.Diagnostics.HealthChecks;
namespace Microsoft.eShopOnContainers.Services.Catalog.API
{
@ -80,9 +81,10 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
});
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
app.Map("/liveness", lapp => lapp.Run(async ctx => ctx.Response.StatusCode = 200));
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
app.UseHealthChecks("/liveness", new HealthCheckOptions
{
Predicate = r => r.Name.Contains("self")
});
app.UseCors("CorsPolicy");
@ -156,6 +158,7 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API
var hcBuilder = services.AddHealthChecks();
hcBuilder
.AddCheck("self", () => HealthCheckResult.Healthy())
.AddSqlServer(
configuration["ConnectionString"],
name: "CatalogDB-check",

View File

@ -13,6 +13,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="2.2.0" />
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="2.2.0" />

View File

@ -21,6 +21,7 @@ using System;
using System.Reflection;
using HealthChecks.UI.Client;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.Extensions.Diagnostics.HealthChecks;
namespace Microsoft.eShopOnContainers.Services.Identity.API
{
@ -67,6 +68,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API
}
services.AddHealthChecks()
.AddCheck("self", () => HealthCheckResult.Healthy())
.AddSqlServer(Configuration["ConnectionString"],
name: "IdentityDB-check",
tags: new string[] { "IdentityDB" });
@ -138,16 +140,16 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API
app.UsePathBase(pathBase);
}
app.UseHealthChecks("/hc", new HealthCheckOptions()
{
Predicate = _ => true,
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
});
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
app.Map("/liveness", lapp => lapp.Run(async ctx => ctx.Response.StatusCode = 200));
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
app.UseHealthChecks("/liveness", new HealthCheckOptions
{
Predicate = r => r.Name.Contains("self")
});
app.UseStaticFiles();

View File

@ -15,6 +15,7 @@
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.6.1" />
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta8" />
<PackageReference Include="Microsoft.ApplicationInsights.ServiceFabric" Version="2.1.1-beta1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="2.2.0" />

View File

@ -21,6 +21,7 @@ using Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Reposito
using Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Services;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.Logging;
using RabbitMQ.Client;
using Swashbuckle.AspNetCore.Swagger;
@ -162,9 +163,10 @@ namespace Microsoft.eShopOnContainers.Services.Locations.API
app.UsePathBase(pathBase);
}
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
app.Map("/liveness", lapp => lapp.Run(async ctx => ctx.Response.StatusCode = 200));
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
app.UseHealthChecks("/liveness", new HealthCheckOptions
{
Predicate = r => r.Name.Contains("self")
});
app.UseHealthChecks("/hc", new HealthCheckOptions()
{
@ -282,6 +284,8 @@ namespace Microsoft.eShopOnContainers.Services.Locations.API
{
var hcBuilder = services.AddHealthChecks();
hcBuilder.AddCheck("self", () => HealthCheckResult.Healthy());
hcBuilder
.AddMongoDb(
configuration["ConnectionString"],

View File

@ -30,6 +30,7 @@
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.2.1" />
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.6.1" />
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta8" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="2.2.0" />
<PackageReference Include="Microsoft.ApplicationInsights.ServiceFabric" Version="2.1.1-beta1" />

View File

@ -28,6 +28,7 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.Middlewares;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using RabbitMQ.Client;
using Swashbuckle.AspNetCore.Swagger;
using System;
@ -193,9 +194,10 @@
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
});
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
app.Map("/liveness", lapp => lapp.Run(async ctx => ctx.Response.StatusCode = 200));
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
app.UseHealthChecks("/liveness", new HealthCheckOptions
{
Predicate = r => r.Name.Contains("self")
});
app.UseCors("CorsPolicy");
@ -313,6 +315,8 @@
{
var hcBuilder = services.AddHealthChecks();
hcBuilder.AddCheck("self", () => HealthCheckResult.Healthy());
hcBuilder
.AddSqlServer(
configuration["ConnectionString"],

View File

@ -38,6 +38,7 @@
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.6.1" />
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta8" />
<PackageReference Include="Microsoft.ApplicationInsights.ServiceFabric" Version="2.1.1-beta1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.2.0" />

View File

@ -37,6 +37,7 @@
using System.Reflection;
using HealthChecks.UI.Client;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.Extensions.Diagnostics.HealthChecks;
public class Startup
{
@ -81,14 +82,14 @@
{
loggerFactory.CreateLogger("init").LogDebug($"Using PATH BASE '{pathBase}'");
app.UsePathBase(pathBase);
}
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
app.Map("/liveness", lapp => lapp.Run(async ctx => ctx.Response.StatusCode = 200));
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
}
app.UseCors("CorsPolicy");
app.UseHealthChecks("/liveness", new HealthCheckOptions
{
Predicate = r => r.Name.Contains("self")
});
app.UseHealthChecks("/hc", new HealthCheckOptions()
{
@ -185,6 +186,8 @@
{
var hcBuilder = services.AddHealthChecks();
hcBuilder.AddCheck("self", () => HealthCheckResult.Healthy());
hcBuilder
.AddSqlServer(
configuration["ConnectionString"],

View File

@ -20,6 +20,7 @@
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.2.1" />
<PackageReference Include="Dapper" Version="1.50.4" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" />
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="2.2.0" />
</ItemGroup>

View File

@ -17,6 +17,7 @@ using RabbitMQ.Client;
using System;
using HealthChecks.UI.Client;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.Extensions.Diagnostics.HealthChecks;
namespace Ordering.BackgroundTasks
{
@ -110,9 +111,10 @@ namespace Ordering.BackgroundTasks
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
});
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
app.Map("/liveness", lapp => lapp.Run(async ctx => ctx.Response.StatusCode = 200));
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
app.UseHealthChecks("/liveness", new HealthCheckOptions
{
Predicate = r => r.Name.Contains("self")
});
}
@ -162,6 +164,8 @@ namespace Ordering.BackgroundTasks
{
var hcBuilder = services.AddHealthChecks();
hcBuilder.AddCheck("self", () => HealthCheckResult.Healthy());
hcBuilder
.AddSqlServer(
configuration["ConnectionString"],

View File

@ -14,11 +14,12 @@
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="2.2.0" />
<PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="2.2.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.2.1" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0-preview3-35497" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" />
<PackageReference Include="Microsoft.AspNetCore.SignalR" Version="1.1.0-preview3-35497" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Core" Version="1.1.0-preview3-35497" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Redis" Version="1.1.0-preview3-35497" />
<PackageReference Include="Microsoft.AspNetCore.SignalR" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Core" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Redis" Version="1.1.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.2.1" />
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.6.1" />
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta8" />

View File

@ -19,6 +19,7 @@ using System;
using System.IdentityModel.Tokens.Jwt;
using HealthChecks.UI.Client;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.Extensions.Diagnostics.HealthChecks;
namespace Ordering.SignalrHub
{
@ -136,6 +137,11 @@ namespace Ordering.SignalrHub
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
});
app.UseHealthChecks("/liveness", new HealthCheckOptions
{
Predicate = r => r.Name.Contains("self")
});
app.UseCors("CorsPolicy");
app.UseAuthentication();
@ -227,6 +233,8 @@ namespace Ordering.SignalrHub
{
var hcBuilder = services.AddHealthChecks();
hcBuilder.AddCheck("self", () => HealthCheckResult.Healthy());
if (configuration.GetValue<bool>("AzureServiceBusEnabled"))
{
hcBuilder

View File

@ -15,6 +15,7 @@
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.6.1" />
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta8" />
<PackageReference Include="Microsoft.ApplicationInsights.ServiceFabric" Version="2.1.1-beta1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.2.0-preview3-35497" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" />
</ItemGroup>

View File

@ -18,6 +18,7 @@ using RabbitMQ.Client;
using System;
using HealthChecks.UI.Client;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.Extensions.Diagnostics.HealthChecks;
namespace Payment.API
{
@ -106,9 +107,10 @@ namespace Payment.API
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
});
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
app.Map("/liveness", lapp => lapp.Run(async ctx => ctx.Response.StatusCode = 200));
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
app.UseHealthChecks("/liveness", new HealthCheckOptions
{
Predicate = r => r.Name.Contains("self")
});
ConfigureEventBus(app);
}
@ -184,6 +186,8 @@ namespace Payment.API
{
var hcBuilder = services.AddHealthChecks();
hcBuilder.AddCheck("self", () => HealthCheckResult.Healthy());
if (configuration.GetValue<bool>("AzureServiceBusEnabled"))
{
hcBuilder

View File

@ -13,7 +13,7 @@ using Microsoft.eShopOnContainers.WebMVC.Services;
using Microsoft.eShopOnContainers.WebMVC.ViewModels;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.HealthChecks;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.Logging;
using Polly;
using Polly.Extensions.Http;
@ -78,10 +78,10 @@ namespace Microsoft.eShopOnContainers.WebMVC
app.UsePathBase(pathBase);
}
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
app.Map("/liveness", lapp => lapp.Run(async ctx => ctx.Response.StatusCode = 200));
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
app.UseHealthChecks("/liveness", new HealthCheckOptions
{
Predicate = r => r.Name.Contains("self")
});
app.UseSession();
app.UseStaticFiles();
@ -138,6 +138,7 @@ namespace Microsoft.eShopOnContainers.WebMVC
public static IServiceCollection AddHealthChecks(this IServiceCollection services, IConfiguration configuration)
{
services.AddHealthChecks()
.AddCheck("self", () => HealthCheckResult.Healthy())
.AddUrlGroup(new Uri(configuration["PurchaseUrlHC"]), name: "purchaseapigw-check", tags: new string[] { "purchaseapigw" })
.AddUrlGroup(new Uri(configuration["MarketingUrlHC"]), name: "marketingapigw-check", tags: new string[] { "marketingapigw" })
.AddUrlGroup(new Uri(configuration["IdentityUrlHC"]), name: "identityapi-check", tags: new string[] { "identityapi" });

View File

@ -27,6 +27,7 @@
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.6.1" />
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta8" />
<PackageReference Include="Microsoft.ApplicationInsights.ServiceFabric" Version="2.1.1-beta1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="2.2.0-preview3-35497" />
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.2.0-preview3-35497" />

View File

@ -16,6 +16,7 @@ using System.IO;
using WebSPA.Infrastructure;
using HealthChecks.UI.Client;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.Extensions.Diagnostics.HealthChecks;
namespace eShopConContainers.WebSPA
{
@ -44,6 +45,7 @@ namespace eShopConContainers.WebSPA
RegisterAppInsights(services);
services.AddHealthChecks()
.AddCheck("self", () => HealthCheckResult.Healthy())
.AddUrlGroup(new Uri(Configuration["PurchaseUrlHC"]), name: "purchaseapigw-check", tags: new string[] { "purchaseapigw" })
.AddUrlGroup(new Uri(Configuration["MarketingUrlHC"]), name: "marketingapigw-check", tags: new string[] { "marketingapigw" })
.AddUrlGroup(new Uri(Configuration["IdentityUrlHC"]), name: "identityapi-check", tags: new string[] { "identityapi" });
@ -87,6 +89,11 @@ namespace eShopConContainers.WebSPA
app.UseHsts();
}
app.UseHealthChecks("/liveness", new HealthCheckOptions
{
Predicate = r => r.Name.Contains("self")
});
app.UseHealthChecks("/hc", new HealthCheckOptions()
{
Predicate = _ => true,
@ -115,11 +122,6 @@ namespace eShopConContainers.WebSPA
app.UsePathBase(pathBase);
}
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
app.Map("/liveness", lapp => lapp.Run(async ctx => ctx.Response.StatusCode = 200));
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
app.Use(async (context, next) =>
{
await next();

View File

@ -91,6 +91,7 @@
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.6.1" />
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta8" />
<PackageReference Include="Microsoft.ApplicationInsights.ServiceFabric" Version="2.1.1-beta1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.2.0-preview3-35497" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection.Redis" Version="2.2.0-preview2-35157" />

View File

@ -1,17 +1,22 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using System.Threading.Tasks;
namespace WebStatus.Controllers
{
public class HomeController : Controller
{
public HomeController()
private IConfiguration _configuration;
public HomeController(IConfiguration configuration)
{
_configuration = configuration;
}
public IActionResult Index()
{
return Redirect("/hc-ui");
var basePath = _configuration["PATH_BASE"];
return Redirect($"{basePath}/hc-ui");
}
public IActionResult Error()

View File

@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.Logging;
namespace WebStatus
@ -26,6 +27,9 @@ namespace WebStatus
RegisterAppInsights(services);
services.AddOptions();
services.AddHealthChecks()
.AddCheck("self", () => HealthCheckResult.Healthy());
services.AddHealthChecksUI();
services.AddMvc()
@ -55,11 +59,15 @@ namespace WebStatus
app.UsePathBase(pathBase);
}
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
app.Map("/liveness", lapp => lapp.Run(async ctx => ctx.Response.StatusCode = 200));
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
app.UseHealthChecks("/liveness", new HealthCheckOptions
{
Predicate = r => r.Name.Contains("self")
});
app.UseHealthChecksUI(config => config.UIPath = "/hc-ui");
app.UseHealthChecksUI(config => {
config.ResourcesPath = string.IsNullOrEmpty(pathBase) ? "/ui/resources" : $"{pathBase}/ui/resources";
config.UIPath = "/hc-ui";
});
app.UseStaticFiles();

View File

@ -5,18 +5,22 @@
<DockerComposeProjectPath>..\..\..\docker-compose.dcproj</DockerComposeProjectPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AspNetCore.HealthChecks.UI" Version="2.2.0" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="2.2.0" />
<Compile Remove="Views\**" />
<Content Remove="Views\**" />
<EmbeddedResource Remove="Views\**" />
<None Remove="Views\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="AspNetCore.HealthChecks.UI" Version="2.2.8" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="2.2.2" />
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="2.2.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.2.1" />
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.6.1" />
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta8" />
<PackageReference Include="Microsoft.ApplicationInsights.ServiceFabric" Version="2.1.1-beta1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.2.0-preview3-35497" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="Views\" />
</ItemGroup>
</Project>