Skip to content

Commit 16ed0cf

Browse files
committed
Allow the kubernetes.io/cluster tag to be either shared or owned
1 parent b657400 commit 16ed0cf

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

docs/setup.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ The controller determines subnets to deploy each ALB to based on an annotation o
2424
##### Via tags on the subnets
2525
When subnet annotations are not present, the controller will attempt to choose the best subnets for deploying the ALBs. It uses the following tag criteria to determine the subnets it should use.
2626

27-
* `kubernetes.io/cluster/$CLUSTER_NAME: = "shared"` `$CLUSTER_NAME` must match the `CLUSTER_NAME` environment variable on the controller.
27+
- `kubernetes.io/cluster/$CLUSTER_NAME` equal to `shared` or `owned`. `$CLUSTER_NAME` must match the `CLUSTER_NAME` environment variable on the controller.
2828

2929
And one of the following:
3030

31-
* `kubernetes.io/role/internal-elb: ""` For internal load balancers
32-
* `kubernetes.io/role/elb = ""` For internet-facing load balancers
31+
- `kubernetes.io/role/internal-elb: ""` For internal load balancers
32+
- `kubernetes.io/role/elb = ""` For internet-facing load balancers
3333

3434
### Security Group Selection
3535

pkg/aws/albec2/ec2.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ const (
3030
ManagedByKey = "ManagedBy"
3131
ManagedByValue = "alb-ingress"
3232

33-
tagNameCluster = "kubernetes.io/cluster"
34-
tagValueCluster = "shared"
33+
tagNameCluster = "kubernetes.io/cluster"
3534

3635
tagNameSubnetInternalELB = "kubernetes.io/role/internal-elb"
3736
tagNameSubnetPublicELB = "kubernetes.io/role/elb"
@@ -775,11 +774,11 @@ func ClusterSubnets(scheme *string, clusterName string, resources *albrgt.Resour
775774

776775
if len(useableSubnets) < 2 {
777776
return nil, fmt.Errorf("Retrieval of subnets failed to resolve 2 qualified subnets. Subnets must "+
778-
"contain the %s/%s tag with a value of %s and the %s tag signifying it should be used for ALBs "+
777+
"contain the %s/%s tag with a value of shared or owned and the %s tag signifying it should be used for ALBs "+
779778
"Additionally, there must be at least 2 subnets with unique availability zones as required by "+
780779
"ALBs. Either tag subnets to meet this requirement or use the subnets annotation on the "+
781780
"ingress resource to explicitly call out what subnets to use for ALB creation. The subnets "+
782-
"that did resolve were %v.", tagNameCluster, clusterName, tagValueCluster, tagNameSubnetInternalELB,
781+
"that did resolve were %v.", tagNameCluster, clusterName, tagNameSubnetInternalELB,
783782
log.Prettify(useableSubnets))
784783
}
785784

pkg/aws/albrgt/rgt.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ func (r *RGT) GetResources(clusterName *string) (*Resources, error) {
5959
Key: aws.String("kubernetes.io/role/internal-elb"),
6060
Values: []*string{aws.String("")},
6161
},
62+
&resourcegroupstaggingapi.TagFilter{
63+
Key: aws.String("kubernetes.io/cluster/" + *clusterName),
64+
Values: []*string{aws.String("owned"), aws.String("shared")},
65+
},
6266
},
6367
},
6468
&resourcegroupstaggingapi.GetResourcesInput{
@@ -70,6 +74,10 @@ func (r *RGT) GetResources(clusterName *string) (*Resources, error) {
7074
Key: aws.String("kubernetes.io/role/elb"),
7175
Values: []*string{aws.String("")},
7276
},
77+
&resourcegroupstaggingapi.TagFilter{
78+
Key: aws.String("kubernetes.io/cluster/" + *clusterName),
79+
Values: []*string{aws.String("owned"), aws.String("shared")},
80+
},
7381
},
7482
},
7583
&resourcegroupstaggingapi.GetResourcesInput{
@@ -79,7 +87,7 @@ func (r *RGT) GetResources(clusterName *string) (*Resources, error) {
7987
TagFilters: []*resourcegroupstaggingapi.TagFilter{
8088
&resourcegroupstaggingapi.TagFilter{
8189
Key: aws.String("kubernetes.io/cluster/" + *clusterName),
82-
Values: []*string{aws.String("owned")},
90+
Values: []*string{aws.String("owned"), aws.String("shared")},
8391
},
8492
},
8593
},

0 commit comments

Comments
 (0)