Search code examples
kubernetesamazon-ekseksctl

How to specify availability zone with AWS EKS Fargate cluster with eckctl?


I'm learning Kubernetes, and am trying to create an AWS EKS Fargate cluster with the following config simple file

kind: ClusterConfig
apiVersion: eksctl.io/v1alpha5

metadata:
  name: sandbox
  region: us-east-1
  version: "1.18"

fargateProfiles:
  - name: fp-default
    selectors:
      # All workloads in the "default" Kubernetes namespace will be
      # scheduled onto Fargate:
      - namespace: default
      # All workloads in the "kube-system" Kubernetes namespace will be
      # scheduled onto Fargate:
      - namespace: kube-system
  - name: fp-sandbox
    selectors:
      # All workloads in the "sandbox" Kubernetes namespace matching the
      # following label selectors will be scheduled onto Fargate:
      - namespace: sandbox
        labels:
          env: sandbox
          checks: passed
  - name: fp-fluxcd
    selectors:
      # All workloads in the "fluxcd" Kubernetes namespace matching the
      # following label selectors will be scheduled onto Fargate:
      - namespace: fluxcd

I get the following error. How can I specify the availability zone in above config file?

[✖]  AWS::EKS::Cluster/ControlPlane: CREATE_FAILED – "Cannot create cluster 'sandbox' because us-east-1a, the targeted availability zone, does not currently have sufficient capacity to support the cluster. Retry and choose from these availability zones: us-east-1b, us-east-1c, us-east-1d, us-east-1e, us-east-1f (Service: AmazonEKS; Status Code: 400; Error Code: UnsupportedAvailabilityZoneException; Request ID: 7c5c4544-4fe5-4ed5-96a8-099d60e1e5ab; Proxy: null)"

Solution

  • See the eksctl config file schema.

    kind: ClusterConfig
    apiVersion: eksctl.io/v1alpha5
    
    metadata:
      name: sandbox
      region: us-east-1
      version: "1.18"
    
    fargateProfiles:
      - name: fp-default
        selectors:
          # All workloads in the "default" Kubernetes namespace will be
          # scheduled onto Fargate:
          - namespace: default
          # All workloads in the "kube-system" Kubernetes namespace will be
          # scheduled onto Fargate:
          - namespace: kube-system
      - name: fp-sandbox
        selectors:
          # All workloads in the "sandbox" Kubernetes namespace matching the
          # following label selectors will be scheduled onto Fargate:
          - namespace: sandbox
            labels:
              env: sandbox
              checks: passed
      - name: fp-fluxcd
        selectors:
          # All workloads in the "fluxcd" Kubernetes namespace matching the
          # following label selectors will be scheduled onto Fargate:
          - namespace: fluxcd
    
    availabilityZones: ['us-east-1b']