66 [parameter (Mandatory = $false )][string ]$kubeconfigPath ,
77 [parameter (Mandatory = $true )][string ]$configFile ,
88 [parameter (Mandatory = $false )][string ]$imageTag ,
9- [parameter (Mandatory = $false )][string ]$externalDns ,
109 [parameter (Mandatory = $false )][bool ]$deployCI = $false ,
1110 [parameter (Mandatory = $false )][bool ]$buildImages = $true ,
12- [parameter (Mandatory = $false )][bool ]$buildBits = $false ,
1311 [parameter (Mandatory = $false )][bool ]$deployInfrastructure = $true ,
1412 [parameter (Mandatory = $false )][string ]$dockerOrg = " eshop"
1513)
@@ -30,6 +28,16 @@ function ExecKube($cmd) {
3028$debugMode = $PSCmdlet.MyInvocation.BoundParameters [" Debug" ].IsPresent
3129$useDockerHub = [string ]::IsNullOrEmpty($registry )
3230
31+ $externalDns = & ExecKube - cmd ' get svc ingress-nginx -n ingress-nginx -o=jsonpath="{.status.loadBalancer.ingress[0].ip}"'
32+ Write-Host " Ingress ip detected: $externalDns " - ForegroundColor Yellow
33+
34+ if (-not [bool ]($externalDns -as [ipaddress ])) {
35+ Write-Host " Must install ingress first" - ForegroundColor Red
36+ Write-Host " Run deploy-ingress.ps1 and deploy-ingress-azure.ps1" - ForegroundColor Red
37+ exit
38+ }
39+
40+
3341# Check required commands (only if not in CI environment)
3442if (-not $deployCI ) {
3543 $requiredCommands = (" docker" , " docker-compose" , " kubectl" )
@@ -41,7 +49,6 @@ if(-not $deployCI) {
4149 }
4250}
4351else {
44- $buildBits = false;
4552 $buildImages = false; # Never build images through CI, as they previously built
4653}
4754
@@ -51,11 +58,7 @@ if ([string]::IsNullOrEmpty($imageTag)) {
5158}
5259Write-Host " Docker image Tag: $imageTag " - ForegroundColor Yellow
5360
54- # building and publishing docker images if needed
55- if ($buildBits ) {
56- Write-Host " Building and publishing eShopOnContainers..." - ForegroundColor Yellow
57- dotnet publish - c Release - o obj/ Docker/ publish ../ eShopOnContainers- ServicesAndWebApps.sln
58- }
61+ # building docker images if needed
5962if ($buildImages ) {
6063 Write-Host " Building Docker images tagged with '$imageTag '" - ForegroundColor Yellow
6164 $env: TAG = $imageTag
@@ -100,35 +103,18 @@ if (-not [string]::IsNullOrEmpty($dockerUser)) {
100103Write-Host " Removing existing services & deployments.." - ForegroundColor Yellow
101104ExecKube - cmd ' delete deployments --all'
102105ExecKube - cmd ' delete services --all'
103- ExecKube - cmd ' delete configmap config-files'
104106ExecKube - cmd ' delete configmap urls'
105107ExecKube - cmd ' delete configmap externalcfg'
106108
107109# start sql, rabbitmq, frontend deployments
108- ExecKube - cmd ' create configmap config-files --from-file=nginx-conf=nginx.conf'
109- ExecKube - cmd ' label configmap config-files app=eshop'
110-
111110if ($deployInfrastructure ) {
112111 Write-Host ' Deploying infrastructure deployments (databases, redis, RabbitMQ...)' - ForegroundColor Yellow
113112 ExecKube - cmd ' create -f sql-data.yaml -f basket-data.yaml -f keystore-data.yaml -f rabbitmq.yaml -f nosql-data.yaml'
114113}
115114
116- Write-Host ' Deploying code deployments (Web APIs, Web apps, ...)' - ForegroundColor Yellow
117- ExecKube - cmd ' create -f services.yaml -f frontend.yaml'
118-
119- if ([string ]::IsNullOrEmpty($externalDns )) {
120- Write-Host " Waiting for frontend's external ip..." - ForegroundColor Yellow
121- while ($true ) {
122- $frontendUrl = & ExecKube - cmd ' get svc frontend -o=jsonpath="{.status.loadBalancer.ingress[0].ip}"'
123- if ([bool ]($frontendUrl -as [ipaddress ])) {
124- break
125- }
126- Start-Sleep - s 15
127- }
128- $externalDns = $frontendUrl
129- }
130115
131- Write-Host " Using $externalDns as the external DNS/IP of the k8s cluster"
116+ Write-Host ' Deploying code deployments (Web APIs, Web apps, ...)' - ForegroundColor Yellow
117+ ExecKube - cmd ' create -f services.yaml'
132118
133119ExecKube - cmd ' create configmap urls `
134120 --from-literal=BasketUrl=http://basket `
0 commit comments