iWay Azure Deployment

iWay Azure Deployment overview

The goal of this tutorial is to show how to deploy iWay application that was built by iWay iIT tool in the previous tutorial here to the Microsoft Azure Cloud

Microsoft Azure is an ever-expanding set of cloud services to help your organization meet your business challenges. It's the freedom to build, manage, and deploy applications on a massive, global network using your favorite tools and frameworks.

In short, this application consists of two Docker containers:

  1. iWay Application exposing an API(defined via RAML file) which utilized the iIT MongoDB Connector
  2. MongoDB Server

We brought these containers up and managed communication between two by using Kubernetes technology.

Kubernetes is an open-source system for automating deployment, scaling, and management of containerized applications.

We deploy this application onAzure Cloud by utilizing brand new Microsoft product called Azure Kubernetes Service (AKS).

Actually, by utilizing technologies described above we managed to build a Software as a Service (SaaS) managed by Azure Cloud!

Software as a service (SaaS) is a software distribution model in which a third-party provider hosts applications and makes them available to customers over the Internet.

SaaS is one of three main categories of cloud computing, alongside infrastructure as a service (IaaS) and platform as a service (PaaS).

What is AKS?

Azure Kubernetes Service (AKS) manages your hosted Kubernetes environment, making it quick and easy to deploy and manage containerized applications without container orchestration expertise. It also eliminates the burden of ongoing operations and maintenance by provisioning, upgrading, and scaling resources on demand, without taking your applications offline.

Introduction to Azure Kubernetes Service (AKS) preview

Azure Kubernetes Service (AKS) makes it simple to create, configure, and manage a cluster of virtual machines that are preconfigured to run containerized applications.

This enables you to use your existing skills, or draw upon a large and growing body of community expertise, to deploy and manage container-based applications on Microsoft Azure.

By using AKS, you can take advantage of the enterprise-grade features of Azure, while still maintaining application portability through Kubernetes and the Docker image format.

Important:

Azure Kubernetes Service (AKS) is currently in preview. Previews are made available to you on the condition that you agree to the supplemental terms of use.

Some aspects of this feature may change prior to general availability (GA).

Managed Kubernetes in Azure

AKS reduces the complexity and operational overhead of managing a Kubernetes cluster by offloading much of that responsibility to Azure.

As a hosted Kubernetes service, Azure handles critical tasks like health monitoring and maintenance for you.

In addition, you pay only for the agent nodes within your clusters, not for the masters. As a managed Kubernetes service, AKS provides:

  • Automated Kubernetes version upgrades and patching
  • Easy cluster scaling
  • Self-healing hosted control plane (masters)
  • Cost savings - pay only for running agent pool nodes

With Azure handling the management of the nodes in your AKS cluster, you no longer need to perform many tasks manually, like cluster upgrades.

Because Azure handles these critical maintenance tasks for you, AKS does not provide direct access (such as with SSH) to the cluster.

Using Azure Kubernetes Service (AKS)

The goal of AKS is to provide a container hosting environment by using open-source tools and technologies that are popular among customers today.

AKS expose the standard Kubernetes API endpoints. By using these standard endpoints, you can leverage any software that is capable of talking to a Kubernetes cluster.

For example, you might choose kubectl, helm, or draft.

Creating a Kubernetes cluster using Azure Kubernetes Service (AKS)

To begin using AKS, deploy an AKS cluster with the Azure CLI or via the portal (search the Marketplace for Azure Kubernetes Service).

If you are an advanced user who needs more control over the Azure Resource Manager templates, use the open-source acs-engine project to build your own custom Kubernetes cluster and deploy it via the az CLI.

Using Kubernetes

Kubernetes automates deployment, scaling, and management of containerized applications. It has a rich set of features including:

  • Automatic binpacking
  • Self-healing
  • Horizontal scaling
  • Service discovery and load balancing
  • Automated rollouts and rollbacks
  • Secret and configuration management
  • Storage orchestration
  • Batch execution

Deploy an Azure Kubernetes Service (AKS) cluster

Install Azure CLI 2.0.

The Azure CLI 2.0 is a command-line tool for managing Azure resources.

https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-windows?view=azure-cli-latest

Sign in to the Azure portal at http://portal.azure.com.

Select the Cloud Shell button on the menu in the upper-right corner of the Azure portal:

 

Run

az --version

to find the version. If you need to install or upgrade, see Install Azure CLI.

Ensure that the needed Azure service providers are enabled with the az provider register command.

az provider register -n Microsoft.Network
az provider register -n Microsoft.Storage
az provider register -n Microsoft.Compute
az provider register -n Microsoft.ContainerService

