Update k8s deploy script. Remove existing services and deployments before deployment

This commit is contained in:
Ramón Tomás 2017-05-08 16:10:41 +02:00
parent 81b8950ced
commit 573c5a026f

View File

@ -20,7 +20,7 @@ function ExecKube($cmd) {
} }
} }
# Check command paths only for manual deployment # No when deploying through CI VSTS
if(-not $deployCI) { if(-not $deployCI) {
$requiredCommands = ("docker", "docker-compose", "kubectl") $requiredCommands = ("docker", "docker-compose", "kubectl")
foreach ($command in $requiredCommands) { foreach ($command in $requiredCommands) {
@ -48,7 +48,14 @@ if(-not $useDockerHub) {
--docker-email=not@used.com' --docker-email=not@used.com'
} }
# start sql, rabbitmq, frontend deployments # Removing previous services & deployments
Write-Host "Removing existing services & deployments.." -ForegroundColor Yellow
ExecKube -cmd 'delete -f sql-data.yaml -f rabbitmq.yaml'
ExecKube -cmd 'delete -f services.yaml -f frontend.yaml -f deployments.yaml'
ExecKube -cmd 'delete configmap config-files'
ExecKube -cmd 'delete configmap urls'
# start sql, rabbitmq, frontend deploymentsExecKube -cmd 'delete configmap config-files'
ExecKube -cmd 'create configmap config-files --from-file=nginx-conf=nginx.conf' ExecKube -cmd 'create configmap config-files --from-file=nginx-conf=nginx.conf'
ExecKube -cmd 'label configmap config-files app=eshop' ExecKube -cmd 'label configmap config-files app=eshop'
ExecKube -cmd 'create -f sql-data.yaml -f rabbitmq.yaml -f services.yaml -f frontend.yaml' ExecKube -cmd 'create -f sql-data.yaml -f rabbitmq.yaml -f services.yaml -f frontend.yaml'
@ -90,10 +97,10 @@ ExecKube -cmd 'create configmap urls `
ExecKube -cmd 'label configmap urls app=eshop' ExecKube -cmd 'label configmap urls app=eshop'
Write-Host "Creating deployments..." Write-Host "Creating deployments..."
ExecKube -cmd 'apply -f deployments.yaml' ExecKube -cmd 'create -f deployments.yaml'
# use ACR registry for pulling images if docker hub is not specified # not using ACR for pulling images when deploying through CI VSTS
if(-not $useDockerHub) { if(-not $deployCI) {
# update deployments with the private registry before k8s tries to pull images # update deployments with the private registry before k8s tries to pull images
# (deployment templating, or Helm, would obviate this) # (deployment templating, or Helm, would obviate this)
ExecKube -cmd 'set image -f deployments.yaml ` ExecKube -cmd 'set image -f deployments.yaml `