Skip to main content

Azure Kubernetes Service

3795878333.png

Prerequisites

The L7|ESP Helm chart will be installed on a managed cloud-native Kubernetes service, therefore it is imperative to have:

  • Azure Subscription

  • Azure Service Principal Account

CLI tools

The kubectl and az command line tools will be use respectively to programmatically access the Kubernetes cluster and the Azure subscription. To install the CLI tools, follow the link below and choose the correct operating sytem:

ARM template

The latest ARM template is as follows:

Bicep

@description('The location of AKS resource.')
param azureLocation string = resourceGroup().location

@description('The name of the Managed Cluster resource.')
param clusterName string = 'l7esp-example'

@description('The number of nodes for the cluster. 1 Node is enough for Dev/Test and minimum 3 nodes, is recommended for Production')
@minValue(1)
@maxValue(100)
param clusterNodeCount int = 3

@description('The size of the Virtual Machine.')
param clusterNodeSize string = 'Standard_D4_v4'

@description('Disk size (in GiB) to provision for each of the agent pool nodes. This value ranges from 0 to 1023. Specifying 0 will apply the default disk size for that agentVMSize.')
@minValue(0)
@maxValue(1023)
param clusterNodeDiskGB int = 0

@description('Optional DNS prefix to use with hosted Kubernetes API server FQDN.')
param clusterDNSPrefix string = 'l7esp-example'

resource cluster 'Microsoft.ContainerService/managedClusters@2020-09-01' = {
  location: azureLocation
  name: clusterName
  tags: {
    displayname: 'AKS Cluster'
  }
  identity: {
    type: 'SystemAssigned'
  }
  properties: {
    dnsPrefix: clusterDNSPrefix
    agentPoolProfiles: [
      {
        name: 'agentpool'
        osDiskSizeGB: clusterNodeDiskGB
        count: clusterNodeCount
        vmSize: clusterNodeSize
        osType: 'Linux'
        type: 'VirtualMachineScaleSets'
        mode: 'System'
      }
    ]
  }
}

output clusterFQDN string = cluster.properties.fqdn

JSON

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "metadata": {
    "_generator": {
      "name": "bicep",
      "version": "0.6.18.56646",
      "templateHash": "16874195123538177185"
    }
  },
  "parameters": {
    "azureLocation": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "The location of AKS resource."
      }
    },
    "clusterName": {
      "type": "string",
      "defaultValue": "l7esp-example",
      "metadata": {
        "description": "The name of the Managed Cluster resource."
      }
    },
    "clusterNodeCount": {
      "type": "int",
      "defaultValue": 3,
      "maxValue": 100,
      "minValue": 1,
      "metadata": {
        "description": "The number of nodes for the cluster. 1 Node is enough for Dev/Test and minimum 3 nodes, is recommended for Production"
      }
    },
    "clusterNodeSize": {
      "type": "string",
      "defaultValue": "Standard_D4_v4",
      "metadata": {
        "description": "The size of the Virtual Machine."
      }
    },
    "clusterNodeDiskGB": {
      "type": "int",
      "defaultValue": 0,
      "maxValue": 1023,
      "minValue": 0,
      "metadata": {
        "description": "Disk size (in GiB) to provision for each of the agent pool nodes. This value ranges from 0 to 1023. Specifying 0 will apply the default disk size for that agentVMSize."
      }
    },
    "clusterDNSPrefix": {
      "type": "string",
      "defaultValue": "l7esp-example",
      "metadata": {
        "description": "Optional DNS prefix to use with hosted Kubernetes API server FQDN."
      }
    }
  },
  "resources": [
    {
      "type": "Microsoft.ContainerService/managedClusters",
      "apiVersion": "2020-09-01",
      "name": "[parameters('clusterName')]",
      "location": "[parameters('azureLocation')]",
      "tags": {
        "displayname": "AKS Cluster"
      },
      "identity": {
        "type": "SystemAssigned"
      },
      "properties": {
        "dnsPrefix": "[parameters('clusterDNSPrefix')]",
        "agentPoolProfiles": [
          {
            "name": "agentpool",
            "osDiskSizeGB": "[parameters('clusterNodeDiskGB')]",
            "count": "[parameters('clusterNodeCount')]",
            "vmSize": "[parameters('clusterNodeSize')]",
            "osType": "Linux",
            "type": "VirtualMachineScaleSets",
            "mode": "System"
          }
        ]
      }
    }
  ],
  "outputs": {
    "clusterFQDN": {
      "type": "string",
      "value": "[reference(resourceId('Microsoft.ContainerService/managedClusters', parameters('clusterName'))).fqdn]"
    }
  }
}

ARM template parameters

When deploying the ARM template, you can override parameters like so:

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
      "agentCount": {
          "value": 4
      },
      "agentVMSize": {
          "value": "standard_d11_v2"
      }
  }
}
  • azureLocation: The location of AKS resource. Default value: same region/location as the resource group you are deploying ARM template into.

  • clusterDNSPrefix: Optional DNS prefix to use with hosted Kubernetes API server FQDN. Default value: aks-esp

  • clusterName: The name of the Managed Cluster resource. Default value: aks101cluster-vmss

  • clusterNodeCount: The number of nodes for the cluster. One node is enough for Dev/Test and minimum 3 nodes is recommended for Production. Default: 3

  • clusterNodeDiskGB: Disk size (in GiB) to provision for each of the agent pool nodes. This value ranges from 0 to 1023. Specifying 0 will apply the default disk size for that agentVMSize. Default value: 0

  • clusterNodeSize: The size of the virtual machine. Default: Standard_D4_v4

Deploy ARM template

Login to Azure. For example, if you are using a service principle account that has Contributor role, you can login to Azure using the following command:

$ az login \
      --service-principal \
      --username <service-principal-id> \
      --password <service-principal-password> \
      --tenant <tenant-id>

Create a resource group to deploy into, if you haven’t already:

$ az group create \
      --name <resource-group-name> \
      --location <resource-group-location>

Create ARM deployment in the resource group:

$ az group deployment create \
      --resource-group l7esp-example-rg \
      --name l7esp-example \
      --template-file ./aks.template.json \
      --parameters ./aks.parameters.json \
      --rollback-on-error \
      --verbose

Validate Resource Creation

In the Azure portal, navigate to the resource group and verify that all resources are listed:

3796271647.png

Access the Kubernetes cluster

Log into your Azure Subscription to access cluster:

$ az login

Use the Azure CLI to download the Kubernetes credentials into your local config:

$ az aks get-credentials \
       --name <cluster-name> \
       --resource-group <cluster-resource>
Merged "<my-cluster>" as current context in /home/<user>/.kube/config

Check that Kubernetes nodes were successfully provisioned and are healthy:

$ kubectl get nodes
NAME                                STATUS   ROLES   AGE   VERSION
aks-agentpool-21130059-vmss000000   Ready    agent   1h    v1.22.6
aks-agentpool-21130059-vmss000001   Ready    agent   1h    v1.22.6
aks-agentpool-21130059-vmss000002   Ready    agent   1h    v1.22.6
aks-agentpool-21130059-vmss000003   Ready    agent   1h    v1.22.6

You should see a list of nodes with a Ready status.

Installing L7|ESP Helm chart

To install L7|ESP on the new Kubernetes cluster, see the Helm deployment guide.