AWS Builder Center
AWS EKS version upgrade from 1.31 to 1.32 using Terraform

AWS EKS version upgrade from 1.31 to 1.32 using Terraform

I am sharing our latest experience on upgrading AWS EKS Cluster from version 1.31 to 1.32 using Terraform with Amazon Linux 2 (AL2).

Series: AWS EKS Version Upgrade (8 articles)

  1. …
  2. 6
    AWS EKS version upgrade from 1.31 to 1.32 using Terraform This article
We will go through the changes required in Terraform script to upgrade an AWS EKS cluster from 1.31 to 1.32 retaining Amazon Linux 2 (AL2). In addition, we will walk through the changes for Karpenter and AWS Blueprint. We have used Karpenter for Node Scaling. We are effectively managing karpenter using AWS EKS Blueprint addon.
PRE-Validate the EKS current version
aws eks describe-cluster - name sample - query cluster.version - output text
PRE-Validate EKS nodes
kubectl get nodes
Identify compatible AWS AMI for EKS version
aws ssm get-parameter - name /aws/service/eks/optimized-ami/<AWS EKS Version>/<your os>/recommended/image_id - region <AWS Region> - query "Parameter.Value" - output text.
sample:
aws ssm get-parameter - name /aws/service/eks/optimized-ami/1.32/amazon-linux-2/recommended/image_id - region eu-west-1 - query "Parameter.Value" - output text.
Following variables in Terraform scripts were updated:
  • Version in resource "aws_eks_cluster"
resource "aws_eks_cluster" "example" {
name = "sample"
version = "1.32"
}
  • Update image_id in aws_launch_template resource (update the AMI we identified above as image_id)
# taken from https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/launch_template
resource "aws_launch_template" "foo" {
name = "foo"
block_device_mappings {
device_name = "/dev/sdf"
ebs {
volume_size = 20
}
}
capacity_reservation_specification {
capacity_reservation_preference = "open"
}
cpu_options {
core_count = 4
threads_per_core = 2
}
credit_specification {
cpu_credits = "standard"
}
disable_api_stop = true
disable_api_termination = true
ebs_optimized = true
iam_instance_profile {
name = "test"
}
image_id = "ami-test"
instance_initiated_shutdown_behavior = "terminate"
instance_market_options {
market_type = "spot"
}
instance_type = "t2.micro"
kernel_id = "test"
key_name = "test"
license_specification {
license_configuration_arn = "arn:aws:license-manager:eu-west-1:123456789012:license-configuration:lic-0123456789abcdef0123456789abcdef"
}
metadata_options {
http_endpoint = "enabled"
http_tokens = "required"
http_put_response_hop_limit = 1
instance_metadata_tags = "enabled"
}
monitoring {
enabled = true
}
network_interfaces {
associate_public_ip_address = true
}
placement {
availability_zone = "us-west-2a"
}
ram_disk_id = "test"
vpc_security_group_ids = ["sg-12345678"]
tag_specifications {
resource_type = "instance"
tags = {
Name = "test"
}
}
user_data = filebase64("${path.module}/example.sh")
}
  • Update addon_version for each aws_eks_addon resource we want to update like vpc_cni , kube_proxy, coredns , etc.
resource "aws_eks_addon" "example" {
cluster_name = aws_eks_cluster.example.name
addon_name = "coredns"
addon_version = "v1.11.4-eksbuild.14"
resolve_conflicts_on_update = "PRESERVE"
}
  • All the other add-ons were updated to below versions.
coredns_version = "v1.11.4-eksbuild.14"
vpc_cni_version = "v1.19.6-eksbuild.1"
kube_proxy_version = "v1.32.6-eksbuild.12"
ebs_csi_version = "v1.45.0-eksbuild.2"
efs_csi_version = "v2.0.2-eksbuild.1"
s3_csi_version = "v1.14.1-eksbuild.1"
The above updates ensured master node of AWS EKS is updated, all worker nodes of AWS EKS are updated and Addons are updated to expected versions.
AWS Blueprint was retained with below version 1.21.0, and no changes were made for this upgrade. It retained the Karpenter in version 0.37.0. Karpenter was not upgraded and planned to be upgraded during next upgrade to 1.33 version.
module "eks-blueprints-addons" {
source = "aws-ia/eks-blueprints-addons/aws"
version = "1.21.0"
# insert the 4 required variables here
}
Once the update is completed, verify the versions of Kubernetes and its nodes using the AWS CLI mentioned above in pre-validation.

Series: AWS EKS Version Upgrade (8 articles)

  1. …
  2. 6
    AWS EKS version upgrade from 1.31 to 1.32 using Terraform This article
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article