0

How can I access a AWS EBS Volume from multiple availability zones?

My case in detail:

I have a VPC across multiple availability zones:

data "aws_availability_zones" "available" {}

module "vpc" {
    source = "terraform-aws-modules/vpc/aws"
    version = "3.10.0"

    name = "${local.project_slug}-main-vpc"
    cidr = "10.0.0.0/16"
    azs = data.aws_availability_zones.available.name
...

In this cluster I have a managed node group with a max_capacity of n:

module "eks" {
    source  = "terraform-aws-modules/eks/aws"
    version = "17.22.0"

    cluster_name = "${local.project_slug}-main-eks"
    cluster_version = "1.19" # K8s version

    vpc_id = module.vpc.vpc_id
    subnets = module.vpc.public_subnets

    # managed nodes
    node_groups = {
      grey = {
        desired_capacity = 1
        min_capacity     = 1
        max_capacity     = 10
        instance_types = ["t3.medium"]
      }
    }
...

But I can only assign a AWS EBY Volume to a single availability zone:

 resource "aws_ebs_volume" "api" {
     availability_zone = "eu-central-1b"
     size = 5 #GiBs
 }

If my the EKS' managed node group provisions a new node in another availability zone the volume can not be mounted.

How would I do this? What's a better practice here?

florianmaxim
  • 355
  • 1
  • 4
  • 13

1 Answers1

5

How can I access a AWS EBS Volume from multiple availability zones?

The short answer is you can't, EBS volumes are tied to an Availability Zone (think a disk in a data-center, that disk cannot be in multiple data-centers at once).

How would I do this? What's a better practice here?

It depends what "this" is. If it's to have some shared data available then you could use something like EFS or S3.

If it's for a stateful set, you could have multiple node groups, each scoped to a single AZ?

Fermin
  • 34,961
  • 21
  • 83
  • 129