Skip to content

Commit

Permalink
Upgrade to Helm 3. Configure ingress rewrite path and targets dep… (m…
Browse files Browse the repository at this point in the history
…icrosoft#78)

Upgrade to Helm 3. Configure ingress rewrite path and targets depending on the nginx-controller
  • Loading branch information
isaacrlevin authored Dec 18, 2019
2 parents 8a56e18 + 920e908 commit 3349a1c
Show file tree
Hide file tree
Showing 21 changed files with 41 additions and 68 deletions.
3 changes: 0 additions & 3 deletions Deploy/Deploy-Unified-WinLinux.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ Write-Host "The name of your AKS: $aksName" -ForegroundColor Yellow
Write-Host "Retrieving credentials" -ForegroundColor Yellow
az aks get-credentials -n $aksName -g $resourceGroup

# ## Add Tiller
.\powershell\Add-Tiller.ps1

## Generate Config
.\powershell\Generate-Config.ps1 -resourceGroup $resourceGroup -outputFile "..\helm\__values\$gValuesFile" -rewardsResourceGroup $rewardsResourceGroup -rewardsDbPassword $rewardsDbPassword

Expand Down
3 changes: 0 additions & 3 deletions Deploy/Deploy-Unified.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ Write-Host "The name of your AKS: $aksName" -ForegroundColor Yellow
# Write-Host "Retrieving credentials" -ForegroundColor Yellow
az aks get-credentials -n $aksName -g $resourceGroup

# Add Tiller
& ./Add-Tiller.ps1

# Generate Config
$gValuesLocation=$(./Join-Path-Recursively.ps1 -pathParts ..,helm,__values,$gValuesFile)
& ./Generate-Config.ps1 -resourceGroup $resourceGroup -outputFile $gValuesLocation
Expand Down
10 changes: 5 additions & 5 deletions Deploy/helm/cart-api/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ data:
ISSUER: {{ .Values.sec.issuer }}
SECURITYKEY: {{ .Values.sec.securityKey }}
UseB2C: {{ .Values.B2C.UseB2C | quote }}
tenantID: {{ .Values.B2C.tenantID }}
clientID: {{ .Values.B2C.clientID }}
policyName: {{ .Values.B2C.policyName }}
identityMetadata: {{ .Values.B2C.identityMetadata }}
issuer: {{ .Values.B2C.issuer }}
tenantID: {{ .Values.B2C.tenantID | quote }}
clientID: {{ .Values.B2C.clientID | quote }}
policyName: {{ .Values.B2C.policyName | quote }}
identityMetadata: {{ .Values.B2C.identityMetadata | quote }}
issuer: {{ .Values.B2C.issuer | quote }}
APPLICATIONINSIGHTSIK: {{ .Values.inf.appinsights.id }}


2 changes: 1 addition & 1 deletion Deploy/helm/cart-api/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ spec:
- host: {{ . }}
http:
paths:
- path: {{ $ingressPath }}(/|$)(.*)
- path: {{ $ingressPath }}
backend:
serviceName: cart
servicePort: http
Expand Down
2 changes: 1 addition & 1 deletion Deploy/helm/coupons-api/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ spec:
- host: {{ . }}
http:
paths:
- path: {{ $ingressPath }}(/|$)(.*)
- path: {{ $ingressPath }}
backend:
serviceName: coupons
servicePort: http
Expand Down
26 changes: 13 additions & 13 deletions Deploy/helm/gvalues.template
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
# - <guid>.<region>.aksapp.io # NOT NEEDED. SET BY SCRIPTS

Expand Down
2 changes: 1 addition & 1 deletion Deploy/helm/image-classifier-api/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ spec:
- host: {{ . }}
http:
paths:
- path: {{ $ingressPath }}(/|$)(.*)
- path: {{ $ingressPath }}
backend:
serviceName: imageclassifier
servicePort: http
Expand Down
2 changes: 1 addition & 1 deletion Deploy/helm/login-api/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ spec:
- host: {{ . }}
http:
paths:
- path: {{ $ingressPath }}(/|$)(.*)
- path: {{ $ingressPath }}
backend:
serviceName: login
servicePort: http
Expand Down
4 changes: 2 additions & 2 deletions Deploy/helm/mobilebff/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ data:
ISSUER: {{ .Values.sec.issuer }}
SECURITYKEY: {{ .Values.sec.securityKey }}
UseB2C: {{ .Values.B2C.UseB2C | quote }}
B2CIssuer: {{ .Values.B2C.B2CIssuer }}
Authority: {{ .Values.B2C.Authority }}
B2CIssuer: {{ .Values.B2C.B2CIssuer | quote }}
Authority: {{ .Values.B2C.Authority | quote }}
RegisterUsers: {{ .Values.inf.registrationusers.registerusers | quote }}
RegistrationUsersEndpoint: {{ .Values.inf.registrationusers.registrationusersurl }}

2 changes: 1 addition & 1 deletion Deploy/helm/mobilebff/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ spec:
- host: {{ . }}
http:
paths:
- path: {{ $ingressPath }}(/|$)(.*)
- path: {{ $ingressPath }}
backend:
serviceName: mobilebff
servicePort: http
Expand Down
2 changes: 1 addition & 1 deletion Deploy/helm/popular-products-api/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ spec:
- host: {{ . }}
http:
paths:
- path: {{ $ingressPath }}(/|$)(.*)
- path: {{ $ingressPath }}
backend:
serviceName: popularproducts
servicePort: http
Expand Down
2 changes: 1 addition & 1 deletion Deploy/helm/products-api/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ spec:
- host: {{ . }}
http:
paths:
- path: {{ $ingressPath }}(/|$)(.*)
- path: {{ $ingressPath }}
backend:
serviceName: product
servicePort: http
Expand Down
2 changes: 1 addition & 1 deletion Deploy/helm/profiles-api/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ spec:
- host: {{ . }}
http:
paths:
- path: {{ $ingressPath }}(/|$)(.*)
- path: {{ $ingressPath }}
backend:
serviceName: profile
servicePort: http
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ spec:
- host: {{ . }}
http:
paths:
- path: {{ $ingressPath }}(/|$)(.*)
- path: {{ $ingressPath }}
backend:
serviceName: rewards-registration
servicePort: http
Expand Down
2 changes: 1 addition & 1 deletion Deploy/helm/stock-api/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ spec:
- host: {{ . }}
http:
paths:
- path: {{ $ingressPath }}(/|$)(.*)
- path: {{ $ingressPath }}
backend:
serviceName: stock
servicePort: http
Expand Down
4 changes: 2 additions & 2 deletions Deploy/helm/webbff/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ data:
ISSUER: {{ .Values.sec.issuer }}
SECURITYKEY: {{ .Values.sec.securityKey }}
UseB2C: {{ .Values.B2C.UseB2C | quote }}
B2CIssuer: {{ .Values.B2C.B2CIssuer }}
Authority: {{ .Values.B2C.Authority }}
B2CIssuer: {{ .Values.B2C.B2CIssuer | quote }}
Authority: {{ .Values.B2C.Authority | quote }}
RegisterUsers: {{ .Values.inf.registrationusers.registerusers | quote }}
RegistrationUsersEndpoint: {{ .Values.inf.registrationusers.registrationusersurl }}

2 changes: 1 addition & 1 deletion Deploy/helm/webbff/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ spec:
- host: {{ . }}
http:
paths:
- path: {{ $ingressPath }}(/|$)(.*)
- path: {{ $ingressPath }}
backend:
serviceName: webbff
servicePort: http
Expand Down
20 changes: 0 additions & 20 deletions Deploy/powershell/Add-Tiller.ps1

This file was deleted.

7 changes: 7 additions & 0 deletions Deploy/powershell/Generate-Config.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion Deploy/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ This folder contains a set of deployment scripts to cover various scenarios
## Powershell scripts inside powershell folder

- `Add-Cert-Manager.ps1`: Adds cert manager to AKS.
- `Add-Tiller.ps1`: Installs and configure Tiller.
- `Build-Push.ps1`: Build and pushes all Docker images to ACR.
- `Create-Secret.ps1`: Create the secret `acr-auth` in AKS used to allow pulling images from ACR.
- `Deploy-Arm-Azure.ps1`: Deploys the ARM script to Azure and configure resources.
Expand Down
9 changes: 1 addition & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ Pre-requisites for this deployment are to have:
- A terminal with Powershell environment
- [Azure CLI 2.0](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest) installed.
- [Kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) installed with the last version (v1.15.0 at this moment).
- [Helm 3](https://helm.sh/docs/intro/install/) installed with 3.0 or superior version (v3.0.0 at this moment).
- Docker installed

#### Service Principal
Expand All @@ -139,14 +140,6 @@ From the terminal type:

At this point if you type `kubectl config current-context` the name of your AKS cluster should be displayed. That means that `kubectl` is ready to use your AKS

#### Installing Tiller on AKS

Helm is a tool to deploy resources in a Kubernetes cluster in a clean and simple manner. It is composed of two tools, one client-side (the Helm client) that needs to be installed on your machine, and a server component called _Tiller_ that has to be installed on the Kubernetes cluster.

To install Helm, refer to its [installation page](https://docs.helm.sh/using_helm/#installing-helm). Once Helm is installed, _Tiller_ must be deployed on the cluster. For deploying _Tiller_ run the `./Add-Tiller.ps1` (from Powershell).

Once installed, helm commands like `helm ls` should work without any error.

#### Configuring services

Before deploying services using Helm, you need to setup the configuration. We refer to the configuration file with the name of _gvalues_ file. This file **contains all secrets and connection strings** so beware to not commit in your repo accidentally.
Expand Down

0 comments on commit 3349a1c

Please sign in to comment.