Browse Source

Merge branch 'main' into tracks-and-sessions

pull/79/head
Halil İbrahim Kalkan 5 years ago
parent
commit
c914c42fbd
  1. 37
      etc/azure/deploy-to-k8s.yml
  2. 37
      etc/azure/scripts/push-images.ps1
  3. 5
      etc/k8s/helm-chart/deploy-azure.ps1
  4. 4
      etc/k8s/helm-chart/deploy-staging.ps1
  5. 2
      etc/k8s/helm-chart/eventhub/charts/account/templates/account.yaml
  6. 2
      etc/k8s/helm-chart/eventhub/charts/admin-api/templates/admin-api.yaml
  7. 2
      etc/k8s/helm-chart/eventhub/charts/admin/templates/admin.yaml
  8. 2
      etc/k8s/helm-chart/eventhub/charts/api/templates/api.yaml
  9. 19
      etc/k8s/helm-chart/eventhub/charts/background-services/templates/background-services.yaml
  10. 2
      etc/k8s/helm-chart/eventhub/charts/dbmigrator/templates/migrator.yaml
  11. 2
      etc/k8s/helm-chart/eventhub/charts/www/templates/www.yaml
  12. 1
      etc/k8s/helm-chart/eventhub/values.azure.yaml
  13. 1
      etc/k8s/helm-chart/eventhub/values.yaml
  14. 16
      etc/k8s/scripts/build-images.ps1
  15. 4
      src/EventHub.Admin.HttpApi.Host/EventHubAdminHttpApiHostModule.cs
  16. 60
      src/EventHub.Domain.Shared/Web/EventHubUrlOptions.cs
  17. 4
      src/EventHub.HttpApi.Host/EventHubHttpApiHostModule.cs
  18. 21
      src/EventHub.IdentityServer/EventHubIdentityServerModule.cs
  19. 4
      src/EventHub.Web/EventHubWebModule.cs
  20. 2
      src/EventHub.Web/Menus/EventHubMenuContributor.cs
  21. 8
      src/EventHub.Web/Pages/Index.cshtml

37
etc/azure/deploy-to-k8s.yml

@ -1,15 +1,46 @@
variables:
version: $(Build.BuildId)
trigger: none
pool:
vmImage: 'windows-latest'
vmImage: 'ubuntu-latest'
steps:
- task: PowerShell@2
displayName: Build docker images
inputs:
filePath: 'etc/k8s/scripts/build-images.ps1'
arguments: '-version $(version)'
- task: Docker@2
displayName: Login to ACR
inputs:
containerRegistry: 'volocr'
command: 'login'
- task: PowerShell@2
displayName: Push images to ACR
inputs:
filePath: 'etc/azure/scripts/push-images.ps1'
arguments: '-version $(version)'
- task: Kubernetes@1
displayName: Delete migrator job
continueOnError: true
inputs:
connectionType: 'Azure Resource Manager'
azureSubscriptionEndpoint: 'volosoft (fe02ef9f-9e1c-4e40-b924-505981688dd8)'
azureResourceGroup: 'volo'
kubernetesCluster: 'volo'
namespace: 'eventhub'
command: 'delete'
arguments: 'job eh-az-dbmigrator'
secretType: 'dockerRegistry'
containerRegistryType: 'Azure Container Registry'
- task: HelmDeploy@0
displayName: Helm deploy
inputs:
connectionType: 'Azure Resource Manager'
azureSubscription: 'volosoft(fe02ef9f-9e1c-4e40-b924-505981688dd8)'
@ -19,7 +50,7 @@ steps:
namespace: 'eventhub'
command: 'upgrade'
chartType: 'Name'
chartName: 'eventhub'
chartName: 'etc/k8s/helm-chart/eventhub'
releaseName: 'eh-az'
valueFile: 'etc/k8s/helm-chart/eventhub/values.azure.yaml'
arguments: '--namespace eventhub --create-namespace'
arguments: '--namespace eventhub --create-namespace --set global.eventHubImageVersion=$(version)'

37
etc/azure/scripts/push-images.ps1

