I'm in the process of creating fargate profiles for my AWS EKS cluster using terraform. In this example for the Terraform Karpenter module, they have a loop that creates one profile for each of the 3 availability zones used in the example:
fargate_profiles = {
for i in range(3) :
"karpenter-${element(split("-", local.azs[i]), 2)}" => {
selectors = [
{ namespace = "karpenter" }
]
# We want to create a profile per AZ for high availability
subnet_ids = [element(module.vpc.private_subnets, i)]
}
}
Why is this necessary? What's the difference between this and creating a single profile that is attached to 3 zones? Something like this:
fargate_profiles = {
"karpenter" = {
selectors = [
{ namespace = "karpenter" }
]
subnet_ids = var.vpc_private_subnets
}
}
One profile one AZ allows you to deploy pod in specific AZ. See here: