Skip to main content
  1. Posts/

AKS doodle

·2 mins·

As a minor excercise I created an AKS cluster (just to see how it compares to my previous experience, where I ran it on bare metal). In the process I established, compared to the blood-and-sweat strugle to setting up a cluster on bare metal (I am not talking about the likes of Minikube – rather k3s on physical / virtual hosts); where you actually have to set up master nodes, worker nodes, networking, load balancers, HA proxy and soo many other things – setting up a cloud cluster from scratch is unsurprisingly a few minute excercise. Probably the longest part was to figure out how to apply the guides – which were assuming you work with vanila Terraform – to use Terragrunt. (I do prefer Terragrunt, `cause of dependencies and all compared to the unwrapped TF).

I first created a few (well, for this one only one is relevant) resource groups. I am not going to detail it here, as it is not that relevant; you can create these from the AZ GUI if you like.

The I set the following files:

# cat terragrunt.hcl
include {
  path = find_in_parent_folders()

dependencies {
  paths = ["../resource-groups"]
# cat
resource "azurerm_kubernetes_cluster" "cluster" {
  name                = "fabricesemti"
  location            = "northeurope"
  resource_group_name = "my-aks-rg"
  dns_prefix          = "fabricesemti"

  default_node_pool {
    name       = "default"
    node_count = "2"
    vm_size    = "standard_d2_v2"

  identity {
    type = "SystemAssigned"
# cat
resource "local_file" "kubeconfig" {
  depends_on   = [azurerm_kubernetes_cluster.cluster]
  filename     = "kubeconfig"
  content      = azurerm_kubernetes_cluster.cluster.kube_config_raw

This took ~5 min and set up a 2 node cluster. Added the kubeconfig to my default config cp kubeconfig ~/.kube/config

kubectl get nodes --kubeconfig kubeconfig
NAME                              STATUS   ROLES   AGE   VERSION
aks-default-20572636-vmss000000   Ready    agent   68m   v1.23.12
aks-default-20572636-vmss000001   Ready    agent   68m   v1.23.12

Next I grabbed a sample app and deployed it to my cluster

k apply -f
Warning: spec.template.spec.nodeSelector[]: deprecated since v1.14; use "" instead
deployment.apps/azure-vote-back created
service/azure-vote-back created
deployment.apps/azure-vote-front created
service/azure-vote-front created

Looks good according to kubectl

default        pod/azure-vote-back-6fcdc5cbd5-zw69n      1/1     Running   0          6m29s
default        pod/azure-vote-front-5f4b8d498-pshzq      1/1     Running   0          6m29s
default        service/azure-vote-back      ClusterIP    <none>         6379/TCP        6m30s
default        service/azure-vote-front     LoadBalancer   80:30158/TCP    6m30s
default        deployment.apps/azure-vote-back      1/1     1            1           6m30s
default        deployment.apps/azure-vote-front     1/1     1            1           6m30s
default        replicaset.apps/azure-vote-back-6fcdc5cbd5      1         1         1       6m30s
default        replicaset.apps/azure-vote-front-5f4b8d498      1         1         1       6m30s

And the browser seems to agree too

vote app
vote for dogs of course!