Codementor Events

eShopOnContainers - Part 4 (AKS)

Published Feb 09, 2023
eShopOnContainers - Part 4 (AKS)

Create The Kubernetes Cluster in AKS

You can create the AKS cluster by using Use Azure CLI or Azure Portal. Follow steps indicated here. I used Azure portal to create dj-eshop-aks AKS.

Configure Kubectl

Once the cluster is up and running, you'll need to configure your local kubectl tool to access AKS cluster. You can do that by running the following command.

az aks get-credentials --resource-group <resource-group-name> --name <k8s-cluster-name>

5.5.PNG

Note Check your kubectl configuration to see if it's pointing to the correct cluster context. You can do that using the below command.

kubectl config get-contexts

5.1.PNG

Setup a container registry

I have created djAcr. Login to your container registry. Use the below username and password.

1.PNG

docker login djacr.azurecr.io

Push your Local Images to ACR

If you have done some local changes in the eshop application and want to deploy that to the cluster, you can do that by building and publishing your local docker images to your private container registry.

Go to the src directory of your local repo and below command :

docker-compose build

Then tag those images and publish them to the ACS registry. Go to the src directory of your local repo and below command :

docker-compose build

Then tag those images and publish them to the ACS registry. You can filter all the shop images using below command -

docker images --filter "reference=eshop*"

2.PNG

docker tag eshop/webmvc:linux-latest djacr.azurecr.io/eshop/webmvc:linux-latest
docker tag eshop/ordering.signalrhub:linux-latest djacr.azurecr.io/eshop/ordering.signalrhub:linux-latest
docker tag eshop/mobileshoppingagg:linux-latest djacr.azurecr.io/eshop/mobileshoppingagg:linux-latest
docker tag eshop/webshoppingagg:linux-latest djacr.azurecr.io/eshop/webshoppingagg:linux-latest
docker tag eshop/basket.api:linux-latest djacr.azurecr.io/eshop/basket.api:linux-latest
docker tag eshop/identity.api:linux-latest djacr.azurecr.io/eshop/identity.api:linux-latest
docker tag eshop/ordering.api:linux-latest djacr.azurecr.io/eshop/ordering.api:linux-latest
docker tag eshop/webspa:linux-latest djacr.azurecr.io/eshop/webspa:linux-latest
docker tag eshop/webstatus:linux-latest djacr.azurecr.io/eshop/webstatus:linux-latest
docker tag eshop/catalog.api:linux-latest djacr.azurecr.io/eshop/catalog.api:linux-latest
docker tag eshop/payment.api:linux-latest djacr.azurecr.io/eshop/payment.api:linux-latest
docker tag eshop/ordering.backgroundtasks:linux-latest djacr.azurecr.io/eshop/ordering.backgroundtasks:linux-latest
docker tag eshop/webhooks.client:linux-latest djacr.azurecr.io/eshop/webhooks.client:linux-latest
docker tag eshop/webhooks.api:linux-latest djacr.azurecr.io/eshop/webhooks.api:linux-latest

Now you can push it to ACR-

docker push djacr.azurecr.io/eshop/webmvc:linux-latest
docker push djacr.azurecr.io/eshop/ordering.signalrhub:linux-latest
docker push djacr.azurecr.io/eshop/mobileshoppingagg:linux-latest
docker push djacr.azurecr.io/eshop/webshoppingagg:linux-latest
docker push djacr.azurecr.io/eshop/basket.api:linux-latest
docker push djacr.azurecr.io/eshop/identity.api:linux-latest
docker push djacr.azurecr.io/eshop/ordering.api:linux-latest
docker push djacr.azurecr.io/eshop/webspa:linux-latest
docker push djacr.azurecr.io/eshop/webstatus:linux-latest
docker push djacr.azurecr.io/eshop/catalog.api:linux-latest
docker push djacr.azurecr.io/eshop/payment.api:linux-latest
docker push djacr.azurecr.io/eshop/ordering.backgroundtasks:linux-latest
docker push djacr.azurecr.io/eshop/webhooks.client:linux-latest
docker push djacr.azurecr.io/eshop/webhooks.api:linux-latest

Once done you can see the images in ACR as below -

3.PNG

Deploy Images to AKS

To use your own images instead of the public ones, you have to pass following additional parameters to the deploy-all.ps1 script:

registry: Login server for the Docker registry
dockerUser: User login for the Docker registry
dockerPassword: User password for the Docker registry

.\deploy-all.ps1 -externalDns aks -aksName dj-eshop-aks -aksRg dj -imageTag linux-latest -registry djacr.azurecr.io -dockerUser djAcr -dockerPassword 8rlnoTqojGw4NncDl+Nqztmp3dDF6VgTnZPRlh4tw3+ACRAAxqNa -useMesh $false

You might get error "The term 'az' is not recognized as the name of a cmdlet". This indicates that the az command is not recognized as a valid command in the terminal or command prompt window you are using. The az command is specific to the Azure CLI, which is a command-line interface for managing resources in Microsoft Azure. You can install from here.

4.PNG

Also note You should enable HTTP routing in an AKS. Log in to the Azure portal (https://portal.azure.com/). Navigate to your AKS cluster.Click on the "Networking" section.In the Add-ons section, click on the "HTTP application routing" toggle switch to turn it on.Click the "Save" button to apply the changes.

5.PNG

Once the script is run, you should see following output when using

kubectl get deployment

6.PNG

Every public service is exposed through its own ingress resource, as you can see if using

kubectl get ing

7.PNG

Now you access the webmvc app as below -

8.PNG

Discover and read more posts from DhananjayKumar
get started
post commentsBe the first to share your opinion
zat zinou
a year ago

Hello Kumar,
Thank you for this interessting arcticeles series on deploying eShopOnContainers sample application.
I tried to deploy this application on AKS but there is a problem with the option “enable application routing”. This option is not supported with K8s version 1.22+ and i decided to use Application Gateway Ingress instead. Many composants were not ready like the 4 SQL Server databases were not created and i have many pods in error.
I used the public images unlike your article. Will you plan an article about the deplyoyment of this application using AKS and Application Gateway ?
Thank you for your help.

Show more replies