Deploy services on AKS: Create resources on cluster

April 29, 2019 ยท View on GitHub

Pre-requisites

  1. AKS created, up & running & kubectl configured to use it.
  2. Helm installed locally, Tiller installed on cluster
  3. If using custom images: images built and pushed in a ACR
  4. If using custom images: docker login secret loaded into the cluster

All tasks must be performed from /Source/Backend/deploy/k8s folder

Deploy Backend Services (Bash terminal)

The script that deploys all services using Helm is deploy.sh. This script needs following parameters:

  • -r (--registry) <registry-name>: FQDN name of the docker registry to use. In ACR it has the form of <acr-name>.azurecr.io. If not passed Docker Hub is assumed.
  • -c (--clean): If passed all previous helm releases are deleted from cluster.
  • -t (--tag) <tag-name>: Tag of the images to use. Defaults to the name of the current git branch.
  • -o (--org) <org-name>: Docker organization to use. Defaults to smarthotels.
  • -d (--dns) <dns-name>: DNS of the cluster (if set). Ingress resources will be bound to this dns. If not set, access to cluster is possible using public IP of ingress controller
  • -n (--name) <name>: Name of the deployment. You must use a unique name in evey deployment.
  • --release <release-name>: Name of the helm release. If passed all helm releases contains this value. if not, every helm release has a random name. It is recommended to give this value same value as -n.

The value of -n parameter is used to generate connection strings and similar configuration settings.

Following command cleans the cluster and then deploy backend services from Docker Hub (using latest tag):

./deploy.sh  -n edu --release edu -c -t latest

As --release is used all helm releases generated by this deploy will contain the edu value, so you can get them all with a single helm ls | grep edu:

helm ls output

As the value of -n was edu all services and deployments will contain this value:

kubectl get deployments output

Deploy Backend Services (Powershell terminal)

The script that deploys all services using Helm is Deploy.ps1. This script needs following parameters:

  • -registry <registry-name>: FQDN name of the docker registry to use. In ACR it has the form of <acr-name>.azurecr.io. If not passed Docker Hub is assumed.
  • -clean <trueORtrue OR false>: If passed with true all previous helm releases are deleted from cluster.
  • -imageTag <tag-name>: Tag of the images to use. Defaults to the name of the current git branch. Defaults to false.
  • -dockerOrg <org-name>: Docker organization to use. Defaults to smarthotels.
  • -dns <dns-name>: DNS of the cluster (if set). Ingress resources will be bound to this dns. If not set, access to cluster is possible using public IP of ingress controller
  • -appName <name>: Name of the deployment. You must use a unique name in evey deployment.
  • -release <release-name>: Name of the helm release. If passed all helm releases contains this value. if not, every helm release has a random name. It is recommended to give this value same value as -appName.

The value of -appName parameter is used to generate connection strings and similar configuration settings.

Following command cleans the cluster and then deploy backend services from Docker Hub (using latest tag):

.\deploy.ps1  -appName edu -release edu -clean $true -imageTag latest

As --release is used all helm releases generated by this deploy will contain the edu value, so you can get them all with a single helm ls | findstr -i edu. As the value of -appName was edu all services and deployments will contain this value.

Deploy a single resource (advanced)

You can redeploy a single resource (API, or PostreSQL or SQL Server) using its helm chart and using helm install directly. This way you can personalize almost everything of the installation.

For your reference here are the parameters passed to helm install by deploy.sh:

  • --name to the value specified in --release and a suffix for each API. If --release is not set, then --name is set to empty string (generating random release names).
  • --set image.tag to the value of -t
  • --set image.repository to the FQDN of the image
  • --set appName to the value of -n parameter
  • --set ingress.enabled to 1 (to generate ingress resources)
  • --set ingress.hosts to the value of -d parameter (if any)

Also following ingress annotations are set:

  • kubernetes.io/ingress.class to addon-http-application-routing to use ingress controller provided by AKS
  • ingress.kubernetes.io/ssl-redirect to false to disallow http to https redirect

Go to Deploy Backend services on AKS main topic