Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

Commit 7321d5e

Browse files
committed
Base path fix and k8s config updated
1 parent 0f1d904 commit 7321d5e

File tree

12 files changed

+89
-22
lines changed

12 files changed

+89
-22
lines changed

k8s/deployments.yaml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ spec:
1515
image: eshop/basket.api
1616
imagePullPolicy: Always
1717
env:
18-
- name: ASPNETCORE_URLS
19-
value: http://0.0.0.0:80/basket-api
18+
- name: PATH_BASE
19+
value: /basket-api
2020
- name: ConnectionString
2121
valueFrom:
2222
configMapKeyRef:
@@ -59,8 +59,8 @@ spec:
5959
image: eshop/catalog.api
6060
imagePullPolicy: Always
6161
env:
62-
- name: ASPNETCORE_URLS
63-
value: http://0.0.0.0:80/catalog-api
62+
- name: PATH_BASE
63+
value: /catalog-api
6464
- name: ConnectionString
6565
valueFrom:
6666
configMapKeyRef:
@@ -103,8 +103,8 @@ spec:
103103
image: eshop/identity.api
104104
imagePullPolicy: Always
105105
env:
106-
- name: ASPNETCORE_URLS
107-
value: http://0.0.0.0:80/identity
106+
- name: PATH_BASE
107+
value: /identity
108108
- name: ConnectionStrings__DefaultConnection
109109
valueFrom:
110110
configMapKeyRef:
@@ -169,8 +169,8 @@ spec:
169169
image: eshop/ordering.api
170170
imagePullPolicy: Always
171171
env:
172-
- name: ASPNETCORE_URLS
173-
value: http://0.0.0.0:80/ordering-api
172+
- name: PATH_BASE
173+
value: /ordering-api
174174
- name: ConnectionString
175175
valueFrom:
176176
configMapKeyRef:
@@ -213,8 +213,8 @@ spec:
213213
image: eshop/locations.api
214214
imagePullPolicy: Always
215215
env:
216-
- name: ASPNETCORE_URLS
217-
value: http://0.0.0.0:80/locations-api
216+
- name: PATH_BASE
217+
value: /locations-api
218218
- name: ConnectionString
219219
valueFrom:
220220
configMapKeyRef:
@@ -267,8 +267,8 @@ spec:
267267
image: eshop/marketing.api
268268
imagePullPolicy: Always
269269
env:
270-
- name: ASPNETCORE_URLS
271-
value: http://0.0.0.0:80/marketing-api
270+
- name: PATH_BASE
271+
value: /marketing-api
272272
- name: ConnectionString
273273
valueFrom:
274274
configMapKeyRef:
@@ -331,8 +331,8 @@ spec:
331331
image: eshop/payment.api
332332
imagePullPolicy: Always
333333
env:
334-
- name: ASPNETCORE_URLS
335-
value: http://0.0.0.0:80/payment-api
334+
- name: PATH_BASE
335+
value: /payment-api
336336
- name: AzureServiceBusEnabled
337337
valueFrom:
338338
configMapKeyRef:
@@ -365,8 +365,8 @@ spec:
365365
image: eshop/webmvc
366366
imagePullPolicy: Always
367367
env:
368-
- name: ASPNETCORE_URLS
369-
value: http://0.0.0.0:80/webmvc
368+
- name: PATH_BASE
369+
value: /webmvc
370370
- name: DPConnectionString
371371
valueFrom:
372372
configMapKeyRef:
@@ -426,8 +426,8 @@ spec:
426426
image: eshop/webstatus
427427
imagePullPolicy: Always
428428
env:
429-
- name: ASPNETCORE_URLS
430-
value: http://0.0.0.0:80/webstatus
429+
- name: PATH_BASE
430+
value: /webstatus
431431
- name: BasketUrl
432432
valueFrom:
433433
configMapKeyRef:

