Skip to content

Commit 6965e9d

Browse files
authored
Merge pull request #3863 from wweiwei-li/listenerAttributes
Support listener attributes
2 parents 6ef8e94 + 174ad83 commit 6965e9d

File tree

21 files changed

+782
-21
lines changed

21 files changed

+782
-21
lines changed

apis/elbv2/v1beta1/ingressclassparams_types.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,22 @@ type Attribute struct {
8585
Value string `json:"value"`
8686
}
8787

88+
type ListenerProtocol string
89+
90+
const (
91+
ListenerProtocolHTTP ListenerProtocol = "HTTP"
92+
ListenerProtocolHTTPS ListenerProtocol = "HTTPS"
93+
)
94+
95+
type Listener struct {
96+
// The protocol of the listener
97+
Protocol ListenerProtocol `json:"protocol,omitempty"`
98+
// The port of the listener
99+
Port int32 `json:"port,omitempty"`
100+
// The attributes of the listener
101+
ListenerAttributes []Attribute `json:"listenerAttributes,omitempty"`
102+
}
103+
88104
// IngressClassParamsSpec defines the desired state of IngressClassParams
89105
type IngressClassParamsSpec struct {
90106
// CertificateArn specifies the ARN of the certificates for all Ingresses that belong to IngressClass with this IngressClassParams.
@@ -126,6 +142,10 @@ type IngressClassParamsSpec struct {
126142
// LoadBalancerAttributes define the custom attributes to LoadBalancers for all Ingress that that belong to IngressClass with this IngressClassParams.
127143
// +optional
128144
LoadBalancerAttributes []Attribute `json:"loadBalancerAttributes,omitempty"`
145+
146+
// Listeners define a list of listeners with their protocol, port and attributes.
147+
// +optional
148+
Listeners []Listener `json:"listeners,omitempty"`
129149
}
130150

131151
// +kubebuilder:object:root=true

apis/elbv2/v1beta1/zz_generated.deepcopy.go

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/elbv2.k8s.aws_ingressclassparams.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,36 @@ spec:
8585
- dualstack
8686
- dualstack-without-public-ipv4
8787
type: string
88+
listeners:
89+
description: Listeners define a list of listeners with their protocol,
90+
port and attributes.
91+
items:
92+
properties:
93+
listenerAttributes:
94+
description: The attributes of the listener
95+
items:
96+
description: Attributes defines custom attributes on resources.
97+
properties:
98+
key:
99+
description: The key of the attribute.
100+
type: string
101+
value:
102+
description: The value of the attribute.
103+
type: string
104+
required:
105+
- key
106+
- value
107+
type: object
108+
type: array
109+
port:
110+
description: The port of the listener
111+
format: int32
112+
type: integer
113+
protocol:
114+
description: The protocol of the listener
115+
type: string
116+
type: object
117+
type: array
88118
loadBalancerAttributes:
89119
description: LoadBalancerAttributes define the custom attributes to
90120
LoadBalancers for all Ingress that that belong to IngressClass with

docs/guide/service/annotations.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
| [service.beta.kubernetes.io/aws-load-balancer-security-groups](#security-groups) | stringList | | |
5353
| [service.beta.kubernetes.io/aws-load-balancer-manage-backend-security-group-rules](#manage-backend-sg-rules) | boolean | true | If `service.beta.kubernetes.io/aws-load-balancer-security-groups` is specified, this must also be explicitly specified otherwise it defaults to `false`. |
5454
| [service.beta.kubernetes.io/aws-load-balancer-inbound-sg-rules-on-private-link-traffic](#update-security-settings) | string | |
55+
| [service.beta.kubernetes.io/aws-load-balancer-listener-attributes.${Protocol}-${Port}](#listener-attributes) | stringMap | |
5556

5657
## Traffic Routing
5758
Traffic Routing can be controlled with following annotations:
@@ -265,6 +266,19 @@ for proxy protocol v2 configuration.
265266
service.beta.kubernetes.io/aws-load-balancer-attributes: dns_record.client_routing_policy=availability_zone_affinity
266267
```
267268

269+
270+
- <a name="listener-attributes">`service.beta.kubernetes.io/aws-load-balancer-listener-attributes.${Protocol}-${Port}`</a> specifies listener attributes that should be applied to the listener.
271+
272+
!!!warning ""
273+
Only attributes defined in the annotation will be updated. To reset any AWS defaults, the values need to be explicitly set to the original values and omitting it is not sufficient.
274+
275+
!!!example
276+
- configure [TCP idle timeout](https://docs.aws.amazon.com/elasticloadbalancing/latest/network/update-idle-timeout.html) value.
277+
```
278+
service.beta.kubernetes.io/aws-load-balancer-listener-attributes.TCP-80: tcp.idle_timeout.seconds=400
279+
```
280+
281+
268282
- <a name="deprecated-attributes"></a>the following annotations are deprecated in v2.3.0 release in favor of [service.beta.kubernetes.io/aws-load-balancer-attributes](#load-balancer-attributes)
269283

270284
!!!note ""

docs/install/iam_policy.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
"elasticloadbalancing:DescribeTargetGroupAttributes",
4040
"elasticloadbalancing:DescribeTargetHealth",
4141
"elasticloadbalancing:DescribeTags",
42-
"elasticloadbalancing:DescribeTrustStores"
42+
"elasticloadbalancing:DescribeTrustStores",
43+
"elasticloadbalancing:DescribeListenerAttributes"
4344
],
4445
"Resource": "*"
4546
},
@@ -188,7 +189,8 @@
188189
"elasticloadbalancing:DeleteLoadBalancer",
189190
"elasticloadbalancing:ModifyTargetGroup",
190191
"elasticloadbalancing:ModifyTargetGroupAttributes",
191-
"elasticloadbalancing:DeleteTargetGroup"
192+
"elasticloadbalancing:DeleteTargetGroup",
193+
"elasticloadbalancing:ModifyListenerAttributes"
192194
],
193195
"Resource": "*",
194196
"Condition": {

docs/install/iam_policy_cn.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
"elasticloadbalancing:DescribeTargetGroupAttributes",
4040
"elasticloadbalancing:DescribeTargetHealth",
4141
"elasticloadbalancing:DescribeTags",
42-
"elasticloadbalancing:DescribeTrustStores"
42+
"elasticloadbalancing:DescribeTrustStores",
43+
"elasticloadbalancing:DescribeListenerAttributes"
4344
],
4445
"Resource": "*"
4546
},
@@ -210,7 +211,8 @@
210211
"elasticloadbalancing:DeleteLoadBalancer",
211212
"elasticloadbalancing:ModifyTargetGroup",
212213
"elasticloadbalancing:ModifyTargetGroupAttributes",
213-
"elasticloadbalancing:DeleteTargetGroup"
214+
"elasticloadbalancing:DeleteTargetGroup",
215+
"elasticloadbalancing:ModifyListenerAttributes"
214216
],
215217
"Resource": "*",
216218
"Condition": {

docs/install/iam_policy_us-gov.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
"elasticloadbalancing:DescribeTargetGroupAttributes",
4040
"elasticloadbalancing:DescribeTargetHealth",
4141
"elasticloadbalancing:DescribeTags",
42-
"elasticloadbalancing:DescribeTrustStores"
42+
"elasticloadbalancing:DescribeTrustStores",
43+
"elasticloadbalancing:DescribeListenerAttributes"
4344
],
4445
"Resource": "*"
4546
},
@@ -210,7 +211,8 @@
210211
"elasticloadbalancing:DeleteLoadBalancer",
211212
"elasticloadbalancing:ModifyTargetGroup",
212213
"elasticloadbalancing:ModifyTargetGroupAttributes",
213-
"elasticloadbalancing:DeleteTargetGroup"
214+
"elasticloadbalancing:DeleteTargetGroup",
215+
"elasticloadbalancing:ModifyListenerAttributes"
214216
],
215217
"Resource": "*",
216218
"Condition": {

helm/aws-load-balancer-controller/crds/crds.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,36 @@ spec:
8484
- dualstack
8585
- dualstack-without-public-ipv4
8686
type: string
87+
listeners:
88+
description: Listeners define a list of listeners with their protocol,
89+
port and attributes.
90+
items:
91+
properties:
92+
listenerAttributes:
93+
description: The attributes of the listener
94+
items:
95+
description: Attributes defines custom attributes on resources.
96+
properties:
97+
key:
98+
description: The key of the attribute.
99+
type: string
100+
value:
101+
description: The value of the attribute.
102+
type: string
103+
required:
104+
- key
105+
- value
106+
type: object
107+
type: array
108+
port:
109+
description: The port of the listener
110+
format: int32
111+
type: integer
112+
protocol:
113+
description: The protocol of the listener
114+
type: string
115+
type: object
116+
type: array
87117
loadBalancerAttributes:
88118
description: LoadBalancerAttributes define the custom attributes to
89119
LoadBalancers for all Ingress that that belong to IngressClass with

pkg/annotations/constants.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const (
4848
IngressSuffixManageSecurityGroupRules = "manage-backend-security-group-rules"
4949
IngressSuffixMutualAuthentication = "mutual-authentication"
5050
IngressSuffixSecurityGroupPrefixLists = "security-group-prefix-lists"
51+
IngressSuffixlsAttsAnnotationPrefix = "listener-attributes"
5152

5253
// NLB annotation suffixes
5354
// prefixes service.beta.kubernetes.io, service.kubernetes.io
@@ -88,4 +89,5 @@ const (
8889
SvcLBSuffixManageSGRules = "aws-load-balancer-manage-backend-security-group-rules"
8990
SvcLBSuffixEnforceSGInboundRulesOnPrivateLinkTraffic = "aws-load-balancer-inbound-sg-rules-on-private-link-traffic"
9091
SvcLBSuffixSecurityGroupPrefixLists = "aws-load-balancer-security-group-prefix-lists"
92+
SvcLBSuffixlsAttsAnnotationPrefix = "aws-load-balancer-listener-attributes"
9193
)

pkg/aws/services/elbv2.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ package services
22

33
import (
44
"context"
5+
"time"
6+
57
"github.com/aws/aws-sdk-go-v2/aws"
68
"github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2"
79
"github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2/types"
810
"sigs.k8s.io/aws-load-balancer-controller/pkg/aws/endpoints"
9-
"time"
1011
)
1112

1213
type ELBV2 interface {
@@ -57,6 +58,8 @@ type ELBV2 interface {
5758
DescribeTrustStoresWithContext(ctx context.Context, input *elasticloadbalancingv2.DescribeTrustStoresInput) (*elasticloadbalancingv2.DescribeTrustStoresOutput, error)
5859
RemoveListenerCertificatesWithContext(ctx context.Context, input *elasticloadbalancingv2.RemoveListenerCertificatesInput) (*elasticloadbalancingv2.RemoveListenerCertificatesOutput, error)
5960
AddListenerCertificatesWithContext(ctx context.Context, input *elasticloadbalancingv2.AddListenerCertificatesInput) (*elasticloadbalancingv2.AddListenerCertificatesOutput, error)
61+
DescribeListenerAttributesWithContext(ctx context.Context, input *elasticloadbalancingv2.DescribeListenerAttributesInput) (*elasticloadbalancingv2.DescribeListenerAttributesOutput, error)
62+
ModifyListenerAttributesWithContext(ctx context.Context, input *elasticloadbalancingv2.ModifyListenerAttributesInput) (*elasticloadbalancingv2.ModifyListenerAttributesOutput, error)
6063
}
6164

6265
func NewELBV2(cfg aws.Config, endpointsResolver *endpoints.Resolver) ELBV2 {
@@ -268,3 +271,11 @@ func (c *elbv2Client) DescribeRulesAsList(ctx context.Context, input *elasticloa
268271
}
269272
return result, nil
270273
}
274+
275+
func (c *elbv2Client) DescribeListenerAttributesWithContext(ctx context.Context, input *elasticloadbalancingv2.DescribeListenerAttributesInput) (*elasticloadbalancingv2.DescribeListenerAttributesOutput, error) {
276+
return c.elbv2Client.DescribeListenerAttributes(ctx, input)
277+
}
278+
279+
func (c *elbv2Client) ModifyListenerAttributesWithContext(ctx context.Context, input *elasticloadbalancingv2.ModifyListenerAttributesInput) (*elasticloadbalancingv2.ModifyListenerAttributesOutput, error) {
280+
return c.elbv2Client.ModifyListenerAttributes(ctx, input)
281+
}

0 commit comments

Comments
 (0)