Date

AKS Lab: Crating ASK Cluster

Summary

In this Lab article we will create Azure Kubernetes Cluster with a Linux Node (default). We will add new Windows Node to the AKS Cluster and scale Cluster Node and Pods

Prerequisites

Azure subscription for Azure Container Instance, Azure Container Registry, kubeclt and Azure CLI module for Windows

Creating Azure Kubernetes Cluster

Step by step process
  1. Create a Resource Group for Azure Kubernetes Cluster

 az group create -n aksGroup -l eastus 

2. Create Azure Kubernetes Cluster with Azure Directory SPN or Username and Password. We will use Username and Password

 az aks create ` 

>> –name azureCluster `

 >> --resource-group aksGroup ` 

 >> --node-count 1 `

 >> --generate-ssh-key `

>> --windows-admin-username azureuser `

 >> --windows-admin-password "Password@123" ` 

 >> --vm-set-type VirtualMachineScaleSets ` 

>> --network-plugin azure `

 >> --location eastus 

3. Get the Credentials for Azure Kubernetes Cluster (Name: “azureCluster”; Resource group: “aksGroup”)

 az aks get-credentials --name "azureCluster" --resource-group "aksGroup" 

Merged “azureCluster” as current context in C:\Users\ AZurs \.kube\config

4. Set Environment variable for kubectl

 $env:Path += ";C:\Users\ AZurs" 

 [Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\Users\ AZurs", [EnvironmentVariableTarget]::Machine) 

 $env:KUBECONFIG="C:\Users\ AZurs\config" 

 [Environment]::SetEnvironmentVariable("KUBECONFIG", "C:\Users\ AZurs\config", [EnvironmentVariableTarget]::User) 

 kubectl config view 

5. Validate Kube Config file for AKS Cluster

 cat C:\Users\ AZurs\.kube\config | sls "azureCluster" 

  name: azureCluster
    cluster: azureCluster
    user: clusterUser_aksGroup_azureCluster
  name: azureCluster
current-context: azureCluster
- name: clusterUser_aksGroup_azureCluster

6. Check Node Status in Azure Kubernetes Cluster

 kubectl get node -o wide 

NAME                                STATUS   ROLES   AGE   VERSION    INTERNAL-IP   EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION      CONTAINER-RUNTIME

aks-nodepool1-25205424-vmss000000   Ready    agent   36m   v1.16.13   10.240.0.4    <none>        Ubuntu 16.04.6 LTS   4.15.0-1091-azure   docker://3.0.10+azure

7. Delete Azure Kubernetes Cluster

 az aks delete --name azureCluster --resource-group aksGroup 

8. Scale Azure Kubernetes Cluster to NodeCount: 3

 az aks scale  --resource-group "aksGroup" --name "azureCluster" `  

 >> --node-count 3   

9. Scale Pods using –replicas: 4

 Kubectl scale --replicas=4 deployment/<deployment-name> 

10. Scale Down AKS Cluster (Node Count: 3 – 1)

Verify current Node count (3)

 kubectl get node -o wide  

NAME                                STATUS   ROLES   AGE     VERSION    INTERNAL-IP   EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION      CONTAINER-RUNTIME

aks-nodepool1-25205424-vmss000000   Ready    agent   7h18m   v1.16.13   10.x.x.4    <none>        Ubuntu 16.04.6 LTS   4.15.0-1091-azure   docker://3.0.10+azure

aks-nodepool1-25205424-vmss000001   Ready    agent   6h14m   v1.16.13   10.x.x.5    <none>        Ubuntu 16.04.6 LTS   4.15.0-1091-azure   docker://3.0.10+azure

aks-nodepool1-25205424-vmss000002   Ready    agent   6h14m   v1.16.13   10.x.x.6    <none>        Ubuntu 16.04.6 LTS   4.15.0-1091-azure   docker://3.0.10+azure

Scale down count to 1

 az aks scale  --resource-group "aksGroup" --name "azureCluster" ` 

 >> --node-count 1  

Check current Node count in AKS Cluster after scale down

 kubectl get node -o wide 

NAME                                STATUS   ROLES   AGE     VERSION    INTERNAL-IP   EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION      CONTAINER-RUNTIME

aks-nodepool1-25205424-vmss000000   Ready    agent   7h23m   v1.16.13   10.x.x.4    <none>        Ubuntu 16.04.6 LTS   4.15.0-1091-azure   docker://3.0.10+azure

Creating Node Pool for Windows Node

The following limitations apply when you create and manage AKS clusters that support multiple node pools:

  • You can’t delete the first node pool.

The following additional limitations apply to Windows Server node pools:

  • The AKS cluster can have a maximum of 10 node pools.
  • The AKS cluster can have a maximum of 100 nodes in each node pool.
  • The Windows Server node pool name has a limit of 6 characters.

Windows Server containers, the default value for node-vm-size is Standard_D2s_v3

Step by Step process
  1. Create New Cluster with Windows Profile for Windows Pool

  az aks create `

 >> --name azureCluster ` 

 >> --resource-group aksGroup `

 >> --node-count 1 `

 >> --generate-ssh-key ` 

 >> --windows-admin-username azureuser ` 

 >> --windows-admin-password "Password@123" `

 >> --vm-set-type VirtualMachineScaleSets ` 

 >> --network-plugin azure ` 

 >> --location eastus   

2. Create Node Pool for Windows Containers

 az aks nodepool add ` 

 >> --resource-group aksGroup `  

 >> --cluster-name azureCluster `

 >> --os-type Windows `

 >> --name winpl `

 >> --node-count 1 

3. Check AKS cluster Node status

 kubectl get node -o wide 

NAME                                STATUS   ROLES   AGE    VERSION    INTERNAL-IP   EXTERNAL-IP   OS-IMAGE                         KERNEL-VERSION      CONTAINER-RUNTIME

aks-nodepool1-25205424-vmss000000   Ready    agent   25m    v1.16.13   10.x.x.4    <none>        Ubuntu 16.04.6 LTS               4.15.0-1091-azure   docker://3.0.10

akswinpl000000                      Ready    agent   7m6s   v1.16.13   10.x.x.35   <none>        Windows Server 2019 Datacenter   10.0.17763.1339     docker://19.3.5

AZmachina

Knowledge Shared = Knowledge2

We have created AZmachina blog to share our knowledge on Docker & Container and Kubernetes on Windows Servers with curious and enthusiastic novice learner. We hope that this will help them to take a swim in this vast ocean of Window Containers and Kubernetes

Happy Learning !
Recent Posts
Categories
Archives
Sumeet Kumar

Sumeet Kumar

I am Windows Core Engineer with 7+ years of experience in Windows Hyper-v, Failover Cluster, Windows Storage, Volume Shadow Copy (VSS), Docker & Containers on Windows Servers, Backup & Recovery, VMware vSphere EXSi & vCenter Server

RELATED

Articles

Leave a Reply

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