From 00bf2470ce64fd43235e99247a33b6791f92410a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mil=C3=A1n=20Figueredo?= Date: Wed, 10 Jul 2019 07:35:44 +0200 Subject: [PATCH] Several improvement and fixes: image_tag check for linux- prefix, login procedure for custom registry, --docker-username normalization and --dns aks option documented at usage() --- k8s/helm/deploy-all.sh | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/k8s/helm/deploy-all.sh b/k8s/helm/deploy-all.sh index cea7289e1..f5e932fe9 100755 --- a/k8s/helm/deploy-all.sh +++ b/k8s/helm/deploy-all.sh @@ -14,8 +14,9 @@ Parameters: The resource group for the AKS cluster. Required when the registry (using the -r parameter) is set to "aks". -b | --build-solution Force a solution build before deployment (default: false). - -d | --dns - Specifies the external DNS/ IP address of the Kubernetes cluster. + -d | --dns | --dns aks + Specifies the external DNS/ IP address of the Kubernetes cluster. + If 'aks' is set as value, the DNS value is retrieved from the AKS. --aks-name and --aks-rg are needed. When --use-local-k8s is specified the external DNS is automatically set to localhost. -h | --help Displays this help text and exits the script. @@ -37,7 +38,7 @@ Parameters: This is useful for production environments where infrastructure is hosted outside the Kubernetes cluster. -t | --tag The tag used for the newly created docker images. Default: newly created, date-based timestamp, with 1-minute resolution. - -u | --docker-username + -u | --docker-user The Docker username used to logon to the custom registry, supplied using the -r parameter. --use-local-k8s Deploy to a locally installed Kubernetes (default: false). @@ -124,6 +125,19 @@ if [[ $build_images ]]; then docker rmi $(docker images -qf "dangling=true") fi +use_custom_registry='' + +if [[ -n $container_registry ]]; then + echo "################ Log into custom registry $container_registry ##################" + use_custom_registry='yes' + if [[ -z $docker_username ]] || [[ -z $docker_password ]]; then + echo "Error: Must use -u (--docker-username) AND -p (--docker-password) if specifying custom registry" + exit 1 + fi + docker login -u $docker_username -p $docker_password $container_registry +fi + + if [[ $push_images ]]; then echo "#################### Pushing images to the container registry ####################" services=(basket.api catalog.api identity.api ordering.api marketing.api payment.api locations.api webmvc webspa webstatus) @@ -131,6 +145,9 @@ if [[ $push_images ]]; then for service in "${services[@]}" do echo "Pushing image for service $service..." + if [[ -z "$(docker image ls -q --filter=reference=eshop/$service:$image_tag)" ]]; then + image_tag=linux-$image_tag + fi docker tag "eshop/$service:$image_tag" "$container_registry/$service:$image_tag" docker push "$container_registry/$service:$image_tag" done @@ -173,16 +190,6 @@ if [[ $clean ]]; then echo "Previous releases deleted" fi -use_custom_registry='' - -if [[ -n $container_registry ]]; then - use_custom_registry='yes' - if [[ -z $docker_user ]] || [[ -z $docker_password ]]; then - echo "Error: Must use -u (--docker-username) AND -p (--docker-password) if specifying custom registry" - exit 1 - fi -fi - echo "#################### Begin $app_name installation using Helm ####################" infras=(sql-data nosql-data rabbitmq keystore-data basket-data) 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)