You will now deploy a containerized application to the Kubernetes cluster running in Azure.
To deploy an application to the Kubernetes cluster, you typically use the YAML files containing a workload declaration. To deploy an application, we will use a declaration containing two objects: deployment and a service. A deployment will create a specific number of Kubernetes pods. These are the smallest deployable units in Kubernetes. A single pod includes one or more containers sharing the volumes and network capabilities. Thus, the declaration of the deployment consists of elements such as:
To expose the pod to other services and the Internet, we will use a Service of the type Load Balancer. Under the hood, Kubernetes will request a public IP from Azure. We will use this IP to access our application.
Let’s now use this declaration to deploy our People.WebApp to the Azure Kubernetes Cluster. To do so, we proceed as follows:
Open the Cloud Shell
Download the declaration file by typing:
Check line number 17. In our case, it points to the fully qualified container image name, image: people.azurecr.io/people.webapp:v1. This includes the container registry login server, image name, and image tag. The login server is the same one we created in part 2 of this learning path series. If you use a different name for either the container registry or the container name, update line 17 correspondingly. Then save the changes to the same file, people_aks.yml (CTRL+S), and close the editor (CTRL+Q).
To deploy the workload, type the following command in the Cloud Shell:
kubectl apply -f people_aks.yml
It will take a few moments to deploy the workload. Then, use the following command to display the list of pods:
kubectl get pods
Ensure the status of each pod is running. Then type:
kubectl get svc
This will display the list of services as shown below:
Note the IP address under the EXTERNAL-IP column of people-web-appsvc. That is the Public IP where you can find your application. In my case, that is 22.214.171.124. By typing this IP in the web browser, you will see an application up and running:
To remove all the cloud resources, we deployed for this tutorial, open the Cloud Shell, and type the following command:
az group delete -n rg-arm64 --yes --no-wait
This tutorial has shown you how to create the Azure Kubernetes cluster with the arm64-powered VMs. Then, you learned how to deploy a containerized application to this cluster. Finally, you exposed the application over the Internet using the LoadBalancer service. Along the way, you saw how to use the Cloud Shell built-in code editor to modify the Kubernetes workload declaration file.