Azure, Technology

18. Azure Kubernetes Services (AKS)


Introduction to Containers

Containers are a cross platform way of deploying code.  It is an abstraction on top of VM’s.

Kubernetes is formally a Google standard but is now an industry standard for running containers.

“Azure Kubernetes Service (AKS) offers serverless Kubernetes, an integrated continuous integration and continuous delivery (CI/CD) experience, and enterprise-grade security and governance. Unite your development and operations teams on a single platform to rapidly build, deliver and scale applications with confidence.”

Kubernetes is not cheap or easy to run, but it is the industrial strength method of running containers.


Create an AKS Cluster

  1. Go to the Market place -> Containers -> Kubernetes Service
  2. Click on Create
  3. Select your standard options (Subscription, resource group)
  4. Give the Cluster a name (this must be unique to the resource group)
  5. Kubernetes version: generally choose default
  6. Select Node: this is the VM size
  7. Node Count: how many nodes you want to start with. It can go up to 100
  8. Node Pools: the is a group of nodes. you need at least one node pool. You can have several containers running in a node pool
  9. Networking: here you can create a new VNet for the cluster
  10. Click on Create


Kubectl (Kube Control)

Once the deployment is complete you get the option to “Go to resource”. From here you can see the overview of the cluster: Node pools, version etc… From here you can scale the nodes or change the version.

You can also add more nodes and they can be of different versions.

Managing Kubernetes with Cloud Shell

  1. Click on the Cloud Shell icon at the top of the Kubernetes instance overview page to enter the cloud shell. In this example we keep it in Bash.
  2. Connect to the Kubernetes service using the command:
    az aks get-credentials --resource-group rgname --name kubernetescontiainername
  3. We are now in the right context to manage the container

Some useful commands

Display node information:

kubectl get nodes


Deploy a Container/application to AKS

In this section we will deploy an application to the AKS. We will be using the sample application found on this page:

Kubernetes uses a “yaml” file to define the application. In this case the file is azure-vote.yaml

Deploying the application

  1. In the Kubernetes Cloud Shell, create a file:
    vi azure-vote.yaml
  2. Paste into this file the contents of the yaml file from the link above and save the file
  3. Apply the yaml file and push this to the nodes that are running:
    kubectl apply -f azure-vote.yaml
  4. This will create the services for the application
  5. Run the following command to show the services:
    kubectl get service

Testing the application

  1. From the results of the “kubectl get service” command you will the “Azure-Vote-Front” service has an external ip. Copy that IP and paste it into a web browser
  2. You will now see the front end of the Voting App


Scaling Kubernetes

If you run the following command it shows you the running services and the VMs they are running on:

Kubectl get pods -o wide

Scaling up

You can scale using the Kubecl with the following command:

Kubectl scale --replicas=3 deployment/azure-vote-front

This command will scale the “Azure Front” service over 3 VMs. Now when you run the command to get the services it will show it running on 3 VM’s

Scaling down

Run the same command just reduce the number of replicas:

Kubectl scale --replicas=1 deployment/azure-vote-front


Installing Docker Desktop

Docker Desktop is an application for MacOS and Windows machines for the building and sharing of containerized applications and microservices. This software allows you take your code, package it into a container, then publish it to a public or private repository.


ACI (Azure Container Instances)

Microsoft says that container instances are the quickest way to deploy a Docker container into Azure. Unlike AKS, where you had to create nodes, select the types, set scaling options etc…ACI allows you to just select the image and deploy it. There is no managing of VM’s etc…

“Develop apps fast without managing virtual machines or having to learn new tools – it’s just your application, in a container, running in the cloud.”

Setting up ACI

  1. Go to “Create a resource”
  2. Search for “container instance”
  3. Set the Subscription, Resource Group, Container Name, Location
  4. Image Source: this can be from Docker Hub or other registry, or a “Quick start Image” which are pre-configured web server images (nginx Linux server, nano server which is a tiny IIS web server)
  5. On the Networking tab you can set a domain name
  6. Click on Create

Leave a Reply

Your email address will not be published. Required fields are marked *