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.

89 lines
4.1 KiB

  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. [parameter(Mandatory=$false)][bool]$useLocalk8s=$false
  13. )
  14. $dns = $externalDns
  15. $ingressValuesFile="ingress_values.yaml"
  16. if ($useLocalk8s -eq $true) {
  17. $ingressValuesFile="ingress_values_dockerk8s.yaml"
  18. $dns="localhost"
  19. }
  20. if ($externalDns -eq "aks") {
  21. if ([string]::IsNullOrEmpty($aksName) -or [string]::IsNullOrEmpty($aksRg)) {
  22. Write-Host "Error: When using -dns aks, MUST set -aksName and -aksRg too." -ForegroundColor Red
  23. exit 1
  24. }
  25. Write-Host "Getting DNS of AKS of AKS $aksName (in resource group $aksRg)..." -ForegroundColor Green
  26. $dns = $(az aks show -n $aksName -g $aksRg --query addonProfiles.httpApplicationRouting.config.HTTPApplicationRoutingZoneName)
  27. if ([string]::IsNullOrEmpty($dns)) {
  28. 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
  29. exit 1
  30. }
  31. $dns = $dns -replace '[\"]'
  32. Write-Host "DNS base found is $dns. Will use $appName.$dns for the app!" -ForegroundColor Green
  33. $dns = "$appName.$dns"
  34. }
  35. # Initialization & check commands
  36. if ([string]::IsNullOrEmpty($dns)) {
  37. Write-Host "No DNS specified. Ingress resources will be bound to public ip" -ForegroundColor Yellow
  38. }
  39. if ($clean) {
  40. Write-Host "Cleaning previous helm releases..." -ForegroundColor Green
  41. helm delete --purge $(helm ls -q)
  42. Write-Host "Previous releases deleted" -ForegroundColor Green
  43. }
  44. $useCustomRegistry=$false
  45. if (-not [string]::IsNullOrEmpty($registry)) {
  46. $useCustomRegistry=$true
  47. if ([string]::IsNullOrEmpty($dockerUser) -or [string]::IsNullOrEmpty($dockerPassword)) {
  48. Write-Host "Error: Must use -dockerUser AND -dockerPassword if specifying custom registry" -ForegroundColor Red
  49. exit 1
  50. }
  51. }
  52. Write-Host "Begin eShopOnContainers installation using Helm" -ForegroundColor Green
  53. $infras = ("sql-data", "nosql-data", "rabbitmq", "keystore-data", "basket-data")
  54. $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", "webhooks-api", "webhooks-web")
  55. if ($deployInfrastructure) {
  56. foreach ($infra in $infras) {
  57. Write-Host "Installing infrastructure: $infra" -ForegroundColor Green
  58. helm install --values app.yaml --values inf.yaml --values $ingressValuesFile --set app.name=$appName --set inf.k8s.dns=$dns --name="$appName-$infra" $infra
  59. }
  60. }
  61. foreach ($chart in $charts) {
  62. Write-Host "Installing: $chart" -ForegroundColor Green
  63. if ($useCustomRegistry) {
  64. 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 $ingressValuesFile --set app.name=$appName --set inf.k8s.dns=$dns --set image.tag=$imageTag --set image.pullPolicy=Always --name="$appName-$chart" $chart
  65. }
  66. else {
  67. if ($chart -ne "eshop-common") { # eshop-common is ignored when no secret must be deployed
  68. helm install --values app.yaml --values inf.yaml --values $ingressValuesFile --set app.name=$appName --set inf.k8s.dns=$dns --set image.tag=$imageTag --set image.pullPolicy=Always --name="$appName-$chart" $chart
  69. }
  70. }
  71. }
  72. Write-Host "helm charts installed." -ForegroundColor Green