After registering, you are now ready to create a Kubernetes cluster with AKS.

Create a resource group

Create a resource group with the az group create command. An Azure resource group is a logical group in which Azure resources are deployed and managed. When creating a resource group you are asked to specify a location, this is where your resources will live in Azure. While AKS is in preview, only some location options are available. These are eastus, westeurope, centralus, canadacentral, canadaeast.

The following example creates a resource group named myResourceGroup in the eastus location.

az group create --name myResourceGroup --location eastus

Output:

{
  "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup",
  "location": "eastus",
  "managedBy": null,
  "name": "myResourceGroup",
  "properties": {
    "provisioningState": "Succeeded"
  },
  "tags": null
}

Create AKS cluster

Use the az aks create command to create an AKS cluster. The following example creates a cluster named demoCluster with one node:

az aks create --resource-group myResourceGroup --name demoCluster --node-count 1 --generate-ssh-keys --node-vm-size Standard_D1_v2

Connect to the cluster

To manage a Kubernetes cluster, use kubectl, the Kubernetes command-line client.

If you're using Azure Cloud Shell, kubectl is already installed. If you want to install it locally, use the az aks install-cli command.

az aks install-cli

To verify the connection to your cluster, use the kubectl get nodes command to return a list of the cluster nodes.

Note that this can take a few minutes to appear.

stan_pokidaylo@Azure:~$ kubectl get nodes

NAME                       STATUS    ROLES     AGE       VERSION

aks-nodepool1-12257698-0   Ready     agent     19h       v1.9.6

Run the application

Use nano or vi editors to create deployment.yml and mongodb-deplyment.yml empty files

Copy and paste the content of the related yml files provided by the main document.

deployment.yml:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: myiway
  labels:
    app: myiway
spec:
  replicas: 1
  strategy: {}
  template:
    metadata:
      labels:
        app: myiway
    spec:
      containers:
      - image: iwaydocker/iwaydemo
        imagePullPolicy: Always
        name: myiway
        ports:
        - containerPort: 9999
        - containerPort: 9000
        - containerPort: 9001
        - containerPort: 8081
        resources: {}
      restartPolicy: Always
status: {}

mongodb-deplyment.yml:

---

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  annotations:
    kompose.cmd: C:\Program Files\docker\kompose-windows-amd64.exe convert -f docker-compose.yml
    kompose.version: 1.12.0 (0ab07be)
  creationTimestamp: null
  labels:
    io.kompose.service: mongodb
  name: mongodb
spec:
  replicas: 1
  strategy:
    type: Recreate
  template:
    metadata:
      creationTimestamp: null
      labels:
        io.kompose.service: mongodb
    spec:
      containers:
      - image: bitnami/mongodb:latest
        name: mongodb
        ports:
        - containerPort: 27017
        resources: {}
        volumeMounts:
        - mountPath: /data/db
          name: mongodb-claim0
      restartPolicy: Always
      volumes:
      - name: mongodb-claim0
        persistentVolumeClaim:
          claimName: mongodb-claim0
status: {}
---
	
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  creationTimestamp: null
  labels:
    io.kompose.service: mongodb-claim0
  name: mongodb-claim0
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 100Mi
status: {}

Then use the following kubernetes commands:

  1. kubectl apply -f deployment.yml
  2. kubectl apply -f mongodb-deployment.yml
  3. kubectl  expose deployment myiway --name=myiway  --type=Loadbalancer
  4. kubectl  expose deployment mongodb --name=mongodb  --type=Loadbalancer

Azure creates Load balancers for you:

Load Balancers Console

Internal load balancing makes a Kubernetes service accessible to applications running in the same virtual network as the Kubernetes cluster.

When all services using the internal load balancer have been deleted, the load balancer itself is also deleted

Services

Load balancer rules for the demo application:

Load Balancer Rules

Load balancer properties:

Load Balancer Properties

 

How to test an application on the AZURE cloud.

Run the following kubernetes command:

kubectl get services

GET Services Command

This command allows us to select an external IP address for the service.

Initially the EXTERNAL-IP for the services appears as pending.

After couple of minutes EXTERNAL-IP address has changed from pending to an IP address

By using EXTERNAL-IP address and port 9999 for the service myiway, we may visit the iWay Service manager Console:

iSM Administration Console

Use EXTERNAL-IP address on port 8081 and iIT iWay Explorer to post JSON document into MongoDB database:

iWay Explorer

Use the API endpoint  to browse the posted document:

API Endpoint