|
1 |
| -# Subnet auto-discovery |
2 |
| -By default, the AWS Load Balancer Controller (LBC) auto-discovers network subnets that it can create AWS Network Load Balancers (NLB) and AWS Application Load Balancers (ALB) in. ALBs require at least two subnets across Availability Zones by default, |
3 |
| -set [Feature Gate ALBSingleSubnet](https://kubernetes-sigs.github.io/aws-load-balancer-controller/latest/deploy/configurations/#feature-gates) to "true" allows using only 1 subnet for provisioning ALB. NLBs require one subnet. |
4 |
| -The subnets must be tagged appropriately for auto-discovery to work. The controller chooses one subnet from each Availability Zone. During auto-discovery, the controller |
5 |
| -considers subnets with at least eight available IP addresses. In the case of multiple qualified tagged subnets in an Availability Zone, the controller chooses the first one in lexicographical |
6 |
| -order by the subnet IDs. |
7 |
| -For more information about the subnets for the LBC, see [Application Load Balancers](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/application-load-balancers.html) |
8 |
| -and [Network Load Balancers](https://docs.aws.amazon.com/elasticloadbalancing/latest/network/network-load-balancers.html). |
9 |
| -If you used `eksctl` or an Amazon EKS AWS CloudFormation template to create your VPC after March 26, 2020, then the subnets are tagged appropriately when they're created. For |
10 |
| -more information about the Amazon EKS AWS CloudFormation VPC templates, see [Creating a VPC for your Amazon EKS cluster](https://docs.aws.amazon.com/eks/latest/userguide/create-public-private-vpc.html). |
| 1 | +# Subnet Auto-Discovery |
| 2 | +The AWS Load Balancer Controller (LBC) automatically discovers subnets for creating AWS Network Load Balancers (NLB) and AWS Application Load Balancers (ALB). This auto-discovery process follows three main steps: |
11 | 3 |
|
12 |
| -## Public subnets |
13 |
| -Public subnets are used for internet-facing load balancers. These subnets must have the following tags: |
| 4 | +1. **Candidate Subnet Determination**: The controller identifies potential candidate subnets |
| 5 | +2. **Subnet Filtering**: The controller filters these candidates based on eligibility criteria |
| 6 | +3. **Final Selection**: The controller selects one subnet per availability zone |
14 | 7 |
|
15 |
| -| Key | Value | |
16 |
| -| --------------------------------------- | --------------------- | |
17 |
| -| `kubernetes.io/role/elb` | `1` or `` | |
| 8 | +## Candidate Subnet Determination |
| 9 | +The controller determines candidate subnets using the following process: |
18 | 10 |
|
19 |
| -## Private subnets |
20 |
| -Private subnets are used for internal load balancers. These subnets must have the following tags: |
| 11 | +1. **If tag filters are specified**: Only subnets matching these filters become candidates |
| 12 | + |
| 13 | + !!!tip |
| 14 | + You can only specify subnet tag filters for Ingress via IngressClassParams |
21 | 15 |
|
22 |
| -| Key | Value | |
23 |
| -| --------------------------------------- | --------------------- | |
24 |
| -| `kubernetes.io/role/internal-elb` | `1` or `` | |
| 16 | +2. **If no tag filters are specified**: |
| 17 | + * If subnets with matching [role tag](#subnet-role-tag) exists: Only these become candidates |
| 18 | + * [**For LBC version >= 2.12.1**] If no subnets have role tags: Candidates are subnets whose [reachability](#subnet-reachability) (public/private) matches the LoadBalancer's schema |
25 | 19 |
|
26 | 20 |
|
27 |
| -## Common tag |
28 |
| -In version v2.1.1 and older of the LBC, both the public and private subnets must be tagged with the cluster name as follows: |
| 21 | +### Subnet Role Tag |
| 22 | +Subnets can be tagged appropriately for auto-discovery selection: |
29 | 23 |
|
30 |
| -| Key | Value | |
31 |
| -| --------------------------------------- | --------------------- | |
32 |
| -| `kubernetes.io/cluster/${cluster-name}` | `owned` or `shared` | |
| 24 | +* **For internet-facing load balancers**, the controller looks for public subnets with following tags: |
33 | 25 |
|
34 |
| - `${cluster-name}` is the name of the Kubernetes cluster. |
35 |
| - |
36 |
| -The cluster tag is not required in versions v2.1.2 to v2.4.1, unless a cluster tag for another cluster is present. |
| 26 | + | Key | Value | |
| 27 | + | --------------------------------------- | --------------------- | |
| 28 | + | `kubernetes.io/role/elb` | `1` or `` | |
37 | 29 |
|
38 |
| -With versions v2.4.2 and later, you can disable the cluster tag check completely by specifying the feature gate `SubnetsClusterTagCheck=false` |
| 30 | +* **For internal load balancers**, the controller looks for private subnets with following tags: |
| 31 | + |
| 32 | + | Key | Value | |
| 33 | + | --------------------------------------- | --------------------- | |
| 34 | + | `kubernetes.io/role/internal-elb` | `1` or `` | |
| 35 | + |
| 36 | +### Subnet reachability |
| 37 | +The controller automatically discovers all subnets in your VPC and determines whether each is a public or private subnet based on its associated route table configuration. |
| 38 | +A subnet is classified as public if its route table contains a route to an Internet Gateway. |
| 39 | + |
| 40 | +!!!tip |
| 41 | + You can disable this behavior via SubnetDiscoveryByReachability feature flag. |
| 42 | + |
| 43 | +## Subnet Filtering |
| 44 | + |
| 45 | +1. **Cluster Tag Check**: The controller checks for cluster tags on subnets. Subnets with ineligible cluster tags will be filtered out. |
| 46 | + |
| 47 | + | Key | Value | |
| 48 | + | --------------------------------------- | --------------------- | |
| 49 | + | `kubernetes.io/cluster/${cluster-name}` | `owned` or `shared` | |
| 50 | + |
| 51 | + * If such cluster tag exists but no `<clusterName>` matches the current cluster, those subnets will be filtered out. |
| 52 | + * [**For LBC version < 2.1.1**] subnets without a cluster tag matching cluster name will be filtered out. |
| 53 | + |
| 54 | + !!! tip |
| 55 | + You can disable this behavior via the `SubnetsClusterTagCheck` feature flag. When disabled, no cluster tag check will be performed against subnets. |
| 56 | + |
| 57 | +2. **IP Address Availability**: Subnets with insufficient available IP addresses(**<8**) are filtered out. |
| 58 | + |
| 59 | +## Final Selection |
| 60 | + |
| 61 | +The controller selects one subnet per availability zone. When multiple subnets exist per Availability Zone, the following priority order applies: |
| 62 | + |
| 63 | +1. Subnets with cluster tag for the current cluster (`kubernetes.io/cluster/<clusterName>`) are prioritized |
| 64 | +2. Subnets with lower lexicographical order of subnet ID are prioritized |
| 65 | + |
| 66 | +## Minimum Subnet Requirements |
| 67 | + |
| 68 | +* **ALBs**: Require at least two subnets across different Availability Zones by default |
| 69 | + |
| 70 | + !!! tip |
| 71 | + For customers allowlisted by the AWS Elastic Load Balancing team, you can enable the [ALBSingleSubnet feature gate](https://kubernetes-sigs.github.io/aws-load-balancer-controller/latest/deploy/configurations/#feature-gates). This allows provisioning an ALB with just one subnet instead of the standard requirement of two subnets. |
0 commit comments