Life's random bits By b1thunt3r (aka Ishan Jain)…
Getting Started: Azure Kubernetes Services

Getting Started: Azure Kubernetes Services

Ishan jain
Docker is fine, when you need to run a handful of containers. But when it comes to running a full cluster, you need another wrapper on top of Docker.

Disclaimer: Currently I am employed by Microsoft, but my views and thoughts are still my own. The reason I joined Microsoft was, the work Microsoft have been doing for last couple of years in Open Source Space. Today I am a advocate for Open Source representing Microsoft.

For managing a cluster of containers, there are several different options; Docker Swarm, Rancher, Kubernetes, Open Shift, etc.

Azure provides three different ways to run Kubernetes:

  1. Infrastructure as a Service (IaaS)
    • Running and managing your own Kubernetes
  2. Azure Kubernetes Service (AKS)
  3. Azure Red Hat Open Shift (AROS)

NOTE: There are several ways to manage Azure, but here I am going to use Azure-CLI. All the commands are cross-platform.


Assuming you have:

Provisioning a Kubernetes cluster

You can create AKS cluster with:

az aks create --name "{AKS-CLUSTER-NAME}" --resource-group AKS-CLUSTER-NAME --node-count "{NODES}" --generate-ssh-keys


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

This will create a new AKS cluster with name aks-cluster in resource group aks-resource-group with 3 nodes.

NOTE: The AKS cluster will be created in the same Azure region as the resource group.

This will take 10-20 mins.

Configure your client

We can control the Kubernetes cluster with kubectl

Azure CLI can help you with the installation of kubectl:

sudo az aks install-cli

Now you need to tell kubectl to use AKS:

az aks get-credentials --name "{AKS-CLUSTER-NAME}" --resource-group "{AKS-CLUSTER-NAME}"

Make sure to use the correct --name and --resource-group.

You can verify the connection to AKS cluster with:

kubectl get nodes

This will return a list of nodes in the connected AKS cluster.

Test AKS Cluster

Create deployment manifest

Copy and paste the flowing code to a nginx.yaml:

apiVersion: apps/v1
kind: Deployment
  name: nginx-deployment
      app: nginx
  replicas: 1
        app: nginx
      - name: nginx
        image: nginx:latest
        - containerPort: 80
apiVersion: v1
kind: Service
  name: nginx-deployment
    app: nginx
    - protocol: TCP
      port: 80
      targetPort: 80
  type: LoadBalancer

Deploy the manifest with:

kubectl apply -f nginx.yml

Verify pod deployment:

kubectl get pods

You should get something like this:

NAME                               READY   STATUS    RESTARTS   AGE
nginx-deployment-6574bd76c-ppfzx   1/1     Running   0          20s

Get External IP of the Service

Now we can ask AKS for the external IP to the nginx service:

kubectl get services

NOTE: It can take sometime to get the external IP, just run the above command again if kubectl return <pending> after a minute or two.

Now you can see the external IP:

NAME              TYPE          CLUSTER-IP   EXTERNAL-IP    PORT(S)       AGE
nginx-deployment  LoadBalancer  <EXTERNAL-IP>  80:31257/TCP  53s

When you enter the <EXTERNAL-IP> in your browser you should be greated with the NGINX Welcome Screen.

Create a namespace

The best practice in Kubernetes is to use separate namespaces.

You create a new namespace in Kubernetes with:

kubectl create namespace  mssql