Browse Source

Deploy admin ui and api into k8s

pull/51/head
Halil İbrahim Kalkan 5 years ago
parent
commit
efa6871c38
  1. 2
      etc/k8s/README.md
  2. 6
      etc/k8s/helm-chart/eventhub/charts/admin-api/Chart.yaml
  3. 25
      etc/k8s/helm-chart/eventhub/charts/admin-api/templates/admin-api-ingress.yaml
  4. 14
      etc/k8s/helm-chart/eventhub/charts/admin-api/templates/admin-api-service.yaml
  5. 27
      etc/k8s/helm-chart/eventhub/charts/admin-api/templates/admin-api.yaml
  6. 0
      etc/k8s/helm-chart/eventhub/charts/admin-api/values.yaml
  7. 6
      etc/k8s/helm-chart/eventhub/charts/admin/Chart.yaml
  8. 25
      etc/k8s/helm-chart/eventhub/charts/admin/templates/admin-ingress.yaml
  9. 14
      etc/k8s/helm-chart/eventhub/charts/admin/templates/admin-service.yaml
  10. 24
      etc/k8s/helm-chart/eventhub/charts/admin/templates/admin.yaml
  11. 0
      etc/k8s/helm-chart/eventhub/charts/admin/values.yaml
  12. 4
      etc/k8s/helm-chart/eventhub/values.yaml
  13. 16
      etc/k8s/scripts/build-images.ps1
  14. 4
      src/EventHub.Admin.HttpApi.Host/Dockerfile
  15. 3
      src/EventHub.Admin.Web/Dockerfile
  16. 7
      src/EventHub.Admin.Web/nginx.conf
  17. 3
      src/EventHub.Admin.Web/wwwroot/appsettings.Development.json
  18. 13
      src/EventHub.Admin.Web/wwwroot/appsettings.Production.json
  19. 2
      src/EventHub.Web/Menus/EventHubMenuContributor.cs

2
etc/k8s/README.md

@ -13,4 +13,4 @@
* Run `build-images.ps1` in the `scripts` directory. * Run `build-images.ps1` in the `scripts` directory.
* Run `helm install eh-st eventhub` in the `helm-chart` 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

6
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

25
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

14
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 }}

27
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 }}

0
etc/k8s/helm-chart/eventhub/charts/admin-api/values.yaml

6
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

25
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

14
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 }}

24
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 }}

0
etc/k8s/helm-chart/eventhub/charts/admin/values.yaml

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

@ -22,5 +22,9 @@ api:
containerImage: "eventhub.api" containerImage: "eventhub.api"
www: www:
containerImage: "eventhub.www" containerImage: "eventhub.www"
admin-api:
containerImage: "eventhub.admin-api"
admin:
containerImage: "eventhub.admin"
dbmigrator: dbmigrator:
containerImage: "eventhub.dbmigrator" containerImage: "eventhub.dbmigrator"

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

@ -3,6 +3,8 @@ $slnFolder = Join-Path $currentFolder "../../../"
$dbmigratorFolder = Join-Path $slnFolder "src/EventHub.DbMigrator" $dbmigratorFolder = Join-Path $slnFolder "src/EventHub.DbMigrator"
$webFolder = Join-Path $slnFolder "src/EventHub.Web" $webFolder = Join-Path $slnFolder "src/EventHub.Web"
$apiFolder = Join-Path $slnFolder "src/EventHub.HttpApi.Host" $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" $identityServerFolder = Join-Path $slnFolder "src/EventHub.IdentityServer"
### DB MIGRATOR ### DB MIGRATOR
@ -26,6 +28,20 @@ Set-Location $apiFolder
dotnet publish -c Release dotnet publish -c Release
docker build -t eventhub.api . 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) ### IDENTITY SERVER (ACCOUNT)
Write-Host "*** BUILDING IDENTITY SERVER (ACCOUNT) ****************" -ForegroundColor Green Write-Host "*** BUILDING IDENTITY SERVER (ACCOUNT) ****************" -ForegroundColor Green

4
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"]

3
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

7
src/EventHub.Admin.Web/nginx.conf

@ -0,0 +1,7 @@
server {
listen 80;
location / {
root /usr/share/nginx/html;
try_files $uri /index.html;
}
}

3
src/EventHub.Admin.Web/wwwroot/appsettings.Development.json

@ -1,3 +0,0 @@
{
}

13
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"
}
}
}

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

@ -51,7 +51,7 @@ namespace EventHub.Web.Menus
if (currentUser.IsAuthenticated) if (currentUser.IsAuthenticated)
{ {
context.Menu.AddItem(new ApplicationMenuItem("Account.Manage", accountStringLocalizer["ManageYourProfile"], 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)); context.Menu.AddItem(new ApplicationMenuItem("Account.Logout", l["Logout"], url: "~/Account/Logout", icon: "fa fa-power-off", order: int.MaxValue - 1000));
} }

Loading…
Cancel
Save