Skip to content

Commit

Permalink
Extend multiple_node_pools example to test AKS upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
zioproto committed Jan 26, 2024
1 parent 3851478 commit ca11785
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 11 deletions.
74 changes: 74 additions & 0 deletions examples/multiple_node_pools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Testing the upgrade scenario

You can use this example to manually test the upgrade scenario.

See existing AKS versions:

```
% az aks get-versions --location centralus
KubernetesVersion Upgrades
------------------- ------------------------
1.28.3 None available
1.28.0 1.28.3
1.27.7 1.28.0, 1.28.3
1.27.3 1.27.7, 1.28.0, 1.28.3
1.26.10 1.27.3, 1.27.7
1.26.6 1.26.10, 1.27.3, 1.27.7
1.25.15 1.26.6, 1.26.10
1.25.11 1.25.15, 1.26.6, 1.26.10
```

In this example we test an upgrade from 1.26.10 to 1.27.7.

## Create the AKS cluster at version 1.26.10:

```
terraform init -upgrade
terraform apply -var="kubernetes_version=1.26.10" -var="orchestrator_version=1.26.10"
```

Verify the AKS cluster version:

```
az aks list -o table # check AKS version
az aks get-credentials --resource-group <rg> --name <name>
kubectl version # check api server version
kubectl get nodes # check nodes version
```

In the `az aks list` output you will have `KubernetesVersion` and `CurrentKubernetesVersion` both at 1.26.10

## Upgrade the AKS cluster control plane only to version 1.27.7

```
terraform apply -var="kubernetes_version=1.27.7" -var="orchestrator_version=1.26.10"
```

Check the new versions:


```
az aks list -o table # check AKS version
kubectl version # check api server version
kubectl get nodes # check nodes version
```

In the `az aks list` output you will have `KubernetesVersion` and `CurrentKubernetesVersion` both at 1.27.7
The control plane version will be 1.27.7 and the nodes will be 1.26.10.

## Upgrade the AKS cluster node pools to version 1.27.7

```
terraform apply -var="kubernetes_version=1.27.7" -var="orchestrator_version=1.27.7"
```

Check the new versions:

```
az aks list -o table # check AKS version
kubectl version # check api server version
kubectl get nodes # check nodes version
```

In the `az aks list` output you will have `KubernetesVersion` and `CurrentKubernetesVersion` both at 1.27.7
The control plane version will be 1.27.7 and the nodes will be 1.27.7.
25 changes: 14 additions & 11 deletions examples/multiple_node_pools/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,25 @@ resource "azurerm_subnet" "test" {
locals {
nodes = {
for i in range(3) : "worker${i}" => {
name = substr("worker${i}${random_id.prefix.hex}", 0, 8)
vm_size = "Standard_D2s_v3"
node_count = 1
vnet_subnet_id = azurerm_subnet.test.id
name = substr("worker${i}${random_id.prefix.hex}", 0, 8)
vm_size = "Standard_D2s_v3"
node_count = 1
vnet_subnet_id = azurerm_subnet.test.id
orchestrator_version = var.orchestrator_version
}
}
}

module "aks" {
source = "../.."

prefix = "prefix-${random_id.prefix.hex}"
resource_group_name = local.resource_group.name
os_disk_size_gb = 60
sku_tier = "Standard"
rbac_aad = false
vnet_subnet_id = azurerm_subnet.test.id
node_pools = local.nodes
prefix = "prefix-${random_id.prefix.hex}"
resource_group_name = local.resource_group.name
os_disk_size_gb = 60
sku_tier = "Standard"
rbac_aad = false
vnet_subnet_id = azurerm_subnet.test.id
node_pools = local.nodes
kubernetes_version = var.kubernetes_version
orchestrator_version = var.orchestrator_version
}
10 changes: 10 additions & 0 deletions examples/multiple_node_pools/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,13 @@ variable "resource_group_name" {
type = string
default = null
}

variable "kubernetes_version" {
type = string
default = null
}

variable "orchestrator_version" {
type = string
default = null
}

0 comments on commit ca11785

Please sign in to comment.