Getting Start with Azure Kubernetes Service (AKS)

Update :- Azure Kubernetes Service was renamed at Build 2018 as Kubernetes Service.

What is Azure Kubernetes Service (AKS)

Azure Kubernetes service (AKS) reduce the complexity and management overhead by offloading those responsibilities to Azure. In AKS we do not need to worry about managing our K8s master nodes. This process is cared by Azure and Its free (No need to pay any charge for managing master nodes pay only for agent pool VMs). AKS does not provide direct access (such as with SSH) to the cluster. As this is managed service it handles critical operations that as a K8s administrator has to do, such as

  • Automated updating/patching of master nodes
  • Cluster scaling for master nodes
  • Self-healing host control panel for master nodes
  • Pay only for the agent pool nodes.

We can use Azure CLI, Azure Portal create AKS cluster. At the moment AKS not available in every region. Refer the following link

https://azure.microsoft.com/en-us/global-infrastructure/services/

Fun Fact: – You may see in this article most of the times I use K8s as alias to Kubernetes. You may wonder how it made. Let’s see how 😊

  K | U B E R N E T E | S = K8s

In above after K and before S there are eight letters, so its shorten as 8

Usage and advantage of using Kubernetes

  1. Moving from monolithic apps to microservices

Monolithic apps are all tightly coupled and had to be developed and deployed as a one entity. Because of this if a developer changes one part of the application it needs to be redeployed again.

  1. Providing a consistent environment to applications
  2. Moving to continuous delivery: DevOps and NoOps
  3. Automatic binpacking
  4. Self-healing
  5. Horizontal scaling
  6. Service discovery and load balancing
  7. Automated rollouts and rollback
  8. Secret and configuration management
  9. Storage orchestration
  10. Batch execution

Kubernetes Architecture

Let’s see how the Kubernetes architecture works. Following is a high-level diagram of K8s cluster.

The Control Plane

The Control Plane is what controls the cluster and makes it function. In control Pane it consists of multiple components. If we are running single master node all those components are stays in one node. But in the multi node environment it spread across those master nodes and replicated to ensure high availability. These components are

  • The Kubernetes API Server, which you and the other Control Plane components communicate with
  • The Scheduler, which schedules your apps (assigns a worker node to each deployable component of your application)
  • The Controller Manager, which performs cluster-level functions, such as replicating components, keeping track of worker nodes, handling node failures, and so on
  • etcd, a reliable distributed data store that persistently stores the cluster configuration.

The components of the Control Plane hold and control the state of the cluster, but they don’t run your applications. This is done by the (worker) nodes.

The nodes

The worker nodes are the machines that run your containerized applications. The task of running, monitoring, and providing services to your applications is done by the following components:

  • Docker, rkt, or another container runtime, which runs your containers
  • The Kubelet, which talks to the API server and manages containers on its node
  • The Kubernetes Service Proxy (kube-proxy), which load-balances network traffic between application components

We can create a K8s cluster by using Azure CLI, Portal, ARM Template. Following are short demo how we can do it.

Using Azure Portal

Before creating AKS cluster using portal we need to have Azure AD SPN & SSH key

  • Create a SPN Follow this link.
  • To create SSH we can use PuttyGen.

Kubernetes Cluster creation via portal (New UI)

 

Using Azure CLI

This is the easiest and quickest way to create a AKS cluster. Following is the CLI guide

Enable AKS

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

Create Resource Group

az group create --name aksdemo-rg --location eastus

Create a AKS Cluster

az aks create --resource-group aksdemo-rg --name aksdemo --node-count 3 --generate-ssh-keys

Connect to a cluster

By default, Azure cloud shell kubeclt installed default

az aks install-cli

Get SSH credentials

az aks get-credentials --resource-group aksdemo-rg --name aksdemo

Try the kubectl commands

kubectl get nodes

Next blog I will walk-through more deep on Pods and features of them