@ -1,22 +1,31 @@
param ($version='latest')
az acr login --name volocr
docker tag eventhub.dbmigrator:latest volocr.azurecr.io/eventhub.dbmigrator:latest
docker push volocr.azurecr.io/eventhub.dbmigrator:latest
docker tag eventhub.dbmigrator:$version volocr.azurecr.io/eventhub.dbmigrator:$version
docker push volocr.azurecr.io/eventhub.dbmigrator:$version
docker tag volocr.azurecr.io/eventhub.dbmigrator:$version volocr.azurecr.io/eventhub.dbmigrator:latest
docker tag eventhub.www:latest volocr.azurecr.io/eventhub.www:latest
docker push volocr.azurecr.io/eventhub.www:latest
docker tag eventhub.www:$version volocr.azurecr.io/eventhub.www:$version
docker push volocr.azurecr.io/eventhub.www:$version
docker tag volocr.azurecr.io/eventhub.www:$version volocr.azurecr.io/eventhub.www:latest
docker tag eventhub.api:latest volocr.azurecr.io/eventhub.api:latest
docker push volocr.azurecr.io/eventhub.api:latest
docker tag eventhub.api:$version volocr.azurecr.io/eventhub.api:$version
docker push volocr.azurecr.io/eventhub.api:$version
docker tag volocr.azurecr.io/eventhub.api:$version volocr.azurecr.io/eventhub.api:latest
docker tag eventhub.admin:latest volocr.azurecr.io/eventhub.admin:latest
docker push volocr.azurecr.io/eventhub.admin:latest
docker tag eventhub.admin:$version volocr.azurecr.io/eventhub.admin:$version
docker push volocr.azurecr.io/eventhub.admin:$version
docker tag volocr.azurecr.io/eventhub.admin:$version volocr.azurecr.io/eventhub.admin:latest
docker tag eventhub.admin-api:latest volocr.azurecr.io/eventhub.admin-api:latest
docker push volocr.azurecr.io/eventhub.admin-api:latest
docker tag eventhub.admin-api:$version volocr.azurecr.io/eventhub.admin-api:$version
docker push volocr.azurecr.io/eventhub.admin-api:$version
docker tag volocr.azurecr.io/eventhub.admin-api:$version volocr.azurecr.io/eventhub.admin-api:latest
docker tag eventhub.account:latest volocr.azurecr.io/eventhub.account:latest
docker push volocr.azurecr.io/eventhub.account:latest
docker tag eventhub.account:$version volocr.azurecr.io/eventhub.account:$version
docker push volocr.azurecr.io/eventhub.account:$version
docker tag volocr.azurecr.io/eventhub.account:$version volocr.azurecr.io/eventhub.account:latest
docker tag eventhub.background-services:latest volocr.azurecr.io/eventhub.background-services:latest
docker push volocr.azurecr.io/eventhub.background-services:latest
docker tag eventhub.background-services:$version volocr.azurecr.io/eventhub.background-services:$version
docker push volocr.azurecr.io/eventhub.background-services:$version
docker tag volocr.azurecr.io/eventhub.background-services:$version volocr.azurecr.io/eventhub.background-services:latest

5
etc/k8s/helm-chart/deploy-azure.ps1

@ -1 +1,4 @@
helm upgrade --install eh-az eventhub -f .\eventhub\values.azure.yaml --namespace eventhub --create-namespace
param ($version='latest')
kubectl delete job eh-az-dbmigrator
helm upgrade --install eh-az eventhub -f .\eventhub\values.azure.yaml --namespace eventhub --create-namespace --set global.eventHubImageVersion=$version

4
etc/k8s/helm-chart/deploy-staging.ps1

@ -0,0 +1,4 @@
param ($version='latest')
kubectl delete job eh-st-dbmigrator
helm upgrade --install eh-st eventhub --namespace eventhub --create-namespace --set global.eventHubImageVersion=$version

2
etc/k8s/helm-chart/eventhub/charts/account/templates/account.yaml

@ -12,7 +12,7 @@ spec:
app: {{ .Release.Name }}-{{ .Chart.Name }}
spec:
containers:
- image: {{ .Values.containerImage }}
- image: {{ .Values.containerImage }}:{{ .Values.global.eventHubImageVersion }}
imagePullPolicy: {{ .Values.global.imagePullPolicy }}
name: {{ .Release.Name }}-{{ .Chart.Name }}
ports:

