You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
3.8 KiB

6 years ago
6 years ago
  1. Param(
  2. [parameter(Mandatory=$false)][string]$registry,
  3. [parameter(Mandatory=$false)][string]$dockerUser,
  4. [parameter(Mandatory=$false)][string]$dockerPassword,
  5. [parameter(Mandatory=$false)][string]$externalDns,
  6. [parameter(Mandatory=$false)][string]$appName="eshop",
  7. [parameter(Mandatory=$false)][bool]$deployInfrastructure=$true,
  8. [parameter(Mandatory=$false)][bool]$clean=$true,
  9. [parameter(Mandatory=$false)][string]$aksName="",
  10. [parameter(Mandatory=$false)][string]$aksRg="",
  11. [parameter(Mandatory=$false)][string]$imageTag="latest"
  12. )
  13. $dns = $externalDns
  14. if ($externalDns -eq "aks") {
  15. if ([string]::IsNullOrEmpty($aksName) -or [string]::IsNullOrEmpty($aksRg)) {
  16. Write-Host "Error: When using -dns aks, MUST set -aksName and -aksRg too." -ForegroundColor Red
  17. exit 1
  18. }
  19. Write-Host "Getting DNS of AKS of AKS $aksName (in resource group $aksRg)..." -ForegroundColor Green
  20. $dns = $(az aks show -n $aksName -g $aksRg --query addonProfiles.httpApplicationRouting.config.HTTPApplicationRoutingZoneName)
  21. if ([string]::IsNullOrEmpty($dns)) {
  22. Write-Host "Error getting DNS of AKS $aksName (in resource group $aksRg). Please ensure AKS has httpRouting enabled AND Azure CLI is logged & in version 2.0.37 or higher" -ForegroundColor Red
  23. exit 1
  24. }
  25. $dns = $dns -replace '[\"]'
  26. Write-Host "DNS base found is $dns. Will use $appName.$dns for the app!" -ForegroundColor Green
  27. $dns = "$appName.$dns"
  28. }
  29. # Initialization & check commands
  30. if ([string]::IsNullOrEmpty($dns)) {
  31. Write-Host "No DNS specified. Ingress resources will be bound to public ip" -ForegroundColor Yellow
  32. }
  33. if ($clean) {
  34. Write-Host "Cleaning previous helm releases..." -ForegroundColor Green
  35. helm delete --purge $(helm ls -q)
  36. Write-Host "Previous releases deleted" -ForegroundColor Green
  37. }
  38. $useCustomRegistry=$false
  39. if (-not [string]::IsNullOrEmpty($registry)) {
  40. $useCustomRegistry=$true
  41. if ([string]::IsNullOrEmpty($dockerUser) -or [string]::IsNullOrEmpty($dockerPassword)) {
  42. Write-Host "Error: Must use -dockerUser AND -dockerPassword if specifying custom registry" -ForegroundColor Red
  43. exit 1
  44. }
  45. }
  46. Write-Host "Begin eShopOnContainers installation using Helm" -ForegroundColor Green
  47. $infras = ("sql-data", "nosql-data", "rabbitmq", "keystore-data", "basket-data")
  48. $charts = ("eshop-common", "apigwmm", "apigwms", "apigwwm", "apigwws", "basket-api","catalog-api", "identity-api", "locations-api", "marketing-api", "mobileshoppingagg","ordering-api","ordering-backgroundtasks","ordering-signalrhub", "payment-api", "webmvc", "webshoppingagg", "webspa", "webstatus")
  49. if ($deployInfrastructure) {
  50. foreach ($infra in $infras) {
  51. Write-Host "Installing infrastructure: $infra" -ForegroundColor Green
  52. helm install --values app.yaml --values inf.yaml --values ingress_values.yaml --set app.name=$appName --set inf.k8s.dns=$dns --name="$appName-$infra" $infra
  53. }
  54. }
  55. foreach ($chart in $charts) {
  56. Write-Host "Installing: $chart" -ForegroundColor Green
  57. if ($useCustomRegistry) {
  58. helm install --set inf.registry.server=$registry --set inf.registry.login=$dockerUser --set inf.registry.pwd=$dockerPassword --set inf.registry.secretName=eshop-docker-scret --values app.yaml --values inf.yaml --values ingress_values.yaml --set app.name=$appName --set inf.k8s.dns=$dns --set image.tag=$imageTag --set image.pullPolicy=Always --name="$appName-$chart" $chart
  59. }
  60. else {
  61. if ($chart -ne "eshop-common") { # eshop-common is ignored when no secret must be deployed
  62. helm install --values app.yaml --values inf.yaml --values ingress_values.yaml --set app.name=$appName --set inf.k8s.dns=$dns --set image.tag=$imageTag --set image.pullPolicy=Always --name="$appName-$chart" $chart
  63. }
  64. }
  65. }
  66. Write-Host "helm charts installed." -ForegroundColor Green