From 920e908f5b5e9d57cf47484dd391098332ad5edc Mon Sep 17 00:00:00 2001 From: David Sanz Date: Wed, 18 Dec 2019 18:32:22 +0100 Subject: [PATCH] Configure ingress rewrite path and targets depending on the nginx-controller version. (#2) --- Deploy/helm/cart-api/templates/ingress.yaml | 2 +- .../helm/coupons-api/templates/ingress.yaml | 2 +- Deploy/helm/gvalues.template | 26 +++++++++---------- .../templates/ingress.yaml | 2 +- Deploy/helm/login-api/templates/ingress.yaml | 2 +- Deploy/helm/mobilebff/templates/ingress.yaml | 2 +- .../templates/ingress.yaml | 2 +- .../helm/products-api/templates/ingress.yaml | 2 +- .../helm/profiles-api/templates/ingress.yaml | 2 +- .../templates/ingress.yaml | 2 +- Deploy/helm/stock-api/templates/ingress.yaml | 2 +- Deploy/helm/webbff/templates/ingress.yaml | 2 +- Deploy/powershell/Generate-Config.ps1 | 7 +++++ 13 files changed, 31 insertions(+), 24 deletions(-) diff --git a/Deploy/helm/cart-api/templates/ingress.yaml b/Deploy/helm/cart-api/templates/ingress.yaml index 703fa331..fdbb9dd6 100644 --- a/Deploy/helm/cart-api/templates/ingress.yaml +++ b/Deploy/helm/cart-api/templates/ingress.yaml @@ -31,7 +31,7 @@ spec: - host: {{ . }} http: paths: - - path: {{ $ingressPath }}(/|$)(.*) + - path: {{ $ingressPath }} backend: serviceName: cart servicePort: http diff --git a/Deploy/helm/coupons-api/templates/ingress.yaml b/Deploy/helm/coupons-api/templates/ingress.yaml index ed39345a..6533904d 100644 --- a/Deploy/helm/coupons-api/templates/ingress.yaml +++ b/Deploy/helm/coupons-api/templates/ingress.yaml @@ -31,7 +31,7 @@ spec: - host: {{ . }} http: paths: - - path: {{ $ingressPath }}(/|$)(.*) + - path: {{ $ingressPath }} backend: serviceName: coupons servicePort: http diff --git a/Deploy/helm/gvalues.template b/Deploy/helm/gvalues.template index 6b3b033e..bd5c5198 100644 --- a/Deploy/helm/gvalues.template +++ b/Deploy/helm/gvalues.template @@ -40,27 +40,27 @@ inf: id: {{appinsightsik}} ingress: products: - path: /product-api + path: /product-api{{ingressrewritepath}} profile: - path: /profile-api + path: /profile-api{{ingressrewritepath}} coupons: - path: /coupons-api + path: /coupons-api{{ingressrewritepath}} popularproducts: - path: /popular-products-api + path: /popular-products-api{{ingressrewritepath}} stock: - path: /stock-api + path: /stock-api{{ingressrewritepath}} imageclassifier: - path: /image-classifier-api + path: /image-classifier-api{{ingressrewritepath}} mobilebff: - path: /mobilebff + path: /mobilebff{{ingressrewritepath}} webbff: - path: /webbff + path: /webbff{{ingressrewritepath}} login: - path: /login-api + path: /login-api{{ingressrewritepath}} cart: - path: /cart-api + path: /cart-api{{ingressrewritepath}} rewardsregistration: - path: /rewards-registration-api + path: /rewards-registration-api{{ingressrewritepath}} apiurls: popularproductsapiurl: http://popularproducts productsapiurl: http://product @@ -80,8 +80,8 @@ ingress: kubernetes.io/ingress.class: {{ingressclass}} ingress.kubernetes.io/ssl-redirect: "false" nginx.ingress.kubernetes.io/ssl-redirect: "false" - ingress.kubernetes.io/rewrite-target: /$2 - nginx.ingress.kubernetes.io/rewrite-target: /$2 + ingress.kubernetes.io/rewrite-target: /{{ingressrewritetarget}} + nginx.ingress.kubernetes.io/rewrite-target: /{{ingressrewritetarget}} # hosts: # - ..aksapp.io # NOT NEEDED. SET BY SCRIPTS diff --git a/Deploy/helm/image-classifier-api/templates/ingress.yaml b/Deploy/helm/image-classifier-api/templates/ingress.yaml index 7159c701..9b056f94 100644 --- a/Deploy/helm/image-classifier-api/templates/ingress.yaml +++ b/Deploy/helm/image-classifier-api/templates/ingress.yaml @@ -31,7 +31,7 @@ spec: - host: {{ . }} http: paths: - - path: {{ $ingressPath }}(/|$)(.*) + - path: {{ $ingressPath }} backend: serviceName: imageclassifier servicePort: http diff --git a/Deploy/helm/login-api/templates/ingress.yaml b/Deploy/helm/login-api/templates/ingress.yaml index eebc8663..05d12e2c 100644 --- a/Deploy/helm/login-api/templates/ingress.yaml +++ b/Deploy/helm/login-api/templates/ingress.yaml @@ -31,7 +31,7 @@ spec: - host: {{ . }} http: paths: - - path: {{ $ingressPath }}(/|$)(.*) + - path: {{ $ingressPath }} backend: serviceName: login servicePort: http diff --git a/Deploy/helm/mobilebff/templates/ingress.yaml b/Deploy/helm/mobilebff/templates/ingress.yaml index edcc8a58..4bfd7f27 100644 --- a/Deploy/helm/mobilebff/templates/ingress.yaml +++ b/Deploy/helm/mobilebff/templates/ingress.yaml @@ -31,7 +31,7 @@ spec: - host: {{ . }} http: paths: - - path: {{ $ingressPath }}(/|$)(.*) + - path: {{ $ingressPath }} backend: serviceName: mobilebff servicePort: http diff --git a/Deploy/helm/popular-products-api/templates/ingress.yaml b/Deploy/helm/popular-products-api/templates/ingress.yaml index c7976577..9ca4a640 100644 --- a/Deploy/helm/popular-products-api/templates/ingress.yaml +++ b/Deploy/helm/popular-products-api/templates/ingress.yaml @@ -31,7 +31,7 @@ spec: - host: {{ . }} http: paths: - - path: {{ $ingressPath }}(/|$)(.*) + - path: {{ $ingressPath }} backend: serviceName: popularproducts servicePort: http diff --git a/Deploy/helm/products-api/templates/ingress.yaml b/Deploy/helm/products-api/templates/ingress.yaml index fe37defd..2dd4ec34 100644 --- a/Deploy/helm/products-api/templates/ingress.yaml +++ b/Deploy/helm/products-api/templates/ingress.yaml @@ -31,7 +31,7 @@ spec: - host: {{ . }} http: paths: - - path: {{ $ingressPath }}(/|$)(.*) + - path: {{ $ingressPath }} backend: serviceName: product servicePort: http diff --git a/Deploy/helm/profiles-api/templates/ingress.yaml b/Deploy/helm/profiles-api/templates/ingress.yaml index 76842a00..f4e45052 100644 --- a/Deploy/helm/profiles-api/templates/ingress.yaml +++ b/Deploy/helm/profiles-api/templates/ingress.yaml @@ -31,7 +31,7 @@ spec: - host: {{ . }} http: paths: - - path: {{ $ingressPath }}(/|$)(.*) + - path: {{ $ingressPath }} backend: serviceName: profile servicePort: http diff --git a/Deploy/helm/rewards-registration-api/templates/ingress.yaml b/Deploy/helm/rewards-registration-api/templates/ingress.yaml index fb5e1d4f..e1dfb4cd 100644 --- a/Deploy/helm/rewards-registration-api/templates/ingress.yaml +++ b/Deploy/helm/rewards-registration-api/templates/ingress.yaml @@ -31,7 +31,7 @@ spec: - host: {{ . }} http: paths: - - path: {{ $ingressPath }}(/|$)(.*) + - path: {{ $ingressPath }} backend: serviceName: rewards-registration servicePort: http diff --git a/Deploy/helm/stock-api/templates/ingress.yaml b/Deploy/helm/stock-api/templates/ingress.yaml index 8f7c53c0..603739fe 100644 --- a/Deploy/helm/stock-api/templates/ingress.yaml +++ b/Deploy/helm/stock-api/templates/ingress.yaml @@ -31,7 +31,7 @@ spec: - host: {{ . }} http: paths: - - path: {{ $ingressPath }}(/|$)(.*) + - path: {{ $ingressPath }} backend: serviceName: stock servicePort: http diff --git a/Deploy/helm/webbff/templates/ingress.yaml b/Deploy/helm/webbff/templates/ingress.yaml index 84c88696..08aa2b40 100644 --- a/Deploy/helm/webbff/templates/ingress.yaml +++ b/Deploy/helm/webbff/templates/ingress.yaml @@ -31,7 +31,7 @@ spec: - host: {{ . }} http: paths: - - path: {{ $ingressPath }}(/|$)(.*) + - path: {{ $ingressPath }} backend: serviceName: webbff servicePort: http diff --git a/Deploy/powershell/Generate-Config.ps1 b/Deploy/powershell/Generate-Config.ps1 index 0f246c57..5a42bc6a 100644 --- a/Deploy/powershell/Generate-Config.ps1 +++ b/Deploy/powershell/Generate-Config.ps1 @@ -100,6 +100,13 @@ $tokens.appinsightsik=$appinsightsId $tokens.ingressclass=$ingressClass $tokens.secissuer="TTFakeLogin" $tokens.seckey="nEpLzQJGNSCNL5H6DIQCtTdNxf5VgAGcBbtXLms1YDD01KJBAs0WVawaEjn97uwB" +$tokens.ingressrewritepath="" +$tokens.ingressrewritetarget="" + +if($ingressClass -ne "addon-http-application-routing") { + $tokens.ingressrewritepath="(/|$)(.*)" + $tokens.ingressrewritetarget="`$2" +} Write-Host ($tokens | ConvertTo-Json) -ForegroundColor Yellow Write-Host "===========================================================" -ForegroundColor Yellow