55 [parameter (Mandatory = $false )][bool ]$deployCI ,
66 [parameter (Mandatory = $false )][bool ]$useDockerHub ,
77 [parameter (Mandatory = $false )][string ]$execPath ,
8- [parameter (Mandatory = $false )][string ]$kubeconfigPath
8+ [parameter (Mandatory = $false )][string ]$kubeconfigPath ,
9+ [parameter (Mandatory = $true )][string ]$configFile
910)
1011
12+ $debugMode = $PSCmdlet.MyInvocation.BoundParameters [" Debug" ].IsPresent
13+
1114function ExecKube ($cmd ) {
1215 if ($deployCI ) {
1316 $kubeconfig = $kubeconfigPath + ' config' ;
@@ -20,6 +23,19 @@ function ExecKube($cmd) {
2023 }
2124}
2225
26+
27+ $config = Get-Content - Raw - Path $configFile | ConvertFrom-Json
28+
29+ if ($debugMode ) {
30+ Write-Host " Using following JSON config: "
31+ $json = ConvertTo-Json $config - Depth 5
32+ Write-Host $json
33+ Write-Host " Press a key "
34+ [System.Console ]::Read()
35+ }
36+
37+
38+
2339# Not used when deploying through CI VSTS
2440if (-not $deployCI ) {
2541 $requiredCommands = (" docker" , " docker-compose" , " kubectl" )
@@ -54,11 +70,13 @@ ExecKube -cmd 'delete deployments --all'
5470ExecKube - cmd ' delete services --all'
5571ExecKube - cmd ' delete configmap config-files'
5672ExecKube - cmd ' delete configmap urls'
73+ ExecKube - cmd ' delete configmap externalcfg'
5774
5875# start sql, rabbitmq, frontend deploymentsExecKube -cmd 'delete configmap config-files'
5976ExecKube - cmd ' create configmap config-files --from-file=nginx-conf=nginx.conf'
6077ExecKube - cmd ' label configmap config-files app=eshop'
61- ExecKube - cmd ' create -f sql-data.yaml -f basket-data.yaml -f keystore-data.yaml -f rabbitmq.yaml -f services.yaml -f frontend.yaml'
78+ # ExecKube -cmd 'create -f sql-data.yaml -f basket-data.yaml -f keystore-data.yaml -f rabbitmq.yaml -f services.yaml -f frontend.yaml'
79+ ExecKube - cmd ' create -f services.yaml -f frontend.yaml'
6280
6381# building and publishing docker images not necessary when deploying through CI VSTS
6482if (-not $deployCI ) {
@@ -109,6 +127,27 @@ ExecKube -cmd 'create configmap urls `
109127
110128ExecKube - cmd ' label configmap urls app=eshop'
111129
130+ Write-Host " Applying external configuration from json" - ForegroundColor Yellow
131+
132+ ExecKube - cmd ' create configmap externalcfg `
133+ --from-literal=CatalogSqlDb=$($config.sql.catalog) `
134+ --from-literal=IdentitySqlDb=$($config.sql.identity) `
135+ --from-literal=OrderingSqlDb=$($config.sql.ordering) `
136+ --from-literal=MarketingSqlDb=$($config.sql.marketing) `
137+ --from-literal=LocationsNoSqlDb=$($config.nosql.locations.constr) `
138+ --from-literal=LocationsNoSqlDbName=$($config.nosql.locations.db) `
139+ --from-literal=MarketingsNoSqlDb=$($config.nosql.marketing.constr) `
140+ --from-literal=MarketingNoSqlDbName=$($config.nosql.marketing.db) `
141+ --from-literal=BasketRedisConStr=$($config.redis.basket) `
142+ --from-literal=LocationsBus=$($config.servicebus.locations) `
143+ --from-literal=MarketingBus=$($config.servicebus.marketing) `
144+ --from-literal=BasketBus=$($config.servicebus.basket) `
145+ --from-literal=OrderingBus=$($config.servicebus.ordering) `
146+ --from-literal=PaymentBus=$($config.servicebus.payment) '
147+
148+ ExecKube - cmd ' label configmap externalcfg app=eshop'
149+
150+
112151Write-Host " Creating deployments..." - ForegroundColor Yellow
113152
114153ExecKube - cmd ' create -f deployments.yaml'
0 commit comments