From baf96e7f4141a5aca0be439ace57715b7015bfb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Mon, 9 Aug 2021 16:47:20 +0300 Subject: [PATCH] Added azure configuration --- .../charts/account/templates/account.yaml | 2 +- .../charts/admin-api/templates/admin-api.yaml | 2 +- .../charts/admin/templates/admin.yaml | 2 +- .../eventhub/charts/api/templates/api.yaml | 2 +- .../templates/background-services.yaml | 2 +- .../charts/dbmigrator/templates/migrator.yaml | 2 +- .../eventhub/charts/www/templates/www.yaml | 2 +- .../eventhub/templates/_helpers.tpl | 2 + etc/k8s/helm-chart/eventhub/values.azure.yaml | 34 +++++++++++++++ etc/k8s/helm-chart/eventhub/values.yaml | 2 + .../scripts/azure-install-nginx-ingress.ps1 | 41 +++++++++++++++++++ .../Web/EventHubUrlOptions.cs | 6 +++ src/EventHub.Web/EventHubWebModule.cs | 3 +- 13 files changed, 93 insertions(+), 9 deletions(-) create mode 100644 etc/k8s/helm-chart/eventhub/values.azure.yaml create mode 100644 etc/k8s/scripts/azure-install-nginx-ingress.ps1 diff --git a/etc/k8s/helm-chart/eventhub/charts/account/templates/account.yaml b/etc/k8s/helm-chart/eventhub/charts/account/templates/account.yaml index 2674576..0fc80aa 100644 --- a/etc/k8s/helm-chart/eventhub/charts/account/templates/account.yaml +++ b/etc/k8s/helm-chart/eventhub/charts/account/templates/account.yaml @@ -13,7 +13,7 @@ spec: spec: containers: - image: {{ .Values.containerImage }} - imagePullPolicy: Never + imagePullPolicy: {{ .Values.global.imagePullPolicy }} name: {{ .Release.Name }}-{{ .Chart.Name }} ports: - name: http 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 index 2674576..0fc80aa 100644 --- 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 @@ -13,7 +13,7 @@ spec: spec: containers: - image: {{ .Values.containerImage }} - imagePullPolicy: Never + imagePullPolicy: {{ .Values.global.imagePullPolicy }} name: {{ .Release.Name }}-{{ .Chart.Name }} ports: - name: http diff --git a/etc/k8s/helm-chart/eventhub/charts/admin/templates/admin.yaml b/etc/k8s/helm-chart/eventhub/charts/admin/templates/admin.yaml index 00a20ca..ca27707 100644 --- a/etc/k8s/helm-chart/eventhub/charts/admin/templates/admin.yaml +++ b/etc/k8s/helm-chart/eventhub/charts/admin/templates/admin.yaml @@ -13,7 +13,7 @@ spec: spec: containers: - image: {{ .Values.containerImage }} - imagePullPolicy: Never + imagePullPolicy: {{ .Values.global.imagePullPolicy }} name: {{ .Release.Name }}-{{ .Chart.Name }} ports: - name: http diff --git a/etc/k8s/helm-chart/eventhub/charts/api/templates/api.yaml b/etc/k8s/helm-chart/eventhub/charts/api/templates/api.yaml index 2674576..0fc80aa 100644 --- a/etc/k8s/helm-chart/eventhub/charts/api/templates/api.yaml +++ b/etc/k8s/helm-chart/eventhub/charts/api/templates/api.yaml @@ -13,7 +13,7 @@ spec: spec: containers: - image: {{ .Values.containerImage }} - imagePullPolicy: Never + imagePullPolicy: {{ .Values.global.imagePullPolicy }} name: {{ .Release.Name }}-{{ .Chart.Name }} ports: - name: http diff --git a/etc/k8s/helm-chart/eventhub/charts/background-services/templates/background-services.yaml b/etc/k8s/helm-chart/eventhub/charts/background-services/templates/background-services.yaml index 2b4d013..6e7d8ee 100644 --- a/etc/k8s/helm-chart/eventhub/charts/background-services/templates/background-services.yaml +++ b/etc/k8s/helm-chart/eventhub/charts/background-services/templates/background-services.yaml @@ -9,7 +9,7 @@ spec: containers: - name: {{ .Release.Name }}-{{ .Chart.Name }} image: {{ .Values.containerImage }} - imagePullPolicy: Never + imagePullPolicy: {{ .Values.global.imagePullPolicy }} env: {{ include "eventhub.global.env" . | indent 8 }} - name: "ConnectionStrings__Default" diff --git a/etc/k8s/helm-chart/eventhub/charts/dbmigrator/templates/migrator.yaml b/etc/k8s/helm-chart/eventhub/charts/dbmigrator/templates/migrator.yaml index 75c2727..03b7b64 100644 --- a/etc/k8s/helm-chart/eventhub/charts/dbmigrator/templates/migrator.yaml +++ b/etc/k8s/helm-chart/eventhub/charts/dbmigrator/templates/migrator.yaml @@ -9,7 +9,7 @@ spec: containers: - name: {{ .Release.Name }}-{{ .Chart.Name }} image: {{ .Values.containerImage }} - imagePullPolicy: Never + imagePullPolicy: {{ .Values.global.imagePullPolicy }} env: {{ include "eventhub.global.env" . | indent 8 }} - name: "ConnectionStrings__Default" diff --git a/etc/k8s/helm-chart/eventhub/charts/www/templates/www.yaml b/etc/k8s/helm-chart/eventhub/charts/www/templates/www.yaml index 00a20ca..ca27707 100644 --- a/etc/k8s/helm-chart/eventhub/charts/www/templates/www.yaml +++ b/etc/k8s/helm-chart/eventhub/charts/www/templates/www.yaml @@ -13,7 +13,7 @@ spec: spec: containers: - image: {{ .Values.containerImage }} - imagePullPolicy: Never + imagePullPolicy: {{ .Values.global.imagePullPolicy }} name: {{ .Release.Name }}-{{ .Chart.Name }} ports: - name: http diff --git a/etc/k8s/helm-chart/eventhub/templates/_helpers.tpl b/etc/k8s/helm-chart/eventhub/templates/_helpers.tpl index 91bcc62..ab74c7a 100644 --- a/etc/k8s/helm-chart/eventhub/templates/_helpers.tpl +++ b/etc/k8s/helm-chart/eventhub/templates/_helpers.tpl @@ -5,6 +5,8 @@ value: "{{ .Values.global.wwwUrl }}" - name: "AppUrls__Api" value: "{{ .Values.global.apiUrl }}" +- name: "AppUrls__ApiInternal" + value: "{{ .Values.global.apiUrlInternal }}" - name: "AppUrls__Admin" value: "{{ .Values.global.adminUrl }}" - name: "AppUrls__AdminApi" diff --git a/etc/k8s/helm-chart/eventhub/values.azure.yaml b/etc/k8s/helm-chart/eventhub/values.azure.yaml new file mode 100644 index 0000000..5f9f34c --- /dev/null +++ b/etc/k8s/helm-chart/eventhub/values.azure.yaml @@ -0,0 +1,34 @@ +global: + accountDomain: account.openeventhub.com + accountUrl: https://account.openeventhub.com + apiDomain: api.openeventhub.com + apiUrl: https://api.openeventhub.com + apiUrlInternal: http://eh-az-api + wwwDomain: openeventhub.com + wwwUrl: "https://openeventhub.com" + adminDomain: admin.openeventhub.com + adminUrl: https://admin.openeventhub.com + adminApiDomain: admin-api.openeventhub.com + adminApiUrl: https://admin-api.openeventhub.com + nginxProxyBufferSize: "32k" + nginxProxyBuffersNumber: "8" + defaultConnString: "Host=eh-az-postgresql;Port=5432;Database=EventHub;Username=root;Password=root" + redisConfiguration: "eh-az-redis" + internalAuthServerAuthority: "http://eh-az-account" + internalAuthServerRequireHttpsMetadata: "false" + stringEncryptionDefaultPassPhrase: "TxVIZFPxK33czbbv" + imagePullPolicy: Always +account: + containerImage: "volocr.azurecr.io/eventhub.account" +api: + containerImage: "volocr.azurecr.io/eventhub.api" +www: + containerImage: "volocr.azurecr.io/eventhub.www" +admin-api: + containerImage: "volocr.azurecr.io/eventhub.admin-api" +admin: + containerImage: "volocr.azurecr.io/eventhub.admin" +dbmigrator: + containerImage: "volocr.azurecr.io/eventhub.dbmigrator" +background-services: + containerImage: "volocr.azurecr.io/eventhub.background-services" \ No newline at end of file diff --git a/etc/k8s/helm-chart/eventhub/values.yaml b/etc/k8s/helm-chart/eventhub/values.yaml index 7bf18a0..e81a1ba 100644 --- a/etc/k8s/helm-chart/eventhub/values.yaml +++ b/etc/k8s/helm-chart/eventhub/values.yaml @@ -3,6 +3,7 @@ global: accountUrl: https://eh-st-account apiDomain: eh-st-api apiUrl: https://eh-st-api + apiUrlInternal: http://api.openeventhub.com wwwDomain: eh-st-www wwwUrl: "https://eh-st-www" adminDomain: eh-st-admin @@ -16,6 +17,7 @@ global: internalAuthServerAuthority: "http://eh-st-account" internalAuthServerRequireHttpsMetadata: "false" stringEncryptionDefaultPassPhrase: "TxVIZFPxK33czbbv" + imagePullPolicy: Never account: containerImage: "eventhub.account" api: diff --git a/etc/k8s/scripts/azure-install-nginx-ingress.ps1 b/etc/k8s/scripts/azure-install-nginx-ingress.ps1 new file mode 100644 index 0000000..1114a62 --- /dev/null +++ b/etc/k8s/scripts/azure-install-nginx-ingress.ps1 @@ -0,0 +1,41 @@ +$REGISTRY_NAME="volocr.azurecr.io" +$CONTROLLER_REGISTRY="k8s.gcr.io" +$CONTROLLER_IMAGE="ingress-nginx/controller" +$CONTROLLER_TAG="v0.48.1" +$PATCH_REGISTRY="docker.io" +$PATCH_IMAGE="jettech/kube-webhook-certgen" +$PATCH_TAG="v1.5.1" +$DEFAULTBACKEND_REGISTRY="k8s.gcr.io" +$DEFAULTBACKEND_IMAGE="defaultbackend-amd64" +$DEFAULTBACKEND_TAG="1.5" + +az acr import --name $REGISTRY_NAME --source ${CONTROLLER_REGISTRY}/${CONTROLLER_IMAGE}:${CONTROLLER_TAG} --image ${CONTROLLER_IMAGE}:${CONTROLLER_TAG} +az acr import --name $REGISTRY_NAME --source ${PATCH_REGISTRY}/${PATCH_IMAGE}:${PATCH_TAG} --image ${PATCH_IMAGE}:${PATCH_TAG} +az acr import --name $REGISTRY_NAME --source ${DEFAULTBACKEND_REGISTRY}/${DEFAULTBACKEND_IMAGE}:${DEFAULTBACKEND_TAG} --image ${DEFAULTBACKEND_IMAGE}:${DEFAULTBACKEND_TAG} + +# Create a namespace for your ingress resources +kubectl create namespace ingress-basic + +# Add the ingress-nginx repository +helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx + +# Set variable for ACR location to use for pulling images +$ACR_URL="volocr.azurecr.io" + +# Use Helm to deploy an NGINX ingress controller +helm install nginx-ingress ingress-nginx/ingress-nginx ` + --namespace ingress-basic ` + --set controller.replicaCount=1 ` + --set controller.nodeSelector."kubernetes\.io/os"=linux ` + --set controller.image.registry=$ACR_URL ` + --set controller.image.image=$CONTROLLER_IMAGE ` + --set controller.image.tag=$CONTROLLER_TAG ` + --set controller.image.digest="" ` + --set controller.admissionWebhooks.patch.nodeSelector."kubernetes\.io/os"=linux ` + --set controller.admissionWebhooks.patch.image.registry=$ACR_URL ` + --set controller.admissionWebhooks.patch.image.image=$PATCH_IMAGE ` + --set controller.admissionWebhooks.patch.image.tag=$PATCH_TAG ` + --set defaultBackend.nodeSelector."kubernetes\.io/os"=linux ` + --set defaultBackend.image.registry=$ACR_URL ` + --set defaultBackend.image.image=$DEFAULTBACKEND_IMAGE ` + --set defaultBackend.image.tag=$DEFAULTBACKEND_TAG \ No newline at end of file diff --git a/src/EventHub.Domain.Shared/Web/EventHubUrlOptions.cs b/src/EventHub.Domain.Shared/Web/EventHubUrlOptions.cs index eec5b04..5d758a1 100644 --- a/src/EventHub.Domain.Shared/Web/EventHubUrlOptions.cs +++ b/src/EventHub.Domain.Shared/Web/EventHubUrlOptions.cs @@ -7,6 +7,7 @@ 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"; @@ -20,6 +21,11 @@ return GetConfigKey(nameof(Www)); } + public static string GetApiInternalConfigKey() + { + return GetConfigKey(nameof(ApiInternal)); + } + public static string GetApiConfigKey() { return GetConfigKey(nameof(Api)); diff --git a/src/EventHub.Web/EventHubWebModule.cs b/src/EventHub.Web/EventHubWebModule.cs index aa72d51..1daba58 100644 --- a/src/EventHub.Web/EventHubWebModule.cs +++ b/src/EventHub.Web/EventHubWebModule.cs @@ -118,8 +118,7 @@ namespace EventHub.Web Configure(options => { options.RemoteServices.Default = new RemoteServiceConfiguration( - configuration[EventHubUrlOptions.GetApiConfigKey()] - .Replace("https", "http") + configuration[EventHubUrlOptions.GetApiInternalConfigKey()] .EnsureEndsWith('/') ); });