2
etc/k8s/helm-chart/eventhub/charts/admin-api/templates/admin-api.yaml

@ -12,7 +12,7 @@ spec:
app: {{ .Release.Name }}-{{ .Chart.Name }}
spec:
containers:
- image: {{ .Values.containerImage }}
- image: {{ .Values.containerImage }}:{{ .Values.global.eventHubImageVersion }}
imagePullPolicy: {{ .Values.global.imagePullPolicy }}
name: {{ .Release.Name }}-{{ .Chart.Name }}
ports:

2
etc/k8s/helm-chart/eventhub/charts/admin/templates/admin.yaml

@ -12,7 +12,7 @@ spec:
app: {{ .Release.Name }}-{{ .Chart.Name }}
spec:
containers:
- image: {{ .Values.containerImage }}
- image: {{ .Values.containerImage }}:{{ .Values.global.eventHubImageVersion }}
imagePullPolicy: {{ .Values.global.imagePullPolicy }}
name: {{ .Release.Name }}-{{ .Chart.Name }}
ports:

2
etc/k8s/helm-chart/eventhub/charts/api/templates/api.yaml

@ -12,7 +12,7 @@ spec:
app: {{ .Release.Name }}-{{ .Chart.Name }}
spec:
containers:
- image: {{ .Values.containerImage }}
- image: {{ .Values.containerImage }}:{{ .Values.global.eventHubImageVersion }}
imagePullPolicy: {{ .Values.global.imagePullPolicy }}
name: {{ .Release.Name }}-{{ .Chart.Name }}
ports:

19
etc/k8s/helm-chart/eventhub/charts/background-services/templates/background-services.yaml

@ -1,18 +1,21 @@
apiVersion: batch/v1
kind: Job
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}-{{ .Chart.Name }}
spec:
activeDeadlineSeconds: 180
selector:
matchLabels:
app: {{ .Release.Name }}-{{ .Chart.Name }}
template:
metadata:
labels:
app: {{ .Release.Name }}-{{ .Chart.Name }}
spec:
containers:
- name: {{ .Release.Name }}-{{ .Chart.Name }}
image: {{ .Values.containerImage }}
- image: {{ .Values.containerImage }}:{{ .Values.global.eventHubImageVersion }}
imagePullPolicy: {{ .Values.global.imagePullPolicy }}
name: {{ .Release.Name }}-{{ .Chart.Name }}
env:
{{ include "eventhub.global.env" . | indent 8 }}
- name: "ConnectionStrings__Default"
value: {{ .Values.global.defaultConnString }}
restartPolicy: Never
backoffLimit: 10
value: {{ .Values.global.defaultConnString }}

2
etc/k8s/helm-chart/eventhub/charts/dbmigrator/templates/migrator.yaml

@ -8,7 +8,7 @@ spec:
spec:
containers:
- name: {{ .Release.Name }}-{{ .Chart.Name }}
image: {{ .Values.containerImage }}
image: {{ .Values.containerImage }}:{{ .Values.global.eventHubImageVersion }}
imagePullPolicy: {{ .Values.global.imagePullPolicy }}
env:
{{ include "eventhub.global.env" . | indent 8 }}

2
etc/k8s/helm-chart/eventhub/charts/www/templates/www.yaml

@ -12,7 +12,7 @@ spec:
app: {{ .Release.Name }}-{{ .Chart.Name }}
spec:
containers:
- image: {{ .Values.containerImage }}
- image: {{ .Values.containerImage }}:{{ .Values.global.eventHubImageVersion }}
imagePullPolicy: {{ .Values.global.imagePullPolicy }}
name: {{ .Release.Name }}-{{ .Chart.Name }}
ports:

1
etc/k8s/helm-chart/eventhub/values.azure.yaml

@ -19,6 +19,7 @@ global:
internalAuthServerRequireHttpsMetadata: "false"
stringEncryptionDefaultPassPhrase: "TxVIZFPxK33czbbv"
imagePullPolicy: Always
eventHubImageVersion: latest
account:
containerImage: "volocr.azurecr.io/eventhub.account"
api:

1
etc/k8s/helm-chart/eventhub/values.yaml

