diff --git a/k8s/deployments.yaml b/k8s/deployments.yaml index 59e37de90..e542e8924 100644 --- a/k8s/deployments.yaml +++ b/k8s/deployments.yaml @@ -15,8 +15,8 @@ spec: image: eshop/basket.api imagePullPolicy: Always env: - - name: ASPNETCORE_URLS - value: http://0.0.0.0:80/basket-api + - name: PATH_BASE + value: /basket-api - name: ConnectionString valueFrom: configMapKeyRef: @@ -59,8 +59,8 @@ spec: image: eshop/catalog.api imagePullPolicy: Always env: - - name: ASPNETCORE_URLS - value: http://0.0.0.0:80/catalog-api + - name: PATH_BASE + value: /catalog-api - name: ConnectionString valueFrom: configMapKeyRef: @@ -103,8 +103,8 @@ spec: image: eshop/identity.api imagePullPolicy: Always env: - - name: ASPNETCORE_URLS - value: http://0.0.0.0:80/identity + - name: PATH_BASE + value: /identity - name: ConnectionStrings__DefaultConnection valueFrom: configMapKeyRef: @@ -169,8 +169,8 @@ spec: image: eshop/ordering.api imagePullPolicy: Always env: - - name: ASPNETCORE_URLS - value: http://0.0.0.0:80/ordering-api + - name: PATH_BASE + value: /ordering-api - name: ConnectionString valueFrom: configMapKeyRef: @@ -213,8 +213,8 @@ spec: image: eshop/locations.api imagePullPolicy: Always env: - - name: ASPNETCORE_URLS - value: http://0.0.0.0:80/locations-api + - name: PATH_BASE + value: /locations-api - name: ConnectionString valueFrom: configMapKeyRef: @@ -267,8 +267,8 @@ spec: image: eshop/marketing.api imagePullPolicy: Always env: - - name: ASPNETCORE_URLS - value: http://0.0.0.0:80/marketing-api + - name: PATH_BASE + value: /marketing-api - name: ConnectionString valueFrom: configMapKeyRef: @@ -331,8 +331,8 @@ spec: image: eshop/payment.api imagePullPolicy: Always env: - - name: ASPNETCORE_URLS - value: http://0.0.0.0:80/payment-api + - name: PATH_BASE + value: /payment-api - name: AzureServiceBusEnabled valueFrom: configMapKeyRef: @@ -365,8 +365,8 @@ spec: image: eshop/webmvc imagePullPolicy: Always env: - - name: ASPNETCORE_URLS - value: http://0.0.0.0:80/webmvc + - name: PATH_BASE + value: /webmvc - name: DPConnectionString valueFrom: configMapKeyRef: @@ -426,8 +426,8 @@ spec: image: eshop/webstatus imagePullPolicy: Always env: - - name: ASPNETCORE_URLS - value: http://0.0.0.0:80/webstatus + - name: PATH_BASE + value: /webstatus - name: BasketUrl valueFrom: configMapKeyRef: diff --git a/k8s/gen-k8s-env.ps1 b/k8s/gen-k8s-env.ps1 index c3b82469c..5276262f5 100644 --- a/k8s/gen-k8s-env.ps1 +++ b/k8s/gen-k8s-env.ps1 @@ -1,7 +1,7 @@ Param( [parameter(Mandatory=$true)][string]$resourceGroupName, [parameter(Mandatory=$true)][string]$location, - [parameter(Mandatory=$true)][string]$registryName, + [parameter(Mandatory=$false)][string]$registryName, [parameter(Mandatory=$true)][string]$orchestratorName, [parameter(Mandatory=$true)][string]$dnsName, [parameter(Mandatory=$true)][string]$createAcr=$true @@ -11,7 +11,7 @@ Write-Host "Creating resource group..." -ForegroundColor Yellow az group create --name=$resourceGroupName --location=$location -if ($createAcr) { +if ($createAcr -eq $true) { # Create Azure Container Registry Write-Host "Creating Azure Container Registry..." -ForegroundColor Yellow az acr create -n $registryName -g $resourceGroupName -l $location --admin-enabled true --sku Basic @@ -24,5 +24,7 @@ az acs create --orchestrator-type=kubernetes --resource-group $resourceGroupName # Retrieve kubernetes cluster configuration and save it under ~/.kube/config az acs kubernetes get-credentials --resource-group=$resourceGroupName --name=$orchestratorName -# Show ACR credentials -az acr credential show -n $registryName \ No newline at end of file +if ($createAcr -eq $true) { + # Show ACR credentials + az acr credential show -n $registryName +} \ No newline at end of file diff --git a/src/Services/Basket/Basket.API/Startup.cs b/src/Services/Basket/Basket.API/Startup.cs index 1f62e44cb..df079e4e6 100644 --- a/src/Services/Basket/Basket.API/Startup.cs +++ b/src/Services/Basket/Basket.API/Startup.cs @@ -169,6 +169,12 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { + + var pathBase = Configuration["PATH_BASE"]; + if (!string.IsNullOrEmpty(pathBase)) + { + app.UsePathBase(pathBase); + } app.UseStaticFiles(); app.UseCors("CorsPolicy"); diff --git a/src/Services/Catalog/Catalog.API/Startup.cs b/src/Services/Catalog/Catalog.API/Startup.cs index 354d0643e..21b9ae1c8 100644 --- a/src/Services/Catalog/Catalog.API/Startup.cs +++ b/src/Services/Catalog/Catalog.API/Startup.cs @@ -167,6 +167,13 @@ loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); + var pathBase = Configuration["PATH_BASE"]; + if (!string.IsNullOrEmpty(pathBase)) + { + loggerFactory.CreateLogger("init").LogDebug($"Using PATH BASE '{pathBase}'"); + app.UsePathBase(pathBase); + } + app.UseCors("CorsPolicy"); app.UseMvcWithDefaultRoute(); diff --git a/src/Services/Identity/Identity.API/Startup.cs b/src/Services/Identity/Identity.API/Startup.cs index edd02d0a1..c4ee28f25 100644 --- a/src/Services/Identity/Identity.API/Startup.cs +++ b/src/Services/Identity/Identity.API/Startup.cs @@ -125,6 +125,13 @@ namespace eShopOnContainers.Identity app.UseExceptionHandler("/Home/Error"); } + var pathBase = Configuration["PATH_BASE"]; + if (!string.IsNullOrEmpty(pathBase)) + { + loggerFactory.CreateLogger("init").LogDebug($"Using PATH BASE '{pathBase}'"); + app.UsePathBase(pathBase); + } + app.UseStaticFiles(); diff --git a/src/Services/Location/Locations.API/Startup.cs b/src/Services/Location/Locations.API/Startup.cs index 4b92afa02..b2147cbd1 100644 --- a/src/Services/Location/Locations.API/Startup.cs +++ b/src/Services/Location/Locations.API/Startup.cs @@ -141,6 +141,12 @@ namespace Microsoft.eShopOnContainers.Services.Locations.API // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { + var pathBase = Configuration["PATH_BASE"]; + if (!string.IsNullOrEmpty(pathBase)) + { + app.UsePathBase(pathBase); + } + app.UseCors("CorsPolicy"); ConfigureAuth(app); diff --git a/src/Services/Marketing/Marketing.API/Startup.cs b/src/Services/Marketing/Marketing.API/Startup.cs index 37d6911c1..bac62095f 100644 --- a/src/Services/Marketing/Marketing.API/Startup.cs +++ b/src/Services/Marketing/Marketing.API/Startup.cs @@ -173,6 +173,12 @@ // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env,ILoggerFactory loggerFactory) { + var pathBase = Configuration["PATH_BASE"]; + if (!string.IsNullOrEmpty(pathBase)) + { + app.UsePathBase(pathBase); + } + app.UseCors("CorsPolicy"); ConfigureAuth(app); diff --git a/src/Services/Ordering/Ordering.API/Startup.cs b/src/Services/Ordering/Ordering.API/Startup.cs index 2d2f94423..1bf2fd22c 100644 --- a/src/Services/Ordering/Ordering.API/Startup.cs +++ b/src/Services/Ordering/Ordering.API/Startup.cs @@ -189,6 +189,13 @@ loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); + var pathBase = Configuration["PATH_BASE"]; + if (!string.IsNullOrEmpty(pathBase)) + { + loggerFactory.CreateLogger("init").LogDebug($"Using PATH BASE '{pathBase}'"); + app.UsePathBase(pathBase); + } + app.UseCors("CorsPolicy"); ConfigureAuth(app); diff --git a/src/Services/Payment/Payment.API/Startup.cs b/src/Services/Payment/Payment.API/Startup.cs index c4ab2c322..e4378dcef 100644 --- a/src/Services/Payment/Payment.API/Startup.cs +++ b/src/Services/Payment/Payment.API/Startup.cs @@ -92,6 +92,12 @@ namespace Payment.API // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { + var pathBase = Configuration["PATH_BASE"]; + if (!string.IsNullOrEmpty(pathBase)) + { + app.UsePathBase(pathBase); + } + app.UseMvcWithDefaultRoute(); app.UseSwagger() diff --git a/src/Web/WebMVC/Startup.cs b/src/Web/WebMVC/Startup.cs index 8b10c1ecc..58fae38f9 100644 --- a/src/Web/WebMVC/Startup.cs +++ b/src/Web/WebMVC/Startup.cs @@ -123,6 +123,13 @@ namespace Microsoft.eShopOnContainers.WebMVC app.UseExceptionHandler("/Error"); } + var pathBase = Configuration["PATH_BASE"]; + if (!string.IsNullOrEmpty(pathBase)) + { + loggerFactory.CreateLogger("init").LogDebug($"Using PATH BASE '{pathBase}'"); + app.UsePathBase(pathBase); + } + app.UseSession(); app.UseStaticFiles(); diff --git a/src/Web/WebSPA/Startup.cs b/src/Web/WebSPA/Startup.cs index 1659af537..15c27da42 100644 --- a/src/Web/WebSPA/Startup.cs +++ b/src/Web/WebSPA/Startup.cs @@ -95,6 +95,13 @@ namespace eShopConContainers.WebSPA //Seed Data WebContextSeed.Seed(app, env, loggerFactory); + var pathBase = Configuration["PATH_BASE"]; + if (!string.IsNullOrEmpty(pathBase)) + { + loggerFactory.CreateLogger("init").LogDebug($"Using PATH BASE '{pathBase}'"); + app.UsePathBase(pathBase); + } + app.Use(async (context, next) => { await next(); diff --git a/src/Web/WebStatus/Startup.cs b/src/Web/WebStatus/Startup.cs index eb559acd9..167a01baa 100644 --- a/src/Web/WebStatus/Startup.cs +++ b/src/Web/WebStatus/Startup.cs @@ -60,6 +60,12 @@ namespace WebStatus app.UseExceptionHandler("/Home/Error"); } + var pathBase = Configuration["PATH_BASE"]; + if (!string.IsNullOrEmpty(pathBase)) + { + app.UsePathBase(pathBase); + } + app.UseStaticFiles(); app.UseMvc(routes =>