diff --git a/deploy/k8s/helm/apigwms/templates/deployment.yaml b/deploy/k8s/helm/apigwms/templates/deployment.yaml index 2fb42f4fbf..11ad032b21 100644 --- a/deploy/k8s/helm/apigwms/templates/deployment.yaml +++ b/deploy/k8s/helm/apigwms/templates/deployment.yaml @@ -22,7 +22,7 @@ spec: labels: app: {{ template "apigwms.name" . }} release: {{ .Release.Name }} - {{ if .Values.inf.mesh.enabled -}} + {{ if .Values.inf.mesh.linkerd -}} annotations: linkerd.io/inject: enabled {{- end }} diff --git a/deploy/k8s/helm/apigwms/templates/ingress.yaml b/deploy/k8s/helm/apigwms/templates/ingress.yaml index 5282962615..27e0cc5e0f 100644 --- a/deploy/k8s/helm/apigwms/templates/ingress.yaml +++ b/deploy/k8s/helm/apigwms/templates/ingress.yaml @@ -1,4 +1,4 @@ -{{- if .Values.ingress.enabled -}} +{{- if and .Values.ingress.enabled (not .Values.inf.mesh.istio) -}} {{- $ingressPath := include "pathBase" . -}} {{- $serviceName := .Values.app.svc.mobileshoppingapigw -}} @@ -18,7 +18,7 @@ metadata: {{- if and .Values.inf.tls.enabled .Values.inf.tls.issuer }} cert-manager.io/issuer: {{ .Values.inf.tls.issuer }} {{- end }} -{{- if .Values.inf.mesh.enabled }} +{{- if .Values.inf.mesh.linkerd }} {{- with .Values.ingress.mesh.annotations }} {{ toYaml . | indent 4 }} {{- end }} diff --git a/deploy/k8s/helm/apigwms/templates/ingresss-istio.yaml b/deploy/k8s/helm/apigwms/templates/ingresss-istio.yaml new file mode 100644 index 0000000000..29e7a19ec6 --- /dev/null +++ b/deploy/k8s/helm/apigwms/templates/ingresss-istio.yaml @@ -0,0 +1,48 @@ +{{- if .Values.ingress.enabled -}} +{{- if .Values.inf.mesh.istio -}} +{{- $ingressPath := include "pathBase" . -}} +{{- $serviceName := .Values.app.svc.mobileshoppingapigw -}} +apiVersion: networking.istio.io/v1alpha3 +kind: VirtualService +metadata: + name: {{ template "apigwms.fullname" . }} + labels: + app: {{ template "apigwms.name" . }} + chart: {{ template "apigwms.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +{{- if and .Values.inf.tls.enabled .Values.inf.tls.issuer }} + annotations: + cert-manager.io/issuer: {{ .Values.inf.tls.issuer }} +{{- end }} +{{- if .Values.inf.mesh.istio }} +{{- with .Values.ingress.mesh.annotations }} +{{ toYaml . | indent 4 }} +{{- end }} +{{- end }} +spec: + hosts: + {{- range .Values.ingress.hosts }} + - {{ . }} + {{- end }} + gateways: + {{- range .Values.ingress.gateways }} + - {{ . }} + {{- end }} + http: + {{- range .Values.ingress.hosts }} + - route: + - destination: + host: {{ $serviceName }} + port: + number: 80 + match: + - uri: + prefix: {{ $ingressPath }}/ + - uri: + prefix: {{ $ingressPath }} + rewrite: + uri: / + {{- end }} +{{- end }} +{{- end }} diff --git a/deploy/k8s/helm/apigwws/templates/deployment.yaml b/deploy/k8s/helm/apigwws/templates/deployment.yaml index 3bbcec274c..7fc1cb8c84 100644 --- a/deploy/k8s/helm/apigwws/templates/deployment.yaml +++ b/deploy/k8s/helm/apigwws/templates/deployment.yaml @@ -21,7 +21,7 @@ spec: labels: app: {{ template "apigwws.name" . }} release: {{ .Release.Name }} - {{ if .Values.inf.mesh.enabled -}} + {{ if .Values.inf.mesh.linkerd -}} annotations: linkerd.io/inject: enabled {{- end }} diff --git a/deploy/k8s/helm/apigwws/templates/ingress.yaml b/deploy/k8s/helm/apigwws/templates/ingress.yaml index 0e937067d8..e63ecc34ae 100644 --- a/deploy/k8s/helm/apigwws/templates/ingress.yaml +++ b/deploy/k8s/helm/apigwws/templates/ingress.yaml @@ -1,4 +1,4 @@ -{{- if .Values.ingress.enabled -}} +{{- if and .Values.ingress.enabled (not .Values.inf.mesh.istio) -}} {{- $ingressPath := include "pathBase" . -}} {{- $serviceName := .Values.app.svc.webshoppingapigw -}} apiVersion: networking.k8s.io/v1 @@ -17,7 +17,7 @@ metadata: {{- if and .Values.inf.tls.enabled .Values.inf.tls.issuer }} cert-manager.io/issuer: {{ .Values.inf.tls.issuer }} {{- end }} -{{- if .Values.inf.mesh.enabled }} +{{- if .Values.inf.mesh.linkerd }} {{- with .Values.ingress.mesh.annotations }} {{ toYaml . | indent 4 }} {{- end }} diff --git a/deploy/k8s/helm/apigwws/templates/ingresss-istio.yaml b/deploy/k8s/helm/apigwws/templates/ingresss-istio.yaml new file mode 100644 index 0000000000..a285ad3b48 --- /dev/null +++ b/deploy/k8s/helm/apigwws/templates/ingresss-istio.yaml @@ -0,0 +1,48 @@ +{{- if .Values.ingress.enabled -}} +{{- if .Values.inf.mesh.istio -}} +{{- $ingressPath := include "pathBase" . -}} +{{- $serviceName := .Values.app.svc.webshoppingapigw -}} +apiVersion: networking.istio.io/v1alpha3 +kind: VirtualService +metadata: + name: {{ template "apigwws.fullname" . }} + labels: + app: {{ template "apigwws.name" . }} + chart: {{ template "apigwws.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +{{- if and .Values.inf.tls.enabled .Values.inf.tls.issuer }} + annotations: + cert-manager.io/issuer: {{ .Values.inf.tls.issuer }} +{{- end }} +{{- if .Values.inf.mesh.istio }} +{{- with .Values.ingress.mesh.annotations }} +{{ toYaml . | indent 4 }} +{{- end }} +{{- end }} +spec: + hosts: + {{- range .Values.ingress.hosts }} + - {{ . }} + {{- end }} + gateways: + {{- range .Values.ingress.gateways }} + - {{ . }} + {{- end }} + http: + {{- range .Values.ingress.hosts }} + - route: + - destination: + host: {{ $serviceName }} + port: + number: 80 + match: + - uri: + prefix: {{ $ingressPath }}/ + - uri: + prefix: {{ $ingressPath }} + rewrite: + uri: / + {{- end }} +{{- end }} +{{- end }} diff --git a/deploy/k8s/helm/basket-api/templates/configmap.yaml b/deploy/k8s/helm/basket-api/templates/configmap.yaml index 8a36f74ace..85ef486f9f 100644 --- a/deploy/k8s/helm/basket-api/templates/configmap.yaml +++ b/deploy/k8s/helm/basket-api/templates/configmap.yaml @@ -14,4 +14,5 @@ data: urls__IdentityUrl: http://{{ .Values.app.svc.identity }} all__EventBusConnection: {{ .Values.inf.eventbus.constr }} all__InstrumentationKey: "{{ .Values.inf.appinsights.key }}" - all__UseAzureServiceBus: "{{ .Values.inf.eventbus.useAzure }}" \ No newline at end of file + all__UseAzureServiceBus: "{{ .Values.inf.eventbus.useAzure }}" + all__Redis: "{{ .Values.inf.redis.basket.constr }}" \ No newline at end of file diff --git a/deploy/k8s/helm/basket-api/templates/deployment.yaml b/deploy/k8s/helm/basket-api/templates/deployment.yaml index b9fd262041..29ef312797 100644 --- a/deploy/k8s/helm/basket-api/templates/deployment.yaml +++ b/deploy/k8s/helm/basket-api/templates/deployment.yaml @@ -21,7 +21,7 @@ spec: labels: app: {{ template "basket-api.name" . }} release: {{ .Release.Name }} - {{ if .Values.inf.mesh.enabled -}} + {{ if .Values.inf.mesh.linkerd -}} annotations: linkerd.io/inject: enabled {{- end }} diff --git a/deploy/k8s/helm/basket-api/values.yaml b/deploy/k8s/helm/basket-api/values.yaml index dcd6aa763b..5d60ecc924 100644 --- a/deploy/k8s/helm/basket-api/values.yaml +++ b/deploy/k8s/helm/basket-api/values.yaml @@ -28,14 +28,16 @@ env: configmap: - name: ConnectionString key: basket__ConnectionString - - name: EventBusConnection + - name: ConnectionStrings__EventBus key: all__EventBusConnection - name: ApplicationInsights__InstrumentationKey key: all__InstrumentationKey - name: AzureServiceBusEnabled key: all__UseAzureServiceBus - - name: IdentityUrl + - name: Identity__Url key: urls__IdentityUrl + - name: ConnectionStrings__Redis + key: all__Redis # values define environment variables with a fixed value (no configmap involved) (name is name of var, and value is its value) values: - name: OrchestratorType diff --git a/deploy/k8s/helm/catalog-api/templates/deployment.yaml b/deploy/k8s/helm/catalog-api/templates/deployment.yaml index 266d894076..707417e0f5 100644 --- a/deploy/k8s/helm/catalog-api/templates/deployment.yaml +++ b/deploy/k8s/helm/catalog-api/templates/deployment.yaml @@ -21,7 +21,7 @@ spec: labels: app: {{ template "catalog-api.name" . }} release: {{ .Release.Name }} - {{ if .Values.inf.mesh.enabled -}} + {{ if .Values.inf.mesh.linkerd -}} annotations: linkerd.io/inject: enabled {{- end }} diff --git a/deploy/k8s/helm/catalog-api/values.yaml b/deploy/k8s/helm/catalog-api/values.yaml index 0de49b7f6c..29fc2ca83c 100644 --- a/deploy/k8s/helm/catalog-api/values.yaml +++ b/deploy/k8s/helm/catalog-api/values.yaml @@ -26,7 +26,7 @@ env: urls: # configmap declares variables which value is taken from the config map defined in template configmap.yaml (name is name of var and key the key in configmap). configmap: - - name: ConnectionString + - name: ConnectionStrings__CatalogDb key: catalog__ConnectionString - name: PicBaseUrl key: catalog__PicBaseUrl @@ -34,7 +34,7 @@ env: key: catalog__AzureStorageEnabled - name: ApplicationInsights__InstrumentationKey key: all__InstrumentationKey - - name: EventBusConnection + - name: ConnectionStrings__EventBus key: all__EventBusConnection - name: AzureServiceBusEnabled key: all__UseAzureServiceBus diff --git a/deploy/k8s/helm/deploy-all-mac.ps1 b/deploy/k8s/helm/deploy-all-mac.ps1 index 3de7dc6c62..139cb9c3f7 100644 --- a/deploy/k8s/helm/deploy-all-mac.ps1 +++ b/deploy/k8s/helm/deploy-all-mac.ps1 @@ -11,7 +11,9 @@ Param( [parameter(Mandatory=$false)][string]$aksRg="", [parameter(Mandatory=$false)][string]$imageTag="latest", [parameter(Mandatory=$false)][bool]$useLocalk8s=$false, - [parameter(Mandatory=$false)][bool]$useMesh=$false, + [parameter(Mandatory=$false)][bool]$useIstio=$false, + [parameter(Mandatory=$false)][string]$istioGatewayName="istio-system/default-gateway", + [parameter(Mandatory=$false)][bool]$useLinkerd=$false, [parameter(Mandatory=$false)][string][ValidateSet('Always','IfNotPresent','Never', IgnoreCase=$false)]$imagePullPolicy="Always", [parameter(Mandatory=$false)][string][ValidateSet('prod','staging','none','custom', IgnoreCase=$false)]$sslSupport = "none", [parameter(Mandatory=$false)][string]$tlsSecretName = "eshop-tls-custom", @@ -23,7 +25,7 @@ function Install-Chart { Param([string]$chart,[string]$initialOptions, [bool]$customRegistry) $options=$initialOptions if ($sslEnabled) { - $options = "$options --set ingress.tls[0].secretName=$tlsSecretName --set ingress.tls[0].hosts=`{$dns`}" + $options = "$options --set ingress.tls[0].secretName=$tlsSecretName --set ingress.tls[0].hosts=``{$dns``}" if ($sslSupport -ne "custom") { $options = "$options --set inf.tls.issuer=$sslIssuer" } @@ -90,6 +92,10 @@ if ([string]::IsNullOrEmpty($dns)) { } } +if ($useIstio -and $useLinkerd) { + Write-Host "You cannot enable both istio and linkerd." -ForegroundColor Red + exit 1 +} if ($useLocalk8s -and $sslEnabled) { Write-Host "SSL can'be enabled on local K8s." -ForegroundColor Red exit 1 @@ -126,7 +132,7 @@ $gateways = ("apigwms", "apigwws") if ($deployInfrastructure) { foreach ($infra in $infras) { Write-Host "Installing infrastructure: $infra" -ForegroundColor Green - helm install "$appName-$infra" --values app.yaml --values inf.yaml --values $ingressValuesFile --set app.name=$appName --set inf.k8s.dns=$dns --set "ingress.hosts={$dns}" $infra + helm install "$appName-$infra" --values app.yaml --values inf.yaml --values $ingressValuesFile --set app.name=$appName --set inf.k8s.dns=$dns --set "ingress.hosts={$dns}" --set "ingress.gateways={$istioGatewayName}" $infra } } else { @@ -137,14 +143,14 @@ if ($deployCharts) { foreach ($chart in $charts) { if ($chartsToDeploy -eq "*" -or $chartsToDeploy.Contains($chart)) { Write-Host "Installing: $chart" -ForegroundColor Green - Install-Chart $chart "--values app.yaml --values inf.yaml --values $ingressValuesFile --values $ingressMeshAnnotationsFile --set app.name=$appName --set inf.k8s.dns=$dns --set ingress.hosts=``{$dns``} --set image.tag=$imageTag --set image.pullPolicy=$imagePullPolicy --set inf.tls.enabled=$sslEnabled --set inf.mesh.enabled=$useMesh --set inf.k8s.local=$useLocalk8s" $useCustomRegistry + Install-Chart $chart "--values app.yaml --values inf.yaml --values $ingressValuesFile --values $ingressMeshAnnotationsFile --set app.name=$appName --set inf.k8s.dns=$dns --set ingress.hosts=``{$dns``} --set ingress.gateways=``{$istioGatewayName``} --set image.tag=$imageTag --set image.pullPolicy=$imagePullPolicy --set inf.tls.enabled=$sslEnabled --set inf.mesh.linkerd=$useLinkerd --set inf.k8s.local=$useLocalk8s --set inf.mesh.istio=$useIstio" $useCustomRegistry } } foreach ($chart in $gateways) { if ($chartsToDeploy -eq "*" -or $chartsToDeploy.Contains($chart)) { Write-Host "Installing Api Gateway Chart: $chart" -ForegroundColor Green - Install-Chart $chart "--values app.yaml --values inf.yaml --values $ingressValuesFile --set app.name=$appName --set inf.k8s.dns=$dns --set image.pullPolicy=$imagePullPolicy --set inf.mesh.enabled=$useMesh --set ingress.hosts=``{$dns``} --set inf.tls.enabled=$sslEnabled" $false + Install-Chart $chart "--values app.yaml --values inf.yaml --values $ingressValuesFile --values $ingressMeshAnnotationsFile --set app.name=$appName --set inf.k8s.dns=$dns --set image.pullPolicy=$imagePullPolicy --set inf.mesh.linkerd=$useLinkerd --set ingress.hosts=``{$dns``} --set ingress.gateways=``{$istioGatewayName``} --set inf.tls.enabled=$sslEnabled --set inf.k8s.local=$useLocalk8s --set inf.mesh.istio=$useIstio" $false } } diff --git a/deploy/k8s/helm/deploy-all.ps1 b/deploy/k8s/helm/deploy-all.ps1 index 213e60fb72..d14ab74f4b 100644 --- a/deploy/k8s/helm/deploy-all.ps1 +++ b/deploy/k8s/helm/deploy-all.ps1 @@ -11,7 +11,9 @@ Param( [parameter(Mandatory=$false)][string]$aksRg="", [parameter(Mandatory=$false)][string]$imageTag="latest", [parameter(Mandatory=$false)][bool]$useLocalk8s=$false, - [parameter(Mandatory=$false)][bool]$useMesh=$false, + [parameter(Mandatory=$false)][bool]$useIstio=$false, + [parameter(Mandatory=$false)][string]$istioGatewayName="istio-system/default-gateway", + [parameter(Mandatory=$false)][bool]$useLinkerd=$false, [parameter(Mandatory=$false)][string][ValidateSet('Always','IfNotPresent','Never', IgnoreCase=$false)]$imagePullPolicy="Always", [parameter(Mandatory=$false)][string][ValidateSet('prod','staging','none','custom', IgnoreCase=$false)]$sslSupport = "none", [parameter(Mandatory=$false)][string]$tlsSecretName = "eshop-tls-custom", @@ -89,6 +91,10 @@ if ([string]::IsNullOrEmpty($dns)) { } } +if ($useIstio -and $useLinkerd) { + Write-Host "You cannot enable both istio and linkerd." -ForegroundColor Red + exit 1 +} if ($useLocalk8s -and $sslEnabled) { Write-Host "SSL can'be enabled on local K8s." -ForegroundColor Red exit 1 @@ -125,7 +131,7 @@ $gateways = ("apigwms", "apigwws") if ($deployInfrastructure) { foreach ($infra in $infras) { Write-Host "Installing infrastructure: $infra" -ForegroundColor Green - helm install "$appName-$infra" --values app.yaml --values inf.yaml --values $ingressValuesFile --set app.name=$appName --set inf.k8s.dns=$dns --set "ingress.hosts={$dns}" $infra + helm install "$appName-$infra" --values app.yaml --values inf.yaml --values $ingressValuesFile --set app.name=$appName --set inf.k8s.dns=$dns --set "ingress.hosts={$dns}" --set "ingress.gateways={$istioGatewayName}" $infra } } else { @@ -136,15 +142,14 @@ if ($deployCharts) { foreach ($chart in $charts) { if ($chartsToDeploy -eq "*" -or $chartsToDeploy.Contains($chart)) { Write-Host "Installing: $chart" -ForegroundColor Green - Install-Chart $chart "-f app.yaml --values inf.yaml -f $ingressValuesFile -f $ingressMeshAnnotationsFile --set app.name=$appName --set inf.k8s.dns=$dns --set ingress.hosts={$dns} --set image.tag=$imageTag --set image.pullPolicy=$imagePullPolicy --set inf.tls.enabled=$sslEnabled --set inf.mesh.enabled=$useMesh --set inf.k8s.local=$useLocalk8s" $useCustomRegistry + Install-Chart $chart "-f app.yaml --values inf.yaml -f $ingressValuesFile -f $ingressMeshAnnotationsFile --set app.name=$appName --set inf.k8s.dns=$dns --set ingress.hosts={$dns} --set ingress.gateways={$istioGatewayName} --set image.tag=$imageTag --set image.pullPolicy=$imagePullPolicy --set inf.tls.enabled=$sslEnabled --set inf.mesh.linkerd=$useLinkerd --set inf.k8s.local=$useLocalk8s --set inf.mesh.istio=$useIstio" $useCustomRegistry } } foreach ($chart in $gateways) { if ($chartsToDeploy -eq "*" -or $chartsToDeploy.Contains($chart)) { Write-Host "Installing Api Gateway Chart: $chart" -ForegroundColor Green - Install-Chart $chart "-f app.yaml -f inf.yaml -f $ingressValuesFile --set app.name=$appName --set inf.k8s.dns=$dns --set image.pullPolicy=$imagePullPolicy --set inf.mesh.enabled=$useMesh --set ingress.hosts={$dns} --set inf.tls.enabled=$sslEnabled" $false - + Install-Chart $chart "-f app.yaml -f inf.yaml -f $ingressValuesFile -f $ingressMeshAnnotationsFile --set app.name=$appName --set inf.k8s.dns=$dns --set image.pullPolicy=$imagePullPolicy --set inf.mesh.linkerd=$useLinkerd --set ingress.hosts={$dns} --set ingress.gateways={$istioGatewayName} --set inf.tls.enabled=$sslEnabled --set inf.k8s.local=$useLocalk8s --set inf.mesh.istio=$useIstio" $false } } } diff --git a/deploy/k8s/helm/deploy-all.sh b/deploy/k8s/helm/deploy-all.sh old mode 100644 new mode 100755 index 704dffe923..ac5b9aff2b --- a/deploy/k8s/helm/deploy-all.sh +++ b/deploy/k8s/helm/deploy-all.sh @@ -43,10 +43,20 @@ Parameters: The Docker username used to logon to the custom registry, supplied using the -r parameter. --use-local-k8s Deploy to a locally installed Kubernetes (default: false). - --use-mesh + --use-linkerd Use Linkerd as service mesh + --use-istio + Use Istio as service mesh + --ingress-mesh-annotations-file ) + e.g. ingress_values_istio.yaml --image-pull-policy Image Pull Policy: Always, IfNotPresent, Never (default: Always) + --ssl-enabled + Enable SSL for the application. + --ssl-support + SSL support: prod, staging, custom, none (default) + --tls-secret-name + The name of the ssl cert. It is assumed that the Kubernetes cluster has been granted access to the container registry. If using AKS and ACR see link for more info: @@ -76,9 +86,17 @@ push_images='' skip_infrastructure='' use_local_k8s='' namespace='eshop' -use_mesh='false' -ingressMeshAnnotationsFile='ingress_values_linkerd.yaml' +use_linkerd='' +use_istio='' +istio_gateway_name='istio-system/default-gateway' +ingress_mesh_annotations_file='ingress_values_linkerd.yaml' imagePullPolicy='Always' +ssl_enabled=false +ssl_issuer="" +ssl_support="none" +ssl_options="" +tls_secret_name='eshop-tls-custom' + while [[ $# -gt 0 ]]; do case "$1" in @@ -114,10 +132,22 @@ while [[ $# -gt 0 ]]; do use_local_k8s='yes'; shift ;; --namespace ) namespace="$2"; shift 2;; - --use-mesh ) - use_mesh='true'; shift ;; + --use-linkerd ) + use_linkerd='yes'; shift ;; + --use-istio ) + use_istio='yes'; shift ;; + --istio-gateway-name ) + istio_gateway_name="$2"; shift 2;; + --ingress-mesh-annotations-file ) + ingress_mesh_annotations_file="$2"; shift 2;; --image-pull-policy ) imagePullPolicy="$2"; shift 2;; + --ssl-enabled ) + ssl_enabled='yes'; shift ;; + --ssl-support ) + ssl_support="$2"; shift 2 ;; + --tls-secret-name ) + tls_secret_name="$2"; shift 2;; *) echo "Unknown option $1" usage; exit 2 ;; @@ -144,6 +174,40 @@ if [[ $build_images ]]; then docker rmi $(docker images -qf "dangling=true") fi +case "$ssl_support" in + "staging") + ssl_enabled=true + tls_secret_name="eshop-letsencrypt-staging" + ssl_issuer="letsencrypt-staging" + ;; + "prod") + ssl_enabled=true + tls_secret_name="eshop-letsencrypt-prod" + ssl_issuer="letsencrypt-prod" + ;; + "custom") + ssl_enabled=true + ;; +esac + +if [ -z "$dns" ]; then + echo "No DNS specified. Ingress resources will be bound to public IP" >&2 + if [ $ssl_enabled ]; then + echo "Can't bind SSL to public IP. DNS is mandatory when using TLS" >&2 + exit 1 + fi +fi + +if [[ $use_istio && $use_linkerd ]]; then + echo "You cannot enable both Istio and Linkerd." >&2 + exit 1 +fi + +if [[ $use_local_k8s && $ssl_enabled ]]; then + echo "SSL cannot be enabled on local K8s." >&2 + exit 1 +fi + use_custom_registry='' if [[ -n $container_registry ]]; then @@ -223,6 +287,15 @@ if [[ $clean ]]; then fi fi +if [ "$ssl_enabled" == 'yes' ]; then + ssl_options="--set ingress.tls[0].secretName=$tls_secret_name --set ingress.tls[0].hosts={$dns}" + + if [ "$ssl_support" != "custom" ]; then + ssl_options="--set inf.tls.issuer=$ssl_issuer" + fi +fi + + echo "#################### Begin $app_name installation using Helm ####################" infras=(sql-data nosql-data rabbitmq keystore-data basket-data) charts=(eshop-common basket-api catalog-api identity-api mobileshoppingagg ordering-api ordering-backgroundtasks ordering-signalrhub payment-api webmvc webshoppingagg webspa webstatus webhooks-api webhooks-web) @@ -232,7 +305,7 @@ if [[ !$skip_infrastructure ]]; then for infra in "${infras[@]}" do echo "Installing infrastructure: $infra" - helm install "$app_name-$infra" --namespace $namespace --set "ingress.hosts={$dns}" --values app.yaml --values inf.yaml --values $ingress_values_file --values $ingressMeshAnnotationsFile --set app.name=$app_name --set inf.k8s.dns=$dns $infra --set inf.mesh.enabled=$use_mesh + helm install "$app_name-$infra" --namespace $namespace --set "ingress.hosts={$dns}" --set "ingress.gateways={$istio_gateway_name}" --values app.yaml --values inf.yaml --values $ingress_values_file --values $ingress_mesh_annotations_file --set app.name=$app_name --set inf.k8s.dns=$dns $infra --set inf.mesh.linkerd=$use_linkerd --set inf.mesh.istio=$use_istio --set inf.tls.enabled=$ssl_enabled $ssl_options done fi @@ -240,16 +313,16 @@ for chart in "${charts[@]}" do echo "Installing: $chart" if [[ $use_custom_registry ]]; then - helm install "$app_name-$chart" --namespace $namespace --set "ingress.hosts={$dns}" --set inf.registry.server=$container_registry --set inf.registry.login=$docker_username --set inf.registry.pwd=$docker_password --set inf.registry.secretName=eshop-docker-scret --values app.yaml --values inf.yaml --values $ingress_values_file --values $ingressMeshAnnotationsFile --set app.name=$app_name --set inf.k8s.dns=$dns --set image.tag=$image_tag --set image.pullPolicy=$imagePullPolicy $chart --set inf.mesh.enabled=$use_mesh + helm install "$app_name-$chart" --namespace $namespace --set "ingress.hosts={$dns}" --set "ingress.gateways={$istio_gateway_name}" --set inf.registry.server=$container_registry --set inf.registry.login=$docker_username --set inf.registry.pwd=$docker_password --set inf.registry.secretName=eshop-docker-scret --values app.yaml --values inf.yaml --values $ingress_values_file --values $ingress_mesh_annotations_file --set app.name=$app_name --set inf.k8s.dns=$dns --set image.tag=$image_tag --set image.pullPolicy=$imagePullPolicy $chart --set inf.mesh.linkerd=$use_linkerd --set inf.mesh.istio=$use_istio --set inf.tls.enabled=$ssl_enabled $ssl_options elif [[ $chart != "eshop-common" ]]; then # eshop-common is ignored when no secret must be deployed - helm install "$app_name-$chart" --namespace $namespace --set "ingress.hosts={$dns}" --values app.yaml --values inf.yaml --values $ingress_values_file --values $ingressMeshAnnotationsFile --set app.name=$app_name --set inf.k8s.dns=$dns --set image.tag=$image_tag --set image.pullPolicy=$imagePullPolicy $chart --set inf.mesh.enabled=$use_mesh + helm install "$app_name-$chart" --namespace $namespace --set "ingress.hosts={$dns}" --set "ingress.gateways={$istio_gateway_name}" --values app.yaml --values inf.yaml --values $ingress_values_file --values $ingress_mesh_annotations_file --set app.name=$app_name --set inf.k8s.dns=$dns --set image.tag=$image_tag --set image.pullPolicy=$imagePullPolicy $chart --set inf.mesh.linkerd=$use_linkerd --set inf.mesh.istio=$use_istio --set inf.tls.enabled=$ssl_enabled $ssl_options fi done for gw in "${gateways[@]}" do echo "Installing gateway: $gw" - helm install "$app_name-$gw" --namespace $namespace --set "ingress.hosts={$dns}" --values app.yaml --values inf.yaml --values $ingress_values_file --set app.name=$app_name --set inf.k8s.dns=$dns --set image.pullPolicy=$imagePullPolicy $gw + helm install "$app_name-$gw" --namespace $namespace --set "ingress.hosts={$dns}" --set "ingress.gateways={$istio_gateway_name}" --values app.yaml --values inf.yaml --values $ingress_values_file --values $ingress_mesh_annotations_file --set app.name=$app_name --set inf.k8s.dns=$dns --set image.pullPolicy=$imagePullPolicy --set inf.tls.enabled=$ssl_enabled $ssl_options --set inf.mesh.linkerd=$use_linkerd --set inf.mesh.istio=$use_istio $gw done echo "FINISHED: Helm charts installed." \ No newline at end of file diff --git a/deploy/k8s/helm/identity-api/templates/_names.tpl b/deploy/k8s/helm/identity-api/templates/_names.tpl index 39ee485ef3..cd7d68491b 100644 --- a/deploy/k8s/helm/identity-api/templates/_names.tpl +++ b/deploy/k8s/helm/identity-api/templates/_names.tpl @@ -48,4 +48,12 @@ {{- else -}} {{- .Values.image.repository -}} {{- end -}} +{{- end -}} + +{{- define "protocol" -}} +{{- if .Values.inf.tls.enabled -}} +{{- printf "%s" "https" -}} +{{- else -}} +{{- printf "%s" "http" -}} +{{- end -}} {{- end -}} \ No newline at end of file diff --git a/deploy/k8s/helm/identity-api/templates/configmap.yaml b/deploy/k8s/helm/identity-api/templates/configmap.yaml index 923b31a954..de8271b456 100644 --- a/deploy/k8s/helm/identity-api/templates/configmap.yaml +++ b/deploy/k8s/helm/identity-api/templates/configmap.yaml @@ -9,6 +9,7 @@ {{- $xamarincallback := include "url-of" (list "xamarincallback" .) -}} {{- $webhooks_url := include "url-of" (list .Values.app.ingress.entries.webhooks .) -}} {{- $webhooksweb_url := include "url-of" (list .Values.app.ingress.entries.webhooksweb .) -}} +{{- $protocol := include "protocol" . -}} apiVersion: v1 kind: ConfigMap @@ -23,13 +24,13 @@ data: identity__ConnectionString: Server={{ $sqlsrv }};Initial Catalog={{ .Values.inf.sql.identity.db }};User Id={{ .Values.inf.sql.common.user }};Password={{ .Values.inf.sql.common.pwd }};TrustServerCertificate={{ .Values.inf.sql.common.TrustServerCertificate }}; identity__keystore: {{ .Values.inf.redis.keystore.constr }} all__InstrumentationKey: "{{ .Values.inf.appinsights.key }}" - mvc_e: http://{{ $mvc_url }} - spa_e: http://{{ $spa_url }} - basket_e: http://{{ $basket_url }} - ordering_e: http://{{ $ordering_url }} - mobileshoppingagg_e: http://{{ $mobileshoppingagg }} - webshoppingagg_e: http://{{ $webhoppingagg }} - xamarin_callback_e: http://{{ $xamarincallback }} - webhooksapi_e: http://{{ $webhooks_url }} - webhooksweb_e: http://{{ $webhooksweb_url }} + mvc_e: {{ $protocol }}://{{ $mvc_url }} + spa_e: {{ $protocol }}://{{ $spa_url }} + basket_e: {{ $protocol }}://{{ $basket_url }} + ordering_e: {{ $protocol }}://{{ $ordering_url }} + mobileshoppingagg_e: {{ $protocol }}://{{ $mobileshoppingagg }} + webshoppingagg_e: {{ $protocol }}://{{ $webhoppingagg }} + xamarin_callback_e: {{ $protocol }}://{{ $xamarincallback }} + webhooksapi_e: {{ $protocol }}://{{ $webhooks_url }} + webhooksweb_e: {{ $protocol }}://{{ $webhooksweb_url }} enableDevspaces: "{{ .Values.enableDevspaces }}" \ No newline at end of file diff --git a/deploy/k8s/helm/identity-api/templates/deployment.yaml b/deploy/k8s/helm/identity-api/templates/deployment.yaml index f2e7d60781..a33ffeb740 100644 --- a/deploy/k8s/helm/identity-api/templates/deployment.yaml +++ b/deploy/k8s/helm/identity-api/templates/deployment.yaml @@ -21,7 +21,7 @@ spec: labels: app: {{ template "identity-api.name" . }} release: {{ .Release.Name }} - {{ if .Values.inf.mesh.enabled -}} + {{ if .Values.inf.mesh.linkerd -}} annotations: linkerd.io/inject: enabled {{- end }} diff --git a/deploy/k8s/helm/identity-api/templates/ingress-dockerk8s.yaml b/deploy/k8s/helm/identity-api/templates/ingress-dockerk8s.yaml index c8a29400cd..3cdfe59ef2 100644 --- a/deploy/k8s/helm/identity-api/templates/ingress-dockerk8s.yaml +++ b/deploy/k8s/helm/identity-api/templates/ingress-dockerk8s.yaml @@ -1,4 +1,4 @@ -{{- if .Values.ingress.enabled -}} +{{- if and .Values.ingress.enabled (not .Values.inf.mesh.istio) -}} {{- if .Values.inf.k8s.local -}} {{- $ingressPath := include "pathBase" . -}} {{- $serviceName := .Values.app.svc.identity }} @@ -16,7 +16,7 @@ metadata: annotations: {{ toYaml . | indent 4 }} {{- end }} -{{- if .Values.inf.mesh.enabled }} +{{- if .Values.inf.mesh.linkerd }} {{- with .Values.ingress.mesh.annotations }} {{ toYaml . | indent 4 }} {{- end }} diff --git a/deploy/k8s/helm/identity-api/templates/ingress.yaml b/deploy/k8s/helm/identity-api/templates/ingress.yaml index 4685926581..dd3918b358 100644 --- a/deploy/k8s/helm/identity-api/templates/ingress.yaml +++ b/deploy/k8s/helm/identity-api/templates/ingress.yaml @@ -1,4 +1,4 @@ -{{- if .Values.ingress.enabled -}} +{{- if and .Values.ingress.enabled (not .Values.inf.mesh.istio) -}} {{- $ingressPath := include "pathBase" . -}} {{- $serviceName := .Values.app.svc.identity }} apiVersion: networking.k8s.io/v1 @@ -17,7 +17,7 @@ metadata: {{- if and .Values.inf.tls.enabled .Values.inf.tls.issuer }} cert-manager.io/issuer: {{ .Values.inf.tls.issuer }} {{- end }} -{{- if .Values.inf.mesh.enabled }} +{{- if .Values.inf.mesh.linkerd }} {{- with .Values.ingress.mesh.annotations }} {{ toYaml . | indent 4 }} {{- end }} diff --git a/deploy/k8s/helm/identity-api/templates/ingresss-istio.yaml b/deploy/k8s/helm/identity-api/templates/ingresss-istio.yaml new file mode 100644 index 0000000000..c3232af085 --- /dev/null +++ b/deploy/k8s/helm/identity-api/templates/ingresss-istio.yaml @@ -0,0 +1,44 @@ +{{- if .Values.ingress.enabled -}} +{{- if .Values.inf.mesh.istio -}} +{{- $ingressPath := include "pathBase" . -}} +{{- $serviceName := .Values.app.svc.identity }} +apiVersion: networking.istio.io/v1alpha3 +kind: VirtualService +metadata: + name: {{ template "identity-api.fullname" . }} + labels: + app: {{ template "identity-api.name" . }} + chart: {{ template "identity-api.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +{{- if and .Values.inf.tls.enabled .Values.inf.tls.issuer }} + annotations: + cert-manager.io/issuer: {{ .Values.inf.tls.issuer }} +{{- end }} +{{- if .Values.inf.mesh.istio }} +{{- with .Values.ingress.mesh.annotations }} +{{ toYaml . | indent 4 }} +{{- end }} +{{- end }} +spec: + hosts: + {{- range .Values.ingress.hosts }} + - {{ . }} + {{- end }} + gateways: + {{- range .Values.ingress.gateways }} + - {{ . }} + {{- end }} + http: + {{- range .Values.ingress.hosts }} + - route: + - destination: + host: {{ $serviceName }} + port: + number: 80 + match: + - uri: + prefix: {{ $ingressPath }} + {{- end }} +{{- end }} +{{- end }} diff --git a/deploy/k8s/helm/identity-api/values.yaml b/deploy/k8s/helm/identity-api/values.yaml index 92fd57283b..4707ce1cbb 100644 --- a/deploy/k8s/helm/identity-api/values.yaml +++ b/deploy/k8s/helm/identity-api/values.yaml @@ -30,7 +30,7 @@ affinity: {} env: urls: configmap: - - name: ConnectionString + - name: ConnectionStrings__IdentityDb key: identity__ConnectionString - name: DPConnectionString key: identity__keystore diff --git a/deploy/k8s/helm/inf.yaml b/deploy/k8s/helm/inf.yaml index 8ed680d6b1..78725d0814 100644 --- a/deploy/k8s/helm/inf.yaml +++ b/deploy/k8s/helm/inf.yaml @@ -3,7 +3,8 @@ inf: mesh: - enabled: false # True to enable Linkerd (set by deploy-all.ps1) + linkerd: false # True to enable Linkerd (set by deploy-all.ps1) + istio: false # True to enable Istio (set by deploy-all.ps1) tls: enabled: false # True to enable TLS (set by deploy-all.ps1) issuer: "" # cert-manager issuer to use for retrieving certs (set by deploy-all.ps1) @@ -48,3 +49,9 @@ inf: # login: # User login # pwd: # User pwd +env: + values: + - name: Kestrel__Endpoints__Http__Url + value: http://0.0.0.0:80 + - name: Kestrel__Endpoints__gRPC__Url + value: http://0.0.0.0:81 diff --git a/deploy/k8s/helm/ingress_values_istio.yaml b/deploy/k8s/helm/ingress_values_istio.yaml new file mode 100644 index 0000000000..998ba38f58 --- /dev/null +++ b/deploy/k8s/helm/ingress_values_istio.yaml @@ -0,0 +1,13 @@ +# This file contains extra annotations to make Istio work. +# ingress.mesh.annotations are inserted into ingress.annotations of the resource being generated, if mesh is deployed +# +# It is designed to work as a placehoder +# +# Check https://istio.io/latest/docs/reference/config/annotations/ for more info +# +# If using your custom file, use -ingressMeshAnnotationsFile parameter in deploy-all.ps1 + + +ingress: + mesh: + annotations: {} \ No newline at end of file diff --git a/deploy/k8s/helm/mobileshoppingagg/templates/deployment.yaml b/deploy/k8s/helm/mobileshoppingagg/templates/deployment.yaml index eb0f4f536b..ad3fd1d518 100644 --- a/deploy/k8s/helm/mobileshoppingagg/templates/deployment.yaml +++ b/deploy/k8s/helm/mobileshoppingagg/templates/deployment.yaml @@ -21,7 +21,7 @@ spec: labels: app: {{ template "mobileshoppingagg.name" . }} release: {{ .Release.Name }} - {{ if .Values.inf.mesh.enabled -}} + {{ if .Values.inf.mesh.linkerd -}} annotations: linkerd.io/inject: enabled {{- end }} diff --git a/deploy/k8s/helm/ordering-api/templates/deployment.yaml b/deploy/k8s/helm/ordering-api/templates/deployment.yaml index 4e25dcbb61..c2f55f03aa 100644 --- a/deploy/k8s/helm/ordering-api/templates/deployment.yaml +++ b/deploy/k8s/helm/ordering-api/templates/deployment.yaml @@ -21,7 +21,7 @@ spec: labels: app: {{ template "ordering-api.name" . }} release: {{ .Release.Name }} - {{ if .Values.inf.mesh.enabled -}} + {{ if .Values.inf.mesh.linkerd -}} annotations: linkerd.io/inject: enabled {{- end }} diff --git a/deploy/k8s/helm/ordering-api/values.yaml b/deploy/k8s/helm/ordering-api/values.yaml index 505ccc3793..4425adcc81 100644 --- a/deploy/k8s/helm/ordering-api/values.yaml +++ b/deploy/k8s/helm/ordering-api/values.yaml @@ -33,15 +33,15 @@ env: urls: # configmap declares variables which value is taken from the config map defined in template configmap.yaml (name is name of var and key the key in configmap). configmap: - - name: ConnectionString + - name: ConnectionStrings__OrderingDb key: ordering__ConnectionString - name: ApplicationInsights__InstrumentationKey key: all__InstrumentationKey - - name: EventBusConnection + - name: ConnectionStrings__EventBus key: all__EventBusConnection - name: AzureServiceBusEnabled key: all__UseAzureServiceBus - - name: IdentityUrl + - name: Identity__Url key: urls__IdentityUrl # values define environment variables with a fixed value (no configmap involved) (name is name of var, and value is its value) values: diff --git a/deploy/k8s/helm/ordering-backgroundtasks/values.yaml b/deploy/k8s/helm/ordering-backgroundtasks/values.yaml index 18abe99a53..71bc163b1f 100644 --- a/deploy/k8s/helm/ordering-backgroundtasks/values.yaml +++ b/deploy/k8s/helm/ordering-backgroundtasks/values.yaml @@ -36,11 +36,11 @@ env: urls: # configmap declares variables which value is taken from the config map defined in template configmap.yaml (name is name of var and key the key in configmap). configmap: - - name: ConnectionString + - name: ConnectionStrings__OrderingDb key: ordering__ConnectionString - name: ApplicationInsights__InstrumentationKey key: all__InstrumentationKey - - name: EventBusConnection + - name: ConnectionStrings__EventBus key: all__EventBusConnection - name: AzureServiceBusEnabled key: all__UseAzureServiceBus diff --git a/deploy/k8s/helm/ordering-signalrhub/values.yaml b/deploy/k8s/helm/ordering-signalrhub/values.yaml index 19099b147c..c6e47afb14 100644 --- a/deploy/k8s/helm/ordering-signalrhub/values.yaml +++ b/deploy/k8s/helm/ordering-signalrhub/values.yaml @@ -38,11 +38,11 @@ env: configmap: - name: ApplicationInsights__InstrumentationKey key: all__InstrumentationKey - - name: EventBusConnection + - name: ConnectionStrings__EventBus key: all__EventBusConnection - name: AzureServiceBusEnabled key: all__UseAzureServiceBus - - name: IdentityUrl + - name: Identity__Url key: urls__IdentityUrl - name: SignalrStoreConnectionString key: signalr__StoreConnectionString diff --git a/deploy/k8s/helm/payment-api/templates/deployment.yaml b/deploy/k8s/helm/payment-api/templates/deployment.yaml index df0bbe7d13..36e0e40741 100644 --- a/deploy/k8s/helm/payment-api/templates/deployment.yaml +++ b/deploy/k8s/helm/payment-api/templates/deployment.yaml @@ -21,7 +21,7 @@ spec: labels: app: {{ template "payment-api.name" . }} release: {{ .Release.Name }} - {{ if .Values.inf.mesh.enabled -}} + {{ if .Values.inf.mesh.linkerd -}} annotations: linkerd.io/inject: enabled {{- end }} diff --git a/deploy/k8s/helm/payment-api/values.yaml b/deploy/k8s/helm/payment-api/values.yaml index 341e4e1a95..4de342f49e 100644 --- a/deploy/k8s/helm/payment-api/values.yaml +++ b/deploy/k8s/helm/payment-api/values.yaml @@ -32,7 +32,7 @@ env: configmap: - name: ApplicationInsights__InstrumentationKey key: all__InstrumentationKey - - name: EventBusConnection + - name: ConnectionStrings__EventBus key: all__EventBusConnection - name: AzureServiceBusEnabled key: all__UseAzureServiceBus diff --git a/deploy/k8s/helm/webhooks-api/templates/deployment.yaml b/deploy/k8s/helm/webhooks-api/templates/deployment.yaml index 16aeecd91d..16bf8359b9 100644 --- a/deploy/k8s/helm/webhooks-api/templates/deployment.yaml +++ b/deploy/k8s/helm/webhooks-api/templates/deployment.yaml @@ -21,7 +21,7 @@ spec: labels: app: {{ template "webhooks-api.name" . }} release: {{ .Release.Name }} - {{ if .Values.inf.mesh.enabled -}} + {{ if .Values.inf.mesh.linkerd -}} annotations: linkerd.io/inject: enabled {{- end }} diff --git a/deploy/k8s/helm/webhooks-api/templates/ingress.yaml b/deploy/k8s/helm/webhooks-api/templates/ingress.yaml index 32effa98e8..f9596f8621 100644 --- a/deploy/k8s/helm/webhooks-api/templates/ingress.yaml +++ b/deploy/k8s/helm/webhooks-api/templates/ingress.yaml @@ -1,4 +1,4 @@ -{{- if .Values.ingress.enabled -}} +{{- if and .Values.ingress.enabled (not .Values.inf.mesh.istio) -}} {{- $ingressPath := include "pathBase" . -}} {{- $serviceName := .Values.app.svc.webhooks }} apiVersion: networking.k8s.io/v1 @@ -17,7 +17,7 @@ metadata: {{- if and .Values.inf.tls.enabled .Values.inf.tls.issuer }} cert-manager.io/issuer: {{ .Values.inf.tls.issuer }} {{- end }} -{{- if .Values.inf.mesh.enabled }} +{{- if .Values.inf.mesh.linkerd }} {{- with .Values.ingress.mesh.annotations }} {{ toYaml . | indent 4 }} {{- end }} diff --git a/deploy/k8s/helm/webhooks-api/templates/ingresss-istio.yaml b/deploy/k8s/helm/webhooks-api/templates/ingresss-istio.yaml new file mode 100644 index 0000000000..cb2dad4fc0 --- /dev/null +++ b/deploy/k8s/helm/webhooks-api/templates/ingresss-istio.yaml @@ -0,0 +1,44 @@ +{{- if .Values.ingress.enabled -}} +{{- if .Values.inf.mesh.istio -}} +{{- $ingressPath := include "pathBase" . -}} +{{- $serviceName := .Values.app.svc.webhooks }} +apiVersion: networking.istio.io/v1alpha3 +kind: VirtualService +metadata: + name: {{ template "webhooks-api.fullname" . }} + labels: + app: {{ template "webhooks-api.name" . }} + chart: {{ template "webhooks-api.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +{{- if and .Values.inf.tls.enabled .Values.inf.tls.issuer }} + annotations: + cert-manager.io/issuer: {{ .Values.inf.tls.issuer }} +{{- end }} +{{- if .Values.inf.mesh.istio }} +{{- with .Values.ingress.mesh.annotations }} +{{ toYaml . | indent 4 }} +{{- end }} +{{- end }} +spec: + hosts: + {{- range .Values.ingress.hosts }} + - {{ . }} + {{- end }} + gateways: + {{- range .Values.ingress.gateways }} + - {{ . }} + {{- end }} + http: + {{- range .Values.ingress.hosts }} + - route: + - destination: + host: {{ $serviceName }} + port: + number: 80 + match: + - uri: + prefix: {{ $ingressPath }} + {{- end }} +{{- end }} +{{- end }} diff --git a/deploy/k8s/helm/webhooks-api/values.yaml b/deploy/k8s/helm/webhooks-api/values.yaml index f6b1957e93..50b67c62fe 100644 --- a/deploy/k8s/helm/webhooks-api/values.yaml +++ b/deploy/k8s/helm/webhooks-api/values.yaml @@ -32,11 +32,11 @@ env: urls: # configmap declares variables which value is taken from the config map defined in template configmap.yaml (name is name of var and key the key in configmap). configmap: - - name: ConnectionString + - name: ConnectionStrings__WebHooksDB key: webhooks__ConnectionString - name: ApplicationInsights__InstrumentationKey key: all__InstrumentationKey - - name: EventBusConnection + - name: ConnectionStrings__EventBus key: all__EventBusConnection - name: AzureServiceBusEnabled key: all__UseAzureServiceBus diff --git a/deploy/k8s/helm/webhooks-web/templates/deployment.yaml b/deploy/k8s/helm/webhooks-web/templates/deployment.yaml index 7ee3572f5f..933748e8df 100644 --- a/deploy/k8s/helm/webhooks-web/templates/deployment.yaml +++ b/deploy/k8s/helm/webhooks-web/templates/deployment.yaml @@ -21,7 +21,7 @@ spec: labels: app: {{ template "webhooks-web.name" . }} release: {{ .Release.Name }} - {{ if .Values.inf.mesh.enabled -}} + {{ if .Values.inf.mesh.linkerd -}} annotations: linkerd.io/inject: enabled {{- end }} diff --git a/deploy/k8s/helm/webhooks-web/templates/ingress.yaml b/deploy/k8s/helm/webhooks-web/templates/ingress.yaml index a2644add18..9eade7da60 100644 --- a/deploy/k8s/helm/webhooks-web/templates/ingress.yaml +++ b/deploy/k8s/helm/webhooks-web/templates/ingress.yaml @@ -1,4 +1,4 @@ -{{- if .Values.ingress.enabled -}} +{{- if and .Values.ingress.enabled (not .Values.inf.mesh.istio) -}} {{- $ingressPath := include "pathBase" . -}} {{- $serviceName := $.Values.app.svc.webhooksweb -}} @@ -18,7 +18,7 @@ metadata: {{- if and .Values.inf.tls.enabled .Values.inf.tls.issuer }} cert-manager.io/issuer: {{ .Values.inf.tls.issuer }} {{- end }} -{{- if .Values.inf.mesh.enabled }} +{{- if .Values.inf.mesh.linkerd }} {{- with .Values.ingress.mesh.annotations }} {{ toYaml . | indent 4 }} {{- end }} diff --git a/deploy/k8s/helm/webhooks-web/templates/ingresss-istio.yaml b/deploy/k8s/helm/webhooks-web/templates/ingresss-istio.yaml new file mode 100644 index 0000000000..cc1dc80040 --- /dev/null +++ b/deploy/k8s/helm/webhooks-web/templates/ingresss-istio.yaml @@ -0,0 +1,44 @@ +{{- if .Values.ingress.enabled -}} +{{- if .Values.inf.mesh.istio -}} +{{- $ingressPath := include "pathBase" . -}} +{{- $serviceName := $.Values.app.svc.webhooksweb -}} +apiVersion: networking.istio.io/v1alpha3 +kind: VirtualService +metadata: + name: {{ template "webhooks-web.fullname" . }} + labels: + app: {{ template "webhooks-web.name" . }} + chart: {{ template "webhooks-web.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +{{- if and .Values.inf.tls.enabled .Values.inf.tls.issuer }} + annotations: + cert-manager.io/issuer: {{ .Values.inf.tls.issuer }} +{{- end }} +{{- if .Values.inf.mesh.istio }} +{{- with .Values.ingress.mesh.annotations }} +{{ toYaml . | indent 4 }} +{{- end }} +{{- end }} +spec: + hosts: + {{- range .Values.ingress.hosts }} + - {{ . }} + {{- end }} + gateways: + {{- range .Values.ingress.gateways }} + - {{ . }} + {{- end }} + http: + {{- range .Values.ingress.hosts }} + - route: + - destination: + host: {{ $serviceName }} + port: + number: 80 + match: + - uri: + prefix: {{ $ingressPath }} + {{- end }} +{{- end }} +{{- end }} diff --git a/deploy/k8s/helm/webmvc/templates/deployment.yaml b/deploy/k8s/helm/webmvc/templates/deployment.yaml index 2e1162be1a..d5abeb54b6 100644 --- a/deploy/k8s/helm/webmvc/templates/deployment.yaml +++ b/deploy/k8s/helm/webmvc/templates/deployment.yaml @@ -21,7 +21,7 @@ spec: labels: app: {{ template "webmvc.name" . }} release: {{ .Release.Name }} - {{ if .Values.inf.mesh.enabled -}} + {{ if .Values.inf.mesh.linkerd -}} annotations: linkerd.io/inject: enabled {{- end }} diff --git a/deploy/k8s/helm/webmvc/templates/ingress-dockerk8s.yaml b/deploy/k8s/helm/webmvc/templates/ingress-dockerk8s.yaml index 074da7e889..a9d5453bda 100644 --- a/deploy/k8s/helm/webmvc/templates/ingress-dockerk8s.yaml +++ b/deploy/k8s/helm/webmvc/templates/ingress-dockerk8s.yaml @@ -1,4 +1,4 @@ -{{- if .Values.ingress.enabled -}} +{{- if and .Values.ingress.enabled (not .Values.inf.mesh.istio) -}} {{- if .Values.inf.k8s.local -}} {{- $ingressPath := include "pathBase" . -}} {{- $serviceName := .Values.app.svc.mvc }} @@ -16,7 +16,7 @@ metadata: annotations: {{ toYaml . | indent 4 }} {{- end }} -{{- if .Values.inf.mesh.enabled }} +{{- if .Values.inf.mesh.linkerd }} {{- with .Values.ingress.mesh.annotations }} {{ toYaml . | indent 4 }} {{- end }} diff --git a/deploy/k8s/helm/webmvc/templates/ingress.yaml b/deploy/k8s/helm/webmvc/templates/ingress.yaml index 2e5b49a890..763ffd7dad 100644 --- a/deploy/k8s/helm/webmvc/templates/ingress.yaml +++ b/deploy/k8s/helm/webmvc/templates/ingress.yaml @@ -1,4 +1,4 @@ -{{- if .Values.ingress.enabled -}} +{{- if and .Values.ingress.enabled (not .Values.inf.mesh.istio) -}} {{- $ingressPath := include "pathBase" . -}} {{- $serviceName := .Values.app.svc.mvc -}} apiVersion: networking.k8s.io/v1 @@ -17,7 +17,7 @@ metadata: {{- if and .Values.inf.tls.enabled .Values.inf.tls.issuer }} cert-manager.io/issuer: {{ .Values.inf.tls.issuer }} {{- end }} -{{- if .Values.inf.mesh.enabled }} +{{- if .Values.inf.mesh.linkerd }} {{- with .Values.ingress.mesh.annotations }} {{ toYaml . | indent 4 }} {{- end }} diff --git a/deploy/k8s/helm/webmvc/templates/ingresss-istio.yaml b/deploy/k8s/helm/webmvc/templates/ingresss-istio.yaml new file mode 100644 index 0000000000..54edb2a25e --- /dev/null +++ b/deploy/k8s/helm/webmvc/templates/ingresss-istio.yaml @@ -0,0 +1,44 @@ +{{- if .Values.ingress.enabled -}} +{{- if .Values.inf.mesh.istio -}} +{{- $ingressPath := include "pathBase" . -}} +{{- $serviceName := .Values.app.svc.mvc -}} +apiVersion: networking.istio.io/v1alpha3 +kind: VirtualService +metadata: + name: {{ template "webmvc.fullname" . }} + labels: + app: {{ template "webmvc.name" . }} + chart: {{ template "webmvc.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +{{- if and .Values.inf.tls.enabled .Values.inf.tls.issuer }} + annotations: + cert-manager.io/issuer: {{ .Values.inf.tls.issuer }} +{{- end }} +{{- if .Values.inf.mesh.istio }} +{{- with .Values.ingress.mesh.annotations }} +{{ toYaml . | indent 4 }} +{{- end }} +{{- end }} +spec: + hosts: + {{- range .Values.ingress.hosts }} + - {{ . }} + {{- end }} + gateways: + {{- range .Values.ingress.gateways }} + - {{ . }} + {{- end }} + http: + {{- range .Values.ingress.hosts }} + - route: + - destination: + host: {{ $serviceName }} + port: + number: 80 + match: + - uri: + prefix: {{ $ingressPath }} + {{- end }} +{{- end }} +{{- end }} diff --git a/deploy/k8s/helm/webshoppingagg/templates/deployment.yaml b/deploy/k8s/helm/webshoppingagg/templates/deployment.yaml index 3e82f1a0e6..80a20fcb28 100644 --- a/deploy/k8s/helm/webshoppingagg/templates/deployment.yaml +++ b/deploy/k8s/helm/webshoppingagg/templates/deployment.yaml @@ -20,7 +20,7 @@ spec: labels: app: {{ template "webshoppingagg.name" . }} release: {{ .Release.Name }} - {{ if .Values.inf.mesh.enabled -}} + {{ if .Values.inf.mesh.linkerd -}} annotations: linkerd.io/inject: enabled {{- end }} diff --git a/deploy/k8s/helm/webshoppingagg/templates/ingress.yaml b/deploy/k8s/helm/webshoppingagg/templates/ingress.yaml new file mode 100644 index 0000000000..c4780fb11b --- /dev/null +++ b/deploy/k8s/helm/webshoppingagg/templates/ingress.yaml @@ -0,0 +1,49 @@ +{{- if and .Values.ingress.enabled (not .Values.inf.mesh.istio) -}} +{{- $ingressPath := include "pathBase" . -}} +{{- $serviceName := .Values.app.svc.webshoppingagg -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ template "webshoppingagg.fullname" . }} + labels: + app: {{ template "webshoppingagg.name" . }} + chart: {{ template "webshoppingagg.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +{{- with .Values.ingress.annotations }} + annotations: +{{ toYaml . | indent 4 }} +{{- end }} +{{- if and .Values.inf.tls.enabled .Values.inf.tls.issuer }} + cert-manager.io/issuer: {{ .Values.inf.tls.issuer }} +{{- end }} +{{- if .Values.inf.mesh.linkerd }} +{{- with .Values.ingress.mesh.annotations }} +{{ toYaml . | indent 4 }} +{{- end }} +{{- end }} +spec: +{{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} +{{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ . }} + http: + paths: + - path: {{ $ingressPath }} + pathType: Prefix + backend: + service: + name: {{ $serviceName }} + port: + number: 80 + {{- end }} +{{- end }} diff --git a/deploy/k8s/helm/webshoppingagg/templates/ingresss-istio.yaml b/deploy/k8s/helm/webshoppingagg/templates/ingresss-istio.yaml new file mode 100644 index 0000000000..c8d0396994 --- /dev/null +++ b/deploy/k8s/helm/webshoppingagg/templates/ingresss-istio.yaml @@ -0,0 +1,44 @@ +{{- if .Values.ingress.enabled -}} +{{- if .Values.inf.mesh.istio -}} +{{- $ingressPath := include "pathBase" . -}} +{{- $serviceName := .Values.app.svc.webshoppingagg -}} +apiVersion: networking.istio.io/v1alpha3 +kind: VirtualService +metadata: + name: {{ template "webshoppingagg.fullname" . }} + labels: + app: {{ template "webshoppingagg.name" . }} + chart: {{ template "webshoppingagg.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +{{- if and .Values.inf.tls.enabled .Values.inf.tls.issuer }} + annotations: + cert-manager.io/issuer: {{ .Values.inf.tls.issuer }} +{{- end }} +{{- if .Values.inf.mesh.istio }} +{{- with .Values.ingress.mesh.annotations }} +{{ toYaml . | indent 4 }} +{{- end }} +{{- end }} +spec: + hosts: + {{- range .Values.ingress.hosts }} + - {{ . }} + {{- end }} + gateways: + {{- range .Values.ingress.gateways }} + - {{ . }} + {{- end }} + http: + {{- range .Values.ingress.hosts }} + - route: + - destination: + host: {{ $serviceName }} + port: + number: 80 + match: + - uri: + prefix: {{ $ingressPath }} + {{- end }} +{{- end }} +{{- end }} diff --git a/deploy/k8s/helm/webshoppingagg/values.yaml b/deploy/k8s/helm/webshoppingagg/values.yaml index b85210afa5..15ceb3c74a 100644 --- a/deploy/k8s/helm/webshoppingagg/values.yaml +++ b/deploy/k8s/helm/webshoppingagg/values.yaml @@ -57,7 +57,7 @@ env: key: internalurls__grpcCatalog - name: urls__grpcOrdering key: internalurls__grpcOrdering - - name: IdentityUrlExternal + - name: Identity__Url key: urls__IdentityUrlExternal # values define environment variables with a fixed value (no configmap involved) (name is name of var, and value is its value) diff --git a/deploy/k8s/helm/webspa/templates/deployment.yaml b/deploy/k8s/helm/webspa/templates/deployment.yaml index 4cffcdb8f1..c42b325507 100644 --- a/deploy/k8s/helm/webspa/templates/deployment.yaml +++ b/deploy/k8s/helm/webspa/templates/deployment.yaml @@ -21,7 +21,7 @@ spec: labels: app: {{ template "webspa.name" . }} release: {{ .Release.Name }} - {{ if .Values.inf.mesh.enabled -}} + {{ if .Values.inf.mesh.linkerd -}} annotations: linkerd.io/inject: enabled {{- end }} diff --git a/deploy/k8s/helm/webspa/templates/ingress.yaml b/deploy/k8s/helm/webspa/templates/ingress.yaml index b684f48985..6f76a09b79 100644 --- a/deploy/k8s/helm/webspa/templates/ingress.yaml +++ b/deploy/k8s/helm/webspa/templates/ingress.yaml @@ -1,4 +1,4 @@ -{{- if .Values.ingress.enabled -}} +{{- if and .Values.ingress.enabled (not .Values.inf.mesh.istio) -}} {{- $ingressPath := include "pathBase" . -}} {{- $serviceName := $.Values.app.svc.spa -}} @@ -18,7 +18,7 @@ metadata: {{- if and .Values.inf.tls.enabled .Values.inf.tls.issuer }} cert-manager.io/issuer: {{ .Values.inf.tls.issuer }} {{- end }} -{{- if .Values.inf.mesh.enabled }} +{{- if .Values.inf.mesh.linkerd }} {{- with .Values.ingress.mesh.annotations }} {{ toYaml . | indent 4 }} {{- end }} diff --git a/deploy/k8s/helm/webspa/templates/ingresss-istio.yaml b/deploy/k8s/helm/webspa/templates/ingresss-istio.yaml new file mode 100644 index 0000000000..a060029e3b --- /dev/null +++ b/deploy/k8s/helm/webspa/templates/ingresss-istio.yaml @@ -0,0 +1,44 @@ +{{- if .Values.ingress.enabled -}} +{{- if .Values.inf.mesh.istio -}} +{{- $ingressPath := include "pathBase" . -}} +{{- $serviceName := $.Values.app.svc.spa -}} +apiVersion: networking.istio.io/v1alpha3 +kind: VirtualService +metadata: + name: {{ template "webspa.fullname" . }} + labels: + app: {{ template "webspa.name" . }} + chart: {{ template "webspa.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +{{- if and .Values.inf.tls.enabled .Values.inf.tls.issuer }} + annotations: + cert-manager.io/issuer: {{ .Values.inf.tls.issuer }} +{{- end }} +{{- if .Values.inf.mesh.istio }} +{{- with .Values.ingress.mesh.annotations }} +{{ toYaml . | indent 4 }} +{{- end }} +{{- end }} +spec: + hosts: + {{- range .Values.ingress.hosts }} + - {{ . }} + {{- end }} + gateways: + {{- range .Values.ingress.gateways }} + - {{ . }} + {{- end }} + http: + {{- range .Values.ingress.hosts }} + - route: + - destination: + host: {{ $serviceName }} + port: + number: 80 + match: + - uri: + prefix: {{ $ingressPath }} + {{- end }} +{{- end }} +{{- end }} diff --git a/deploy/k8s/helm/webstatus/templates/deployment.yaml b/deploy/k8s/helm/webstatus/templates/deployment.yaml index 33ab7e0567..73358a5e24 100644 --- a/deploy/k8s/helm/webstatus/templates/deployment.yaml +++ b/deploy/k8s/helm/webstatus/templates/deployment.yaml @@ -21,7 +21,7 @@ spec: labels: app: {{ template "webstatus.name" . }} release: {{ .Release.Name }} - {{ if .Values.inf.mesh.enabled -}} + {{ if .Values.inf.mesh.linkerd -}} annotations: linkerd.io/inject: enabled {{- end }} diff --git a/deploy/k8s/helm/webstatus/templates/ingress.yaml b/deploy/k8s/helm/webstatus/templates/ingress.yaml index 6ec79d0dd0..11aae28320 100644 --- a/deploy/k8s/helm/webstatus/templates/ingress.yaml +++ b/deploy/k8s/helm/webstatus/templates/ingress.yaml @@ -1,4 +1,4 @@ -{{- if .Values.ingress.enabled -}} +{{- if and .Values.ingress.enabled (not .Values.inf.mesh.istio) -}} {{- $fullName := include "webstatus.fullname" . -}} {{- $ingressPath := include "pathBase" . -}} {{- $serviceName := $.Values.app.svc.status -}} @@ -19,7 +19,7 @@ metadata: {{- if and .Values.inf.tls.enabled .Values.inf.tls.issuer }} cert-manager.io/issuer: {{ .Values.inf.tls.issuer }} {{- end }} -{{- if .Values.inf.mesh.enabled }} +{{- if .Values.inf.mesh.linkerd }} {{- with .Values.ingress.mesh.annotations }} {{ toYaml . | indent 4 }} {{- end }} diff --git a/deploy/k8s/helm/webstatus/templates/ingresss-istio.yaml b/deploy/k8s/helm/webstatus/templates/ingresss-istio.yaml new file mode 100644 index 0000000000..8df228f4bf --- /dev/null +++ b/deploy/k8s/helm/webstatus/templates/ingresss-istio.yaml @@ -0,0 +1,44 @@ +{{- if .Values.ingress.enabled -}} +{{- if .Values.inf.mesh.istio -}} +{{- $ingressPath := include "pathBase" . -}} +{{- $serviceName := $.Values.app.svc.status -}} +apiVersion: networking.istio.io/v1alpha3 +kind: VirtualService +metadata: + name: {{ template "webstatus.fullname" . }} + labels: + app: {{ template "webstatus.name" . }} + chart: {{ template "webstatus.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +{{- if and .Values.inf.tls.enabled .Values.inf.tls.issuer }} + annotations: + cert-manager.io/issuer: {{ .Values.inf.tls.issuer }} +{{- end }} +{{- if .Values.inf.mesh.istio }} +{{- with .Values.ingress.mesh.annotations }} +{{ toYaml . | indent 4 }} +{{- end }} +{{- end }} +spec: + hosts: + {{- range .Values.ingress.hosts }} + - {{ . }} + {{- end }} + gateways: + {{- range .Values.ingress.gateways }} + - {{ . }} + {{- end }} + http: + {{- range .Values.ingress.hosts }} + - route: + - destination: + host: {{ $serviceName }} + port: + number: 80 + match: + - uri: + prefix: {{ $ingressPath }} + {{- end }} +{{- end }} +{{- end }} diff --git a/src/Services/Ordering/Ordering.SignalrHub/Program.cs b/src/Services/Ordering/Ordering.SignalrHub/Program.cs index 1b0abd0994..b2cbbc32c0 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/Program.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/Program.cs @@ -4,12 +4,12 @@ builder.Services.AddSignalR(builder.Configuration); -builder.Services.AddSingleton, OrderStatusChangedToAwaitingValidationIntegrationEventHandler>(); -builder.Services.AddSingleton, OrderStatusChangedToCancelledIntegrationEventHandler>(); -builder.Services.AddSingleton, OrderStatusChangedToPaidIntegrationEventHandler>(); -builder.Services.AddSingleton, OrderStatusChangedToShippedIntegrationEventHandler>(); -builder.Services.AddSingleton, OrderStatusChangedToStockConfirmedIntegrationEventHandler>(); -builder.Services.AddSingleton, OrderStatusChangedToSubmittedIntegrationEventHandler>(); +builder.Services.AddTransient, OrderStatusChangedToAwaitingValidationIntegrationEventHandler>(); +builder.Services.AddTransient, OrderStatusChangedToCancelledIntegrationEventHandler>(); +builder.Services.AddTransient, OrderStatusChangedToPaidIntegrationEventHandler>(); +builder.Services.AddTransient, OrderStatusChangedToShippedIntegrationEventHandler>(); +builder.Services.AddTransient, OrderStatusChangedToStockConfirmedIntegrationEventHandler>(); +builder.Services.AddTransient, OrderStatusChangedToSubmittedIntegrationEventHandler>(); var app = builder.Build(); @@ -19,11 +19,11 @@ var eventBus = app.Services.GetRequiredService(); -eventBus.Subscribe(); -eventBus.Subscribe(); -eventBus.Subscribe(); -eventBus.Subscribe(); -eventBus.Subscribe(); -eventBus.Subscribe(); +eventBus.Subscribe>(); +eventBus.Subscribe>(); +eventBus.Subscribe>(); +eventBus.Subscribe>(); +eventBus.Subscribe>(); +eventBus.Subscribe>(); await app.RunAsync(); diff --git a/src/Services/Services.Common/CommonExtensions.cs b/src/Services/Services.Common/CommonExtensions.cs index 1d666edd2c..4718359c95 100644 --- a/src/Services/Services.Common/CommonExtensions.cs +++ b/src/Services/Services.Common/CommonExtensions.cs @@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Diagnostics.HealthChecks; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.HttpOverrides; using Microsoft.AspNetCore.Routing; using Microsoft.eShopOnContainers.BuildingBlocks.EventBus; using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; @@ -48,6 +49,15 @@ public static WebApplicationBuilder AddServiceDefaults(this WebApplicationBuilde public static WebApplication UseServiceDefaults(this WebApplication app) { + var forwardingOptions = new ForwardedHeadersOptions() + { + ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto + }; + forwardingOptions.KnownNetworks.Clear(); + forwardingOptions.KnownProxies.Clear(); + + app.UseForwardedHeaders(forwardingOptions); + if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/Home/Error"); diff --git a/src/Web/WebMVC/Views/Shared/_Layout.cshtml b/src/Web/WebMVC/Views/Shared/_Layout.cshtml index 6cb3f43fba..76c3e3532a 100644 --- a/src/Web/WebMVC/Views/Shared/_Layout.cshtml +++ b/src/Web/WebMVC/Views/Shared/_Layout.cshtml @@ -23,7 +23,7 @@ - @@ -77,7 +77,7 @@ asp-fallback-src="~/lib/jquery/jquery.min.js" asp-fallback-test="window.jQuery"> - @@ -94,8 +94,14 @@ } async function connect() { + // Get the current URL base path + var baseUrl = "@Url.Content("~/")"; + + // Build the SignalR hub URL based on the current path + const hubUrl = `${baseUrl}hub/notificationhub`; + let connection = new signalR.HubConnectionBuilder() - .withUrl('/hub/notificationhub') + .withUrl(hubUrl) .withAutomaticReconnect() .build(); @@ -111,6 +117,7 @@ }); } + function refreshOrderList() { clearTimeout(timerId); timerId = setTimeout(function () { diff --git a/src/Web/WebSPA/Client/src/modules/basket/basket.component.ts b/src/Web/WebSPA/Client/src/modules/basket/basket.component.ts index 8528b516dd..d857213388 100644 --- a/src/Web/WebSPA/Client/src/modules/basket/basket.component.ts +++ b/src/Web/WebSPA/Client/src/modules/basket/basket.component.ts @@ -7,6 +7,7 @@ import { BasketService } from './basket.service'; import { IBasket } from '../shared/models/basket.model'; import { IBasketItem } from '../shared/models/basketItem.model'; import { BasketWrapperService } from '../shared/services/basket.wrapper.service'; +import { ConfigurationService } from '../shared/services/configuration.service'; @Component({ selector: 'esh-basket .esh-basket .mb-5', @@ -18,9 +19,20 @@ export class BasketComponent implements OnInit { basket: IBasket; totalPrice: number = 0; - constructor(private basketSerive: BasketService, private router: Router, private basketWrapperService: BasketWrapperService) { } + constructor(private configurationService: ConfigurationService, private basketSerive: BasketService, private router: Router, private basketWrapperService: BasketWrapperService) { } ngOnInit() { + if (this.configurationService.isReady) { + this.loadBasketData(); + } else { + // Subscribe to the settingsLoaded$ observable to know when settings are ready + this.configurationService.settingsLoaded$.subscribe(() => { + this.loadBasketData(); + }); + } + } + + private loadBasketData() { this.basketSerive.getBasket().subscribe(basket => { this.basket = basket; this.calculateTotalPrice(); diff --git a/src/Web/WebSPA/Client/src/modules/orders/orders-detail/orders-detail.component.ts b/src/Web/WebSPA/Client/src/modules/orders/orders-detail/orders-detail.component.ts index 1ccae3e245..146bf86be4 100644 --- a/src/Web/WebSPA/Client/src/modules/orders/orders-detail/orders-detail.component.ts +++ b/src/Web/WebSPA/Client/src/modules/orders/orders-detail/orders-detail.component.ts @@ -1,6 +1,7 @@ import { Component, OnInit } from '@angular/core'; import { OrdersService } from '../orders.service'; import { IOrderDetail } from '../../shared/models/order-detail.model'; +import { ConfigurationService } from '../../shared/services/configuration.service'; import { ActivatedRoute } from '@angular/router'; @Component({ @@ -11,12 +12,18 @@ import { ActivatedRoute } from '@angular/router'; export class OrdersDetailComponent implements OnInit { public order: IOrderDetail = {}; - constructor(private service: OrdersService, private route: ActivatedRoute) { } + constructor(private configurationService: ConfigurationService, private service: OrdersService, private route: ActivatedRoute) { } ngOnInit() { this.route.params.subscribe(params => { let id = +params['id']; // (+) converts string 'id' to a number - this.getOrder(id); + if (this.configurationService.isReady) { + this.getOrder(id); + } else { + this.configurationService.settingsLoaded$.subscribe(x => { + this.getOrder(id); + }); + } }); }