@ -19,6 +19,7 @@ global:
internalAuthServerRequireHttpsMetadata: "false"
stringEncryptionDefaultPassPhrase: "TxVIZFPxK33czbbv"
imagePullPolicy: Never
eventHubImageVersion: latest
account:
containerImage: "eventhub.account"
api:

16
etc/k8s/scripts/build-images.ps1

@ -1,3 +1,5 @@
param ($version='latest')
$currentFolder = $PSScriptRoot
$slnFolder = Join-Path $currentFolder "../../../"
$dbmigratorFolder = Join-Path $slnFolder "src/EventHub.DbMigrator"
@ -13,49 +15,49 @@ $backgroundServicesFolder = Join-Path $slnFolder "src/EventHub.BackgroundService
Write-Host "*** BUILDING DB MIGRATOR ****************" -ForegroundColor Green
Set-Location $dbmigratorFolder
dotnet publish -c Release
docker build -t eventhub.dbmigrator .
docker build -t eventhub.dbmigrator:$version .
### WEB (WWW)
Write-Host "*** BUILDING WEB (WWW) ****************" -ForegroundColor Green
Set-Location $webFolder
dotnet publish -c Release
docker build -t eventhub.www .
docker build -t eventhub.www:$version .
### API
Write-Host "*** BUILDING API ****************" -ForegroundColor Green
Set-Location $apiFolder
dotnet publish -c Release
docker build -t eventhub.api .
docker build -t eventhub.api:$version .
### ADMIN (BLAZOR)
Write-Host "*** BUILDING ADMIN (BLAZOR) ****************" -ForegroundColor Green
Set-Location $adminFolder
dotnet publish -c Release
docker build -t eventhub.admin .
docker build -t eventhub.admin:$version .
### ADMIN API
Write-Host "*** BUILDING ADMIN API ****************" -ForegroundColor Green
Set-Location $adminApiFolder
dotnet publish -c Release
docker build -t eventhub.admin-api .
docker build -t eventhub.admin-api:$version .
### IDENTITY SERVER (ACCOUNT)
Write-Host "*** BUILDING IDENTITY SERVER (ACCOUNT) ****************" -ForegroundColor Green
Set-Location $identityServerFolder
dotnet publish -c Release
docker build -t eventhub.account .
docker build -t eventhub.account:$version .
### BACKGROUND SERVICES
Write-Host "*** BUILDING BACKGROUND SERVICES ****************" -ForegroundColor Green
Set-Location $backgroundServicesFolder
dotnet publish -c Release
docker build -t eventhub.background-services .
docker build -t eventhub.background-services:$version .
### ALL COMPLETED

4
src/EventHub.Admin.HttpApi.Host/EventHubAdminHttpApiHostModule.cs

