DEV Community

Michael Levan
Michael Levan

Posted on

AKS Automatic: Configure k8s Without Configuring k8s

When Kubernetes first came out, everyone felt that it was hard to manage and required significant expertise. Then, Managed Kubernetes Services (AKS, EKS, GKE, etc.) came out and the management got a little bit easier, but it still showed a significant effort.

Engineers and developers across the globe wanted a way to use Kubernetes without having to worry about the overall management.

Enter AKS Automatic.

Why AKS Automatic

As mentioned in the opening of this post, the idea behind AKS Automatic is to give you the ability to use Kubernetes and all of the API-driven infrastructure that comes with it without having to necessarily manage Kubernetes itself.

Why is this important? Because the following:

  • Resource optimization.
  • Cost optimization.
  • Ensuring the proper resources are within the cluster configuration.
  • Upgrades, updates, and overall management.
  • Scaling.
  • Security.
  • Monitoring and observability (AKS Automatic comes pre-installed with managed Grafana and Prometheus).

was the responsibly of the engineer creating and managing the environment, which is totally fine, but it doesn’t give engineers/developers who aren’t “experts” in Kubernetes a chance to use Kubernetes. It limits who can use Kubernetes in production or even in testing/dev environments.

With AKS Automatic, the engineer no longer has to worry about cluster creation, node management, security, and scaling which is great for some organizations and teams.

On the flipside (because there’s always a con in anything you implement), you lose all of the flexibility and configuration options available. For example organizations, this matters a ton. For many others, it doesn’t.

As with any implementation/solution, understand what it is prior to using it.

Before AKS Automatic

Prior to using AKS Automatic, you’ll need a few different Azure Preview features.

As you can see in the screenshot below, if you try to create an AKS Automatic cluster without these Preview Features, you’ll see an error.

If you click the blue Register preview features button, they will get installed automatically.

Image description

Image description

Please note that at the time of writing this, the supported methods of deploying AKS Automatic is with the Azure portal, the Azure CLI, and Bicep.

Image description

Creating The Cluster

Now that the prerequisites are complete and you know the “why” behind implementing AKS Automatic, let’s learn about three different ways to create an AKS Automatic cluster.

Portal

First, go to the AKS service.

When you click the + Create button dropdown, you’ll see the option for Automatic Kubernetes Cluster (AKS Automatic).

Image description

Choose the proper subscription and Resource Group along with specifying a name for your cluster, the region it’ll reside in, and the upgrade schedule.

Image description

In the next tab, you’ll see a few different options for implementing monitoring and observability. via Container Insights, Managed Prometheus, and Managed Grafana.

Image description

And that’s it! Literally. There are only a few options that you have to configure. Everything else is managed for you.

You should see the cluster getting created and updated in the Kubernetes Service portal.

Image description

What you’ll notice is the majority of the infrastructure-related work is abstracted away from you.

Image description

In hindsight, AKS Automatic and other services like it are realistically what Managed Kubernetes Services were meant to be.

CLI

Next, let’s learn how to do it with the Azure CLI.

First, add the extension for AKS Preview if you don’t already have it.

az extension add --name aks-preview
Enter fullscreen mode Exit fullscreen mode

Next, register the AutomaticSKUPreview preview service.

az feature register --namespace Microsoft.ContainerService --name AutomaticSKUPreview
Enter fullscreen mode Exit fullscreen mode

Register the Microsoft.ContainerService provider.

az provider register --namespace Microsoft.ContainerService
Enter fullscreen mode Exit fullscreen mode

Create an AKS cluster like you usually would using the aks create command, but use the automatic SKU.

az aks create -g devrelasaservice -n myAKSAutomaticCluster --sku automatic
Enter fullscreen mode Exit fullscreen mode

PowerShell

If you’re interested in a little further automation, here’s a PowerShell function you can use.

function Create-AKSAutomatic {
    param (
        [parameter(Mandatory=$true)]
        [alias('rg')]
        [string]$resourceGroupName,

        [parameter(Mandatory=$true)]
        [alias('name')]
        [string]$clusterName
    )

    begin {
        $subscription = az account show
        if ($subscription -eq $null) {
            Write-Error "No subscription is chosen. Please run: az login"
        }
    }

    process {
        az aks create -g $resourceGroupName -n $clusterName --sku automatic
    }

    end {
        Write-Output "Cluster Created"
    }
}
Enter fullscreen mode Exit fullscreen mode

You can then run it with the following once the code is loaded on your system:

Create-AKSAutomatic -resourceGroupName "devrelasaservice" -clusterName "myAKSClust"
Enter fullscreen mode Exit fullscreen mode

Closing Thoughts

It’s very interesting to see this level of abstraction and more importantly, it’s going to be interesting to see just how many organizations adopt it. Will organizations go in this direction or will they be nervous to give up this level of control?

Top comments (0)