k8s/gen-k8s-env.ps1

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Param(
22
[parameter(Mandatory=$true)][string]$resourceGroupName,
33
[parameter(Mandatory=$true)][string]$location,
4-
[parameter(Mandatory=$true)][string]$registryName,
4+
[parameter(Mandatory=$false)][string]$registryName,
55
[parameter(Mandatory=$true)][string]$orchestratorName,
66
[parameter(Mandatory=$true)][string]$dnsName,
77
[parameter(Mandatory=$true)][string]$createAcr=$true
@@ -11,7 +11,7 @@
1111
Write-Host "Creating resource group..." -ForegroundColor Yellow
1212
az group create --name=$resourceGroupName --location=$location
1313

14-
if ($createAcr) {
14+
if ($createAcr -eq $true) {
1515
# Create Azure Container Registry
1616
Write-Host "Creating Azure Container Registry..." -ForegroundColor Yellow
1717
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
2424
# Retrieve kubernetes cluster configuration and save it under ~/.kube/config
2525
az acs kubernetes get-credentials --resource-group=$resourceGroupName --name=$orchestratorName
2626

27-
# Show ACR credentials
28-
az acr credential show -n $registryName
27+
if ($createAcr -eq $true) {
28+
# Show ACR credentials
29+
az acr credential show -n $registryName
30+
}

src/Services/Basket/Basket.API/Startup.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
169169
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
170170
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
171171
{
172+
173+
var pathBase = Configuration["PATH_BASE"];
174+
if (!string.IsNullOrEmpty(pathBase))
175+
{
176+
app.UsePathBase(pathBase);
177+
}
172178
app.UseStaticFiles();
173179
app.UseCors("CorsPolicy");
174180

src/Services/Catalog/Catalog.API/Startup.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,13 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
167167
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
168168
loggerFactory.AddDebug();
169169

170+
var pathBase = Configuration["PATH_BASE"];
171+
if (!string.IsNullOrEmpty(pathBase))
172+
{
173+
loggerFactory.CreateLogger("init").LogDebug($"Using PATH BASE '{pathBase}'");
174+
app.UsePathBase(pathBase);
175+
}
176+
170177
app.UseCors("CorsPolicy");
171178

172179
app.UseMvcWithDefaultRoute();

src/Services/Identity/Identity.API/Startup.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,13 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
125125
app.UseExceptionHandler("/Home/Error");
126126
}
127127

128+
var pathBase = Configuration["PATH_BASE"];
129+
if (!string.IsNullOrEmpty(pathBase))
130+
{
131+
loggerFactory.CreateLogger("init").LogDebug($"Using PATH BASE '{pathBase}'");
132+
app.UsePathBase(pathBase);
133+
}
134+
128135
app.UseStaticFiles();
129136

130137

src/Services/Location/Locations.API/Startup.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
141141
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
142142
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
143143
{
144+
var pathBase = Configuration["PATH_BASE"];
145+
if (!string.IsNullOrEmpty(pathBase))
146+
{
147+
app.UsePathBase(pathBase);
148+
}
149+
144150
app.UseCors("CorsPolicy");
145151

146152
ConfigureAuth(app);

src/Services/Marketing/Marketing.API/Startup.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,12 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
173173
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
174174
public void Configure(IApplicationBuilder app, IHostingEnvironment env,ILoggerFactory loggerFactory)
175175
{
176+
var pathBase = Configuration["PATH_BASE"];
177+
if (!string.IsNullOrEmpty(pathBase))
178+
{
179+
app.UsePathBase(pathBase);
180+
}
181+
176182
app.UseCors("CorsPolicy");
177183

178184
ConfigureAuth(app);

src/Services/Ordering/Ordering.API/Startup.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,13 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
189189
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
190190
loggerFactory.AddDebug();
191191

192+
var pathBase = Configuration["PATH_BASE"];
193+
if (!string.IsNullOrEmpty(pathBase))
194+
{
195+
loggerFactory.CreateLogger("init").LogDebug($"Using PATH BASE '{pathBase}'");
196+
app.UsePathBase(pathBase);
197+
}
198+
192199
app.UseCors("CorsPolicy");
193200

194201
ConfigureAuth(app);

src/Services/Payment/Payment.API/Startup.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
9292
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
9393
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
9494
{
95+
var pathBase = Configuration["PATH_BASE"];
96+
if (!string.IsNullOrEmpty(pathBase))
97+
{
98+
app.UsePathBase(pathBase);
99+
}
100+
95101
app.UseMvcWithDefaultRoute();
96102

97103
app.UseSwagger()

src/Web/WebMVC/Startup.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
123123
app.UseExceptionHandler("/Error");
124124
}
125125

126+
var pathBase = Configuration["PATH_BASE"];
127+
if (!string.IsNullOrEmpty(pathBase))
128+
{
129+
loggerFactory.CreateLogger("init").LogDebug($"Using PATH BASE '{pathBase}'");
130+
app.UsePathBase(pathBase);
131+
}
132+
126133
app.UseSession();
127134
app.UseStaticFiles();
128135

0 commit comments

Comments
 (0)