@ -112,7 +112,7 @@ namespace EventHub.Admin
private static void ConfigureSwaggerServices(ServiceConfigurationContext context, IConfiguration configuration)
{
context.Services.AddAbpSwaggerGenWithOAuth(
configuration[EventHubUrlOptions.GetAccountConfigKey()],
EventHubUrlOptions.GetAccountConfigValue(configuration),
new Dictionary<string, string>
{
{"EventHubAdmin", "EventHub Admin API"}
@ -151,7 +151,7 @@ namespace EventHub.Admin
{
builder
.WithOrigins(
configuration[EventHubUrlOptions.GetAdminConfigKey()]
EventHubUrlOptions.GetAdminConfigValue(configuration)
)
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()

60
src/EventHub.Domain.Shared/Web/EventHubUrlOptions.cs

@ -1,49 +1,65 @@
namespace EventHub.Web
using Microsoft.Extensions.Configuration;
namespace EventHub.Web
{
public class EventHubUrlOptions
{
private const string ConfigurationName = "AppUrls";
private const string AccountDefaultValue = "https://localhost:44313";
private const string AdminDefaultValue = "https://localhost:44307";
private const string WwwDefaultValue = "https://localhost:44308";
private const string ApiDefaultValue = "https://localhost:44362";
private const string ApiInternalDefaultValue = ApiDefaultValue;
private const string AdminApiDefaultValue = "https://localhost:44305";
public string Account { get; set; } = "https://localhost:44313";
public string Www { get; set; } = "https://localhost:44308";
public string Api { get; set; } = "https://localhost:44362";
public string ApiInternal { get; set; } = "https://localhost:44362";
public string Admin { get; set; } = "https://localhost:44307";
public string AdminApi { get; set; } = "https://localhost:44305";
public string Account { get; set; } = AccountDefaultValue;
public string Www { get; set; } = WwwDefaultValue;
public string Api { get; set; } = ApiDefaultValue;
public string ApiInternal { get; set; } = ApiInternalDefaultValue;
public string Admin { get; set; } = AdminDefaultValue;
public string AdminApi { get; set; } = AdminApiDefaultValue;
public static string GetAccountConfigKey()
public static string GetAccountConfigValue(IConfiguration configuration)
{
return GetConfigKey(nameof(Account));
return GetConfigValue(configuration, nameof(Account), AccountDefaultValue);
}
public static string GetWwwConfigKey()
public static string GetWwwConfigValue(IConfiguration configuration)
{
return GetConfigKey(nameof(Www));
return GetConfigValue(configuration, nameof(Www), WwwDefaultValue);
}
public static string GetApiInternalConfigKey()
public static string GetApiInternalConfigValue(IConfiguration configuration)
{
return GetConfigKey(nameof(ApiInternal));
return GetConfigValue(configuration, nameof(ApiInternal), ApiInternalDefaultValue);
}
public static string GetApiConfigKey()
public static string GetApiConfigValue(IConfiguration configuration)
{
return GetConfigKey(nameof(Api));
return GetConfigValue(configuration, nameof(Api), ApiDefaultValue);
}
public static string GetAdminConfigKey()
public static string GetAdminConfigValue(IConfiguration configuration)
{
return GetConfigKey(nameof(Admin));
return GetConfigValue(configuration, nameof(Admin), AdminDefaultValue);
}
public static string GetAdminApiConfigKey()
public static string GetAdminApiConfigValue(IConfiguration configuration)
{
return GetConfigKey(nameof(AdminApi));
return GetConfigValue(configuration, nameof(AdminApi), AdminApiDefaultValue);
}
private static string GetConfigKey(string appName)
{
return $"{ConfigurationName}:{appName}";
}
private static string GetConfigValue(
IConfiguration configuration,
string appName,
string defaultValue)
{
return configuration[GetConfigKey(appName)] ?? defaultValue;
}
}
}

4
src/EventHub.HttpApi.Host/EventHubHttpApiHostModule.cs

@ -114,7 +114,7 @@ namespace EventHub
private static void ConfigureSwaggerServices(ServiceConfigurationContext context, IConfiguration configuration)
{
context.Services.AddAbpSwaggerGenWithOAuth(
configuration[EventHubUrlOptions.GetAccountConfigKey()],
EventHubUrlOptions.GetAccountConfigValue(configuration),
new Dictionary<string, string>
{
{"EventHub", "EventHub API"}
@ -153,7 +153,7 @@ namespace EventHub
{
builder
.WithOrigins(
configuration[EventHubUrlOptions.GetWwwConfigKey()]
EventHubUrlOptions.GetWwwConfigValue(configuration)
)
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()

21
src/EventHub.IdentityServer/EventHubIdentityServerModule.cs

@ -118,7 +118,7 @@ namespace EventHub
Configure<IdentityServerOptions>(options =>
{
options.IssuerUri = configuration[EventHubUrlOptions.GetAccountConfigKey()];
options.IssuerUri = EventHubUrlOptions.GetAccountConfigValue(configuration);
});
if (hostingEnvironment.IsDevelopment())
@ -133,14 +133,13 @@ namespace EventHub
Configure<AppUrlOptions>(options =>
{
options.Applications["MVC"].RootUrl = configuration[EventHubUrlOptions.GetAccountConfigKey()];
options.Applications["MVC"].RootUrl = EventHubUrlOptions.GetAccountConfigValue(configuration);
options.RedirectAllowedUrls.AddRange(
new[]
{
configuration[EventHubUrlOptions.GetWwwConfigKey()],
configuration[EventHubUrlOptions.GetAdminConfigKey()],
configuration[EventHubUrlOptions.GetApiConfigKey()],
configuration[EventHubUrlOptions.GetAdminApiConfigKey()]
EventHubUrlOptions.GetWwwConfigValue(configuration),
EventHubUrlOptions.GetApiConfigValue(configuration),
EventHubUrlOptions.GetAdminApiConfigValue(configuration)
});
});
@ -165,10 +164,10 @@ namespace EventHub
{
builder
.WithOrigins(
configuration[EventHubUrlOptions.GetWwwConfigKey()],
configuration[EventHubUrlOptions.GetApiConfigKey()],
configuration[EventHubUrlOptions.GetAdminConfigKey()],
configuration[EventHubUrlOptions.GetAdminApiConfigKey()]
EventHubUrlOptions.GetWwwConfigValue(configuration),
EventHubUrlOptions.GetApiConfigValue(configuration),
EventHubUrlOptions.GetAdminConfigValue(configuration),
EventHubUrlOptions.GetAdminApiConfigValue(configuration)
)
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
@ -191,7 +190,7 @@ namespace EventHub
{
if (ctx.Request.Headers.ContainsKey("from-ingress"))
{
ctx.SetIdentityServerOrigin(configuration[EventHubUrlOptions.GetAccountConfigKey()]);
ctx.SetIdentityServerOrigin(EventHubUrlOptions.GetAccountConfigValue(configuration));
}
await next();

4
src/EventHub.Web/EventHubWebModule.cs

@ -112,13 +112,13 @@ namespace EventHub.Web
{
Configure<AppUrlOptions>(options =>
{
options.Applications["MVC"].RootUrl = configuration[EventHubUrlOptions.GetWwwConfigKey()];
options.Applications["MVC"].RootUrl = EventHubUrlOptions.GetWwwConfigValue(configuration);
});
Configure<AbpRemoteServiceOptions>(options =>
{
options.RemoteServices.Default = new RemoteServiceConfiguration(
configuration[EventHubUrlOptions.GetApiInternalConfigKey()]
EventHubUrlOptions.GetApiInternalConfigValue(configuration)
.EnsureEndsWith('/')
);
});

2
src/EventHub.Web/Menus/EventHubMenuContributor.cs

@ -51,7 +51,7 @@ namespace EventHub.Web.Menus
if (currentUser.IsAuthenticated)
{
context.Menu.AddItem(new ApplicationMenuItem("Account.Manage", accountStringLocalizer["ManageYourProfile"],
$"{identityServerUrl.EnsureEndsWith('/')}Account/Manage?returnUrl={_configuration[EventHubUrlOptions.GetWwwConfigKey()]}", icon: "fa fa-cog", order: 1000, null, "_blank"));
$"{identityServerUrl.EnsureEndsWith('/')}Account/Manage?returnUrl={EventHubUrlOptions.GetWwwConfigValue(_configuration)}", icon: "fa fa-cog", order: 1000, null, "_blank"));
context.Menu.AddItem(new ApplicationMenuItem("Account.Logout", l["Logout"], url: "~/Account/Logout", icon: "fa fa-power-off", order: int.MaxValue - 1000));
}

8
src/EventHub.Web/Pages/Index.cshtml

@ -40,7 +40,7 @@
<div class="col-lg-9 col-md-11 mx-auto">
<h1>.Net Foundation Week</h1>
<p class="lead">
Lorem ipsum is placeholder text commonly used in the graphic.
Lorem ipsum is placeholder text commonly used in the graphic!!
</p>
<div>
<a href="#" class="btn btn-primary">Join Now</a>
@ -58,7 +58,7 @@
<div class="col-lg-9 col-md-11 mx-auto">
<h1>.Net Foundation Week</h1>
<p class="lead">
Lorem ipsum is placeholder text commonly used in the graphic.
Lorem ipsum is placeholder text commonly used in the graphic!
</p>
<div>
<a href="#" class="btn btn-primary">Join Now</a>
@ -74,8 +74,8 @@
<div class="container">
<div class="row">
<div class="col-lg-9 col-md-11 mx-auto">
<h1>Let's Share Together</h1>
<p class="lead">Try something new, or do more of what you love.</p>
<h1>Let's Share Together!</h1>
<p class="lead">Try something new, or do more of what you love :)</p>
</div>
</div>
</div>

Loading…
Cancel
Save