Aligned with PowerShell version deploy-all.ps1
This commit is contained in:
parent
93c86fc33e
commit
186b2eb534
@ -20,30 +20,29 @@ Parameters:
|
|||||||
When --use-local-k8s is specified the external DNS is automatically set to localhost.
|
When --use-local-k8s is specified the external DNS is automatically set to localhost.
|
||||||
-h | --help
|
-h | --help
|
||||||
Displays this help text and exits the script.
|
Displays this help text and exits the script.
|
||||||
|
--image-build
|
||||||
|
Build images (default is to not build all images).
|
||||||
|
--image-push
|
||||||
|
Upload images to the container registry (default is not pushing to the custom registry)
|
||||||
-n | --app-name <the name of the app>
|
-n | --app-name <the name of the app>
|
||||||
Specifies the name of the application (default: eshop).
|
Specifies the name of the application (default: eshop).
|
||||||
|
--namespace <namespace name>
|
||||||
|
Specifies the namespace name to deploy the app. If it doesn't exists it will be created (default: eshop).
|
||||||
-p | --docker-password <docker password>
|
-p | --docker-password <docker password>
|
||||||
The Docker password used to logon to the custom registry, supplied using the -r parameter.
|
The Docker password used to logon to the custom registry, supplied using the -r parameter.
|
||||||
-r | --registry <container registry>
|
-r | --registry <container registry>
|
||||||
Specifies the container registry to use (required), e.g. myregistry.azurecr.io.
|
Specifies the container registry to use (required), e.g. myregistry.azurecr.io.
|
||||||
--skip-clean
|
--skip-clean
|
||||||
Do not clean the Kubernetes cluster (default is to clean the cluster).
|
Do not clean the Kubernetes cluster (default is to clean the cluster).
|
||||||
--skip-image-build
|
|
||||||
Do not build images (default is to build all images).
|
|
||||||
--skip-image-push
|
|
||||||
Do not upload images to the container registry (just run the Kubernetes deployment portion).
|
|
||||||
Default is to push the images to the container registry.
|
|
||||||
--skip-infrastructure
|
--skip-infrastructure
|
||||||
Do not deploy infrastructure resources (like sql-data, no-sql or redis).
|
Do not deploy infrastructure resources (like sql-data, no-sql or redis).
|
||||||
This is useful for production environments where infrastructure is hosted outside the Kubernetes cluster.
|
This is useful for production environments where infrastructure is hosted outside the Kubernetes cluster.
|
||||||
-t | --tag <docker image tag>
|
-t | --tag <docker image tag>
|
||||||
The tag used for the newly created docker images. Default: newly created, date-based timestamp, with 1-minute resolution.
|
The tag used for the newly created docker images. Default: latest.
|
||||||
-u | --docker-username <docker username>
|
-u | --docker-username <docker username>
|
||||||
The Docker username used to logon to the custom registry, supplied using the -r parameter.
|
The Docker username used to logon to the custom registry, supplied using the -r parameter.
|
||||||
--use-local-k8s
|
--use-local-k8s
|
||||||
Deploy to a locally installed Kubernetes (default: false).
|
Deploy to a locally installed Kubernetes (default: false).
|
||||||
--namespace <namespace name>
|
|
||||||
Specifies the namespace name to deploy the app. If it doesn't exists it will be created (default: eshop).
|
|
||||||
|
|
||||||
It is assumed that the Kubernetes cluster has been granted access to the container registry.
|
It is assumed that the Kubernetes cluster has been granted access to the container registry.
|
||||||
If using AKS and ACR see link for more info:
|
If using AKS and ACR see link for more info:
|
||||||
@ -61,15 +60,15 @@ END
|
|||||||
app_name='eshop'
|
app_name='eshop'
|
||||||
aks_name=''
|
aks_name=''
|
||||||
aks_rg=''
|
aks_rg=''
|
||||||
build_images='yes'
|
build_images=''
|
||||||
clean='yes'
|
clean='yes'
|
||||||
build_solution=''
|
build_solution=''
|
||||||
container_registry=''
|
container_registry=''
|
||||||
docker_password=''
|
docker_password=''
|
||||||
docker_username=''
|
docker_username=''
|
||||||
dns=''
|
dns=''
|
||||||
image_tag=$(date '+%Y%m%d%H%M')
|
image_tag='latest'
|
||||||
push_images='yes'
|
push_images=''
|
||||||
skip_infrastructure=''
|
skip_infrastructure=''
|
||||||
use_local_k8s=''
|
use_local_k8s=''
|
||||||
namespace='eshop'
|
namespace='eshop'
|
||||||
@ -94,10 +93,10 @@ while [[ $# -gt 0 ]]; do
|
|||||||
container_registry="$2"; shift 2;;
|
container_registry="$2"; shift 2;;
|
||||||
--skip-clean )
|
--skip-clean )
|
||||||
clean=''; shift ;;
|
clean=''; shift ;;
|
||||||
--skip-image-build )
|
--image-build )
|
||||||
build_images=''; shift ;;
|
build_images='yes'; shift ;;
|
||||||
--skip-image-push )
|
--image-push )
|
||||||
push_images=''; shift ;;
|
push_images='yes'; shift ;;
|
||||||
--skip-infrastructure )
|
--skip-infrastructure )
|
||||||
skip_infrastructure='yes'; shift ;;
|
skip_infrastructure='yes'; shift ;;
|
||||||
-t | --tag )
|
-t | --tag )
|
||||||
@ -141,17 +140,17 @@ if [[ -n $container_registry ]]; then
|
|||||||
docker login -u $docker_username -p $docker_password $container_registry
|
docker login -u $docker_username -p $docker_password $container_registry
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [[ $push_images ]]; then
|
if [[ $push_images ]]; then
|
||||||
echo "#################### Pushing images to the container registry ####################"
|
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)
|
services=(basket.api catalog.api identity.api ordering.api marketing.api payment.api locations.api webmvc webspa webstatus)
|
||||||
|
|
||||||
|
if [[ -z "$(docker image ls -q --filter=reference=eshop/$service:$image_tag)" ]]; then
|
||||||
|
image_tag=linux-$image_tag
|
||||||
|
fi
|
||||||
|
|
||||||
for service in "${services[@]}"
|
for service in "${services[@]}"
|
||||||
do
|
do
|
||||||
echo "Pushing image for service $service..."
|
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 tag "eshop/$service:$image_tag" "$container_registry/$service:$image_tag"
|
||||||
docker push "$container_registry/$service:$image_tag"
|
docker push "$container_registry/$service:$image_tag"
|
||||||
done
|
done
|
||||||
@ -175,8 +174,10 @@ if [[ $dns == "aks" ]]; then
|
|||||||
|
|
||||||
echo "Getting AKS cluster $aks_name AKS (in resource group $aks_rg)"
|
echo "Getting AKS cluster $aks_name AKS (in resource group $aks_rg)"
|
||||||
# JMESPath queries are case sensitive and httpapplicationrouting can be lowercase sometimes
|
# JMESPath queries are case sensitive and httpapplicationrouting can be lowercase sometimes
|
||||||
jmespath_dnsqueries=(addonProfiles.httpApplicationRouting.config.HTTPApplicationRoutingZoneName \
|
jmespath_dnsqueries=(\
|
||||||
addonProfiles.httpapplicationrouting.config.HTTPApplicationRoutingZoneName)
|
addonProfiles.httpApplicationRouting.config.HTTPApplicationRoutingZoneName \
|
||||||
|
addonProfiles.httpapplicationrouting.config.HTTPApplicationRoutingZoneName \
|
||||||
|
)
|
||||||
for q in "${jmespath_dnsqueries[@]}"
|
for q in "${jmespath_dnsqueries[@]}"
|
||||||
do
|
do
|
||||||
dns="$(az aks show -n $aks_name -g $aks_rg --query $q -o tsv)"
|
dns="$(az aks show -n $aks_name -g $aks_rg --query $q -o tsv)"
|
||||||
@ -187,6 +188,7 @@ if [[ $dns == "aks" ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "DNS base found is $dns. Will use $aks_name.$dns for the app!"
|
echo "DNS base found is $dns. Will use $aks_name.$dns for the app!"
|
||||||
|
dns="$aks_name.$dns"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Initialization & check commands
|
# Initialization & check commands
|
||||||
@ -201,6 +203,7 @@ if [[ $clean ]]; then
|
|||||||
else
|
else
|
||||||
helm delete --purge $(helm ls -q --namespace $namespace)
|
helm delete --purge $(helm ls -q --namespace $namespace)
|
||||||
echo "Previous releases deleted"
|
echo "Previous releases deleted"
|
||||||
|
waitsecs=10; while [ $waitsecs -gt 0 ]; do echo -ne "$waitsecs\033[0K\r"; sleep 1; : $((waitsecs--)); done
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -212,7 +215,7 @@ if [[ !$skip_infrastructure ]]; then
|
|||||||
for infra in "${infras[@]}"
|
for infra in "${infras[@]}"
|
||||||
do
|
do
|
||||||
echo "Installing infrastructure: $infra"
|
echo "Installing infrastructure: $infra"
|
||||||
helm install --namespace $namespace --values app.yaml --values inf.yaml --values $ingress_values_file --set app.name=$app_name --set inf.k8s.dns=$dns --name="$app_name-$infra" $infra
|
helm install --namespace $namespace --set "ingress.hosts={$dns}" --values app.yaml --values inf.yaml --values $ingress_values_file --set app.name=$app_name --set inf.k8s.dns=$dns --name="$app_name-$infra" $infra
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -220,9 +223,9 @@ for chart in "${charts[@]}"
|
|||||||
do
|
do
|
||||||
echo "Installing: $chart"
|
echo "Installing: $chart"
|
||||||
if [[ $use_custom_registry ]]; then
|
if [[ $use_custom_registry ]]; then
|
||||||
helm install --namespace $namespace --set ingress.hosts[0]=$dns --set inf.registry.server=$container_registry --set inf.registry.login=$docker_username --set inf.registry.pwd=$docker_password --set inf.registry.secretName=eshop-docker-scret --values app.yaml --values inf.yaml --values $ingress_values_file --set app.name=$app_name --set inf.k8s.dns=$dns --set image.tag=$image_tag --set image.pullPolicy=Always --name="$app_name-$chart" $chart
|
helm install --namespace $namespace --set "ingress.hosts={$dns}" --set inf.registry.server=$container_registry --set inf.registry.login=$docker_username --set inf.registry.pwd=$docker_password --set inf.registry.secretName=eshop-docker-scret --values app.yaml --values inf.yaml --values $ingress_values_file --set app.name=$app_name --set inf.k8s.dns=$dns --set image.tag=$image_tag --set image.pullPolicy=Always --name="$app_name-$chart" $chart
|
||||||
elif [[ $chart != "eshop-common" ]]; then # eshop-common is ignored when no secret must be deployed
|
elif [[ $chart != "eshop-common" ]]; then # eshop-common is ignored when no secret must be deployed
|
||||||
helm install --namespace $namespace --set ingress.hosts[0]=$dns --values app.yaml --values inf.yaml --values $ingress_values_file --set app.name=$app_name --set inf.k8s.dns=$dns --set image.tag=$image_tag --set image.pullPolicy=Always --name="$app_name-$chart" $chart
|
helm install --namespace $namespace --set "ingress.hosts={$dns}" --values app.yaml --values inf.yaml --values $ingress_values_file --set app.name=$app_name --set inf.k8s.dns=$dns --set image.tag=$image_tag --set image.pullPolicy=Always --name="$app_name-$chart" $chart
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user