|
@ -6,10 +6,8 @@ Param( |
|
|
[parameter(Mandatory=$false)][string]$kubeconfigPath, |
|
|
[parameter(Mandatory=$false)][string]$kubeconfigPath, |
|
|
[parameter(Mandatory=$true)][string]$configFile, |
|
|
[parameter(Mandatory=$true)][string]$configFile, |
|
|
[parameter(Mandatory=$false)][string]$imageTag, |
|
|
[parameter(Mandatory=$false)][string]$imageTag, |
|
|
[parameter(Mandatory=$false)][string]$externalDns, |
|
|
|
|
|
[parameter(Mandatory=$false)][bool]$deployCI=$false, |
|
|
[parameter(Mandatory=$false)][bool]$deployCI=$false, |
|
|
[parameter(Mandatory=$false)][bool]$buildImages=$true, |
|
|
[parameter(Mandatory=$false)][bool]$buildImages=$true, |
|
|
[parameter(Mandatory=$false)][bool]$buildBits=$false, |
|
|
|
|
|
[parameter(Mandatory=$false)][bool]$deployInfrastructure=$true, |
|
|
[parameter(Mandatory=$false)][bool]$deployInfrastructure=$true, |
|
|
[parameter(Mandatory=$false)][string]$dockerOrg="eshop" |
|
|
[parameter(Mandatory=$false)][string]$dockerOrg="eshop" |
|
|
) |
|
|
) |
|
@ -30,6 +28,16 @@ function ExecKube($cmd) { |
|
|
$debugMode = $PSCmdlet.MyInvocation.BoundParameters["Debug"].IsPresent |
|
|
$debugMode = $PSCmdlet.MyInvocation.BoundParameters["Debug"].IsPresent |
|
|
$useDockerHub = [string]::IsNullOrEmpty($registry) |
|
|
$useDockerHub = [string]::IsNullOrEmpty($registry) |
|
|
|
|
|
|
|
|
|
|
|
$externalDns = & ExecKube -cmd 'get svc ingress-nginx -n ingress-nginx -o=jsonpath="{.status.loadBalancer.ingress[0].ip}"' |
|
|
|
|
|
Write-Host "Ingress ip detected: $externalDns" -ForegroundColor Yellow |
|
|
|
|
|
|
|
|
|
|
|
if (-not [bool]($externalDns -as [ipaddress])) { |
|
|
|
|
|
Write-Host "Must install ingress first" -ForegroundColor Red |
|
|
|
|
|
Write-Host "Run deploy-ingress.ps1 and deploy-ingress-azure.ps1" -ForegroundColor Red |
|
|
|
|
|
exit |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Check required commands (only if not in CI environment) |
|
|
# Check required commands (only if not in CI environment) |
|
|
if(-not $deployCI) { |
|
|
if(-not $deployCI) { |
|
|
$requiredCommands = ("docker", "docker-compose", "kubectl") |
|
|
$requiredCommands = ("docker", "docker-compose", "kubectl") |
|
@ -41,7 +49,6 @@ if(-not $deployCI) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
$buildBits = false; |
|
|
|
|
|
$buildImages = false; # Never build images through CI, as they previously built |
|
|
$buildImages = false; # Never build images through CI, as they previously built |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -51,11 +58,7 @@ if ([string]::IsNullOrEmpty($imageTag)) { |
|
|
} |
|
|
} |
|
|
Write-Host "Docker image Tag: $imageTag" -ForegroundColor Yellow |
|
|
Write-Host "Docker image Tag: $imageTag" -ForegroundColor Yellow |
|
|
|
|
|
|
|
|
# building and publishing docker images if needed |
|
|
|
|
|
if($buildBits) { |
|
|
|
|
|
Write-Host "Building and publishing eShopOnContainers..." -ForegroundColor Yellow |
|
|
|
|
|
dotnet publish -c Release -o obj/Docker/publish ../eShopOnContainers-ServicesAndWebApps.sln |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
# building docker images if needed |
|
|
if ($buildImages) { |
|
|
if ($buildImages) { |
|
|
Write-Host "Building Docker images tagged with '$imageTag'" -ForegroundColor Yellow |
|
|
Write-Host "Building Docker images tagged with '$imageTag'" -ForegroundColor Yellow |
|
|
$env:TAG=$imageTag |
|
|
$env:TAG=$imageTag |
|
@ -100,35 +103,18 @@ if (-not [string]::IsNullOrEmpty($dockerUser)) { |
|
|
Write-Host "Removing existing services & deployments.." -ForegroundColor Yellow |
|
|
Write-Host "Removing existing services & deployments.." -ForegroundColor Yellow |
|
|
ExecKube -cmd 'delete deployments --all' |
|
|
ExecKube -cmd 'delete deployments --all' |
|
|
ExecKube -cmd 'delete services --all' |
|
|
ExecKube -cmd 'delete services --all' |
|
|
ExecKube -cmd 'delete configmap config-files' |
|
|
|
|
|
ExecKube -cmd 'delete configmap urls' |
|
|
ExecKube -cmd 'delete configmap urls' |
|
|
ExecKube -cmd 'delete configmap externalcfg' |
|
|
ExecKube -cmd 'delete configmap externalcfg' |
|
|
|
|
|
|
|
|
# start sql, rabbitmq, frontend deployments |
|
|
# start sql, rabbitmq, frontend deployments |
|
|
ExecKube -cmd 'create configmap config-files --from-file=nginx-conf=nginx.conf' |
|
|
|
|
|
ExecKube -cmd 'label configmap config-files app=eshop' |
|
|
|
|
|
|
|
|
|
|
|
if ($deployInfrastructure) { |
|
|
if ($deployInfrastructure) { |
|
|
Write-Host 'Deploying infrastructure deployments (databases, redis, RabbitMQ...)' -ForegroundColor Yellow |
|
|
Write-Host 'Deploying infrastructure deployments (databases, redis, RabbitMQ...)' -ForegroundColor Yellow |
|
|
ExecKube -cmd 'create -f sql-data.yaml -f basket-data.yaml -f keystore-data.yaml -f rabbitmq.yaml -f nosql-data.yaml' |
|
|
ExecKube -cmd 'create -f sql-data.yaml -f basket-data.yaml -f keystore-data.yaml -f rabbitmq.yaml -f nosql-data.yaml' |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Write-Host 'Deploying code deployments (Web APIs, Web apps, ...)' -ForegroundColor Yellow |
|
|
|
|
|
ExecKube -cmd 'create -f services.yaml -f frontend.yaml' |
|
|
|
|
|
|
|
|
|
|
|
if ([string]::IsNullOrEmpty($externalDns)) { |
|
|
|
|
|
Write-Host "Waiting for frontend's external ip..." -ForegroundColor Yellow |
|
|
|
|
|
while ($true) { |
|
|
|
|
|
$frontendUrl = & ExecKube -cmd 'get svc frontend -o=jsonpath="{.status.loadBalancer.ingress[0].ip}"' |
|
|
|
|
|
if ([bool]($frontendUrl -as [ipaddress])) { |
|
|
|
|
|
break |
|
|
|
|
|
} |
|
|
|
|
|
Start-Sleep -s 15 |
|
|
|
|
|
} |
|
|
|
|
|
$externalDns = $frontendUrl |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Write-Host "Using $externalDns as the external DNS/IP of the k8s cluster" |
|
|
|
|
|
|
|
|
Write-Host 'Deploying code deployments (Web APIs, Web apps, ...)' -ForegroundColor Yellow |
|
|
|
|
|
ExecKube -cmd 'create -f services.yaml' |
|
|
|
|
|
|
|
|
ExecKube -cmd 'create configmap urls ` |
|
|
ExecKube -cmd 'create configmap urls ` |
|
|
--from-literal=BasketUrl=http://basket ` |
|
|
--from-literal=BasketUrl=http://basket ` |
|
|