diff --git a/etc/k8s/README.md b/etc/k8s/README.md index c40bbf5..db71d90 100644 --- a/etc/k8s/README.md +++ b/etc/k8s/README.md @@ -13,4 +13,4 @@ * Run `build-images.ps1` in the `scripts` directory. * Run `helm install eh-st eventhub` in the `helm-chart` directory. -* Browse https://eh-st-www +* Browse https://eh-st-www and https://eh-st-admin diff --git a/etc/k8s/helm-chart/eventhub/charts/admin-api/Chart.yaml b/etc/k8s/helm-chart/eventhub/charts/admin-api/Chart.yaml new file mode 100644 index 0000000..4b82d4b --- /dev/null +++ b/etc/k8s/helm-chart/eventhub/charts/admin-api/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: admin-api +appVersion: "1.0" +description: EventHub Admin API Application +version: 1.0.0 +type: application \ No newline at end of file diff --git a/etc/k8s/helm-chart/eventhub/charts/admin-api/templates/admin-api-ingress.yaml b/etc/k8s/helm-chart/eventhub/charts/admin-api/templates/admin-api-ingress.yaml new file mode 100644 index 0000000..f519e26 --- /dev/null +++ b/etc/k8s/helm-chart/eventhub/charts/admin-api/templates/admin-api-ingress.yaml @@ -0,0 +1,25 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Release.Name }}-{{ .Chart.Name }}-ingress + annotations: + nginx.ingress.kubernetes.io/rewrite-target: / + nginx.ingress.kubernetes.io/force-ssl-redirect: "true" + nginx.ingress.kubernetes.io/proxy-buffer-size: "{{ .Values.global.nginxProxyBufferSize }}" + nginx.ingress.kubernetes.io/proxy-buffers-number: "{{ .Values.global.nginxProxyBuffersNumber }}" +spec: + tls: + - hosts: + - {{ .Values.global.adminApiDomain }} + secretName: {{ .Release.Name }}-{{ .Chart.Name }}-tls + rules: + - host: "{{ .Values.global.adminApiDomain }}" + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ .Release.Name }}-{{ .Chart.Name }} + port: + number: 80 \ No newline at end of file diff --git a/etc/k8s/helm-chart/eventhub/charts/admin-api/templates/admin-api-service.yaml b/etc/k8s/helm-chart/eventhub/charts/admin-api/templates/admin-api-service.yaml new file mode 100644 index 0000000..ee157c0 --- /dev/null +++ b/etc/k8s/helm-chart/eventhub/charts/admin-api/templates/admin-api-service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + name: {{ .Release.Name }}-{{ .Chart.Name }} + name: {{ .Release.Name }}-{{ .Chart.Name }} +spec: + ports: + - name: "80" + port: 80 + - name: "443" + port: 443 + selector: + app: {{ .Release.Name }}-{{ .Chart.Name }} diff --git a/etc/k8s/helm-chart/eventhub/charts/admin-api/templates/admin-api.yaml b/etc/k8s/helm-chart/eventhub/charts/admin-api/templates/admin-api.yaml new file mode 100644 index 0000000..2674576 --- /dev/null +++ b/etc/k8s/helm-chart/eventhub/charts/admin-api/templates/admin-api.yaml @@ -0,0 +1,27 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Release.Name }}-{{ .Chart.Name }} +spec: + selector: + matchLabels: + app: {{ .Release.Name }}-{{ .Chart.Name }} + template: + metadata: + labels: + app: {{ .Release.Name }}-{{ .Chart.Name }} + spec: + containers: + - image: {{ .Values.containerImage }} + imagePullPolicy: Never + name: {{ .Release.Name }}-{{ .Chart.Name }} + ports: + - name: http + containerPort: 80 + - name: https + containerPort: 443 + env: +{{ include "eventhub.global.env" . | indent 8 }} + - name: "ConnectionStrings__Default" + value: {{ .Values.global.defaultConnString }} + diff --git a/etc/k8s/helm-chart/eventhub/charts/admin-api/values.yaml b/etc/k8s/helm-chart/eventhub/charts/admin-api/values.yaml new file mode 100644 index 0000000..e69de29 diff --git a/etc/k8s/helm-chart/eventhub/charts/admin/Chart.yaml b/etc/k8s/helm-chart/eventhub/charts/admin/Chart.yaml new file mode 100644 index 0000000..6432aff --- /dev/null +++ b/etc/k8s/helm-chart/eventhub/charts/admin/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: admin +appVersion: "1.0" +description: EventHub Admin Application +version: 1.0.0 +type: application \ No newline at end of file diff --git a/etc/k8s/helm-chart/eventhub/charts/admin/templates/admin-ingress.yaml b/etc/k8s/helm-chart/eventhub/charts/admin/templates/admin-ingress.yaml new file mode 100644 index 0000000..06533dd --- /dev/null +++ b/etc/k8s/helm-chart/eventhub/charts/admin/templates/admin-ingress.yaml @@ -0,0 +1,25 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Release.Name }}-{{ .Chart.Name }}-ingress + annotations: + nginx.ingress.kubernetes.io/rewrite-target: / + nginx.ingress.kubernetes.io/force-ssl-redirect: "true" + nginx.ingress.kubernetes.io/proxy-buffer-size: "{{ .Values.global.nginxProxyBufferSize }}" + nginx.ingress.kubernetes.io/proxy-buffers-number: "{{ .Values.global.nginxProxyBuffersNumber }}" +spec: + tls: + - hosts: + - {{ .Values.global.adminDomain }} + secretName: {{ .Release.Name }}-{{ .Chart.Name }}-tls + rules: + - host: "{{ .Values.global.adminDomain }}" + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ .Release.Name }}-{{ .Chart.Name }} + port: + number: 80 \ No newline at end of file diff --git a/etc/k8s/helm-chart/eventhub/charts/admin/templates/admin-service.yaml b/etc/k8s/helm-chart/eventhub/charts/admin/templates/admin-service.yaml new file mode 100644 index 0000000..ee157c0 --- /dev/null +++ b/etc/k8s/helm-chart/eventhub/charts/admin/templates/admin-service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + name: {{ .Release.Name }}-{{ .Chart.Name }} + name: {{ .Release.Name }}-{{ .Chart.Name }} +spec: + ports: + - name: "80" + port: 80 + - name: "443" + port: 443 + selector: + app: {{ .Release.Name }}-{{ .Chart.Name }} diff --git a/etc/k8s/helm-chart/eventhub/charts/admin/templates/admin.yaml b/etc/k8s/helm-chart/eventhub/charts/admin/templates/admin.yaml new file mode 100644 index 0000000..00a20ca --- /dev/null +++ b/etc/k8s/helm-chart/eventhub/charts/admin/templates/admin.yaml @@ -0,0 +1,24 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Release.Name }}-{{ .Chart.Name }} +spec: + selector: + matchLabels: + app: {{ .Release.Name }}-{{ .Chart.Name }} + template: + metadata: + labels: + app: {{ .Release.Name }}-{{ .Chart.Name }} + spec: + containers: + - image: {{ .Values.containerImage }} + imagePullPolicy: Never + name: {{ .Release.Name }}-{{ .Chart.Name }} + ports: + - name: http + containerPort: 80 + - name: https + containerPort: 443 + env: +{{ include "eventhub.global.env" . | indent 8 }} diff --git a/etc/k8s/helm-chart/eventhub/charts/admin/values.yaml b/etc/k8s/helm-chart/eventhub/charts/admin/values.yaml new file mode 100644 index 0000000..e69de29 diff --git a/etc/k8s/helm-chart/eventhub/values.yaml b/etc/k8s/helm-chart/eventhub/values.yaml index 9d122ce..b55052e 100644 --- a/etc/k8s/helm-chart/eventhub/values.yaml +++ b/etc/k8s/helm-chart/eventhub/values.yaml @@ -22,5 +22,9 @@ api: containerImage: "eventhub.api" www: containerImage: "eventhub.www" +admin-api: + containerImage: "eventhub.admin-api" +admin: + containerImage: "eventhub.admin" dbmigrator: containerImage: "eventhub.dbmigrator" \ No newline at end of file diff --git a/etc/k8s/scripts/build-images.ps1 b/etc/k8s/scripts/build-images.ps1 index b7c7f9e..3690b30 100644 --- a/etc/k8s/scripts/build-images.ps1 +++ b/etc/k8s/scripts/build-images.ps1 @@ -3,6 +3,8 @@ $slnFolder = Join-Path $currentFolder "../../../" $dbmigratorFolder = Join-Path $slnFolder "src/EventHub.DbMigrator" $webFolder = Join-Path $slnFolder "src/EventHub.Web" $apiFolder = Join-Path $slnFolder "src/EventHub.HttpApi.Host" +$adminFolder = Join-Path $slnFolder "src/EventHub.Admin.Web" +$adminApiFolder = Join-Path $slnFolder "src/EventHub.Admin.HttpApi.Host" $identityServerFolder = Join-Path $slnFolder "src/EventHub.IdentityServer" ### DB MIGRATOR @@ -26,6 +28,20 @@ Set-Location $apiFolder dotnet publish -c Release docker build -t eventhub.api . +### ADMIN (BLAZOR) + +Write-Host "*** BUILDING ADMIN (BLAZOR) ****************" -ForegroundColor Green +Set-Location $adminFolder +dotnet publish -c Release +docker build -t eventhub.admin . + +### ADMIN API + +Write-Host "*** BUILDING ADMIN API ****************" -ForegroundColor Green +Set-Location $adminApiFolder +dotnet publish -c Release +docker build -t eventhub.admin-api . + ### IDENTITY SERVER (ACCOUNT) Write-Host "*** BUILDING IDENTITY SERVER (ACCOUNT) ****************" -ForegroundColor Green diff --git a/src/EventHub.Admin.HttpApi.Host/Dockerfile b/src/EventHub.Admin.HttpApi.Host/Dockerfile new file mode 100644 index 0000000..7dda575 --- /dev/null +++ b/src/EventHub.Admin.HttpApi.Host/Dockerfile @@ -0,0 +1,4 @@ + FROM mcr.microsoft.com/dotnet/aspnet:5.0 + COPY bin/Release/net5.0/publish/ app/ + WORKDIR /app + ENTRYPOINT ["dotnet", "EventHub.Admin.HttpApi.Host.dll"] \ No newline at end of file diff --git a/src/EventHub.Admin.Web/Dockerfile b/src/EventHub.Admin.Web/Dockerfile new file mode 100644 index 0000000..cdfeb3c --- /dev/null +++ b/src/EventHub.Admin.Web/Dockerfile @@ -0,0 +1,3 @@ +FROM nginx:latest +COPY ./bin/Release/net5.0/publish/wwwroot/ /usr/share/nginx/html/ +COPY ./nginx.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/src/EventHub.Admin.Web/nginx.conf b/src/EventHub.Admin.Web/nginx.conf new file mode 100644 index 0000000..4369baa --- /dev/null +++ b/src/EventHub.Admin.Web/nginx.conf @@ -0,0 +1,7 @@ +server { + listen 80; + location / { + root /usr/share/nginx/html; + try_files $uri /index.html; + } +} \ No newline at end of file diff --git a/src/EventHub.Admin.Web/wwwroot/appsettings.Development.json b/src/EventHub.Admin.Web/wwwroot/appsettings.Development.json deleted file mode 100644 index 0db3279..0000000 --- a/src/EventHub.Admin.Web/wwwroot/appsettings.Development.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - -} diff --git a/src/EventHub.Admin.Web/wwwroot/appsettings.Production.json b/src/EventHub.Admin.Web/wwwroot/appsettings.Production.json new file mode 100644 index 0000000..52d847d --- /dev/null +++ b/src/EventHub.Admin.Web/wwwroot/appsettings.Production.json @@ -0,0 +1,13 @@ +{ + "App": { + "SelfUrl": "https://eh-st-admin" + }, + "AuthServer": { + "Authority": "https://eh-st-account" + }, + "RemoteServices": { + "Default": { + "BaseUrl": "https://eh-st-admin-api" + } + } +} diff --git a/src/EventHub.Web/Menus/EventHubMenuContributor.cs b/src/EventHub.Web/Menus/EventHubMenuContributor.cs index 6b3d0c2..2d5fda7 100644 --- a/src/EventHub.Web/Menus/EventHubMenuContributor.cs +++ b/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["App:SelfUrl"]}", icon: "fa fa-cog", order: 1000, null, "_blank")); + $"{identityServerUrl.EnsureEndsWith('/')}Account/Manage?returnUrl={_configuration[EventHubUrlOptions.GetWwwConfigKey()]}", 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)); }