Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
d7e0d9b4
Unverified
Commit
d7e0d9b4
authored
Jan 03, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Jan 03, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #61064 from johanneswuerbach/nlb-cross-zone
AWS NLB: Support cross-zone load balancing annotation
parents
60561cdd
5e6d8657
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
0 deletions
+58
-0
aws_loadbalancer.go
pkg/cloudprovider/providers/aws/aws_loadbalancer.go
+58
-0
No files found.
pkg/cloudprovider/providers/aws/aws_loadbalancer.go
View file @
d7e0d9b4
...
...
@@ -313,6 +313,64 @@ func (c *Cloud) ensureLoadBalancerv2(namespacedName types.NamespacedName, loadBa
}
}
desiredLoadBalancerAttributes
:=
map
[
string
]
string
{}
// Default values to ensured a remove annotation reverts back to the default
desiredLoadBalancerAttributes
[
"load_balancing.cross_zone.enabled"
]
=
"false"
// Determine if cross zone load balancing enabled/disabled has been specified
crossZoneLoadBalancingEnabledAnnotation
:=
annotations
[
ServiceAnnotationLoadBalancerCrossZoneLoadBalancingEnabled
]
if
crossZoneLoadBalancingEnabledAnnotation
!=
""
{
crossZoneEnabled
,
err
:=
strconv
.
ParseBool
(
crossZoneLoadBalancingEnabledAnnotation
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"error parsing service annotation: %s=%s"
,
ServiceAnnotationLoadBalancerCrossZoneLoadBalancingEnabled
,
crossZoneLoadBalancingEnabledAnnotation
,
)
}
if
crossZoneEnabled
{
desiredLoadBalancerAttributes
[
"load_balancing.cross_zone.enabled"
]
=
"true"
}
}
// Whether the ELB was new or existing, sync attributes regardless. This accounts for things
// that cannot be specified at the time of creation and can only be modified after the fact,
// e.g. idle connection timeout.
describeAttributesRequest
:=
&
elbv2
.
DescribeLoadBalancerAttributesInput
{
LoadBalancerArn
:
loadBalancer
.
LoadBalancerArn
,
}
describeAttributesOutput
,
err
:=
c
.
elbv2
.
DescribeLoadBalancerAttributes
(
describeAttributesRequest
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Unable to retrieve load balancer attributes during attribute sync: %q"
,
err
)
}
changedAttributes
:=
[]
*
elbv2
.
LoadBalancerAttribute
{}
// Identify to be changed attributes
for
_
,
foundAttribute
:=
range
describeAttributesOutput
.
Attributes
{
if
targetValue
,
ok
:=
desiredLoadBalancerAttributes
[
*
foundAttribute
.
Key
];
ok
{
if
targetValue
!=
*
foundAttribute
.
Value
{
changedAttributes
=
append
(
changedAttributes
,
&
elbv2
.
LoadBalancerAttribute
{
Key
:
foundAttribute
.
Key
,
Value
:
aws
.
String
(
targetValue
),
})
}
}
}
// Update attributes requiring changes
if
len
(
changedAttributes
)
>
0
{
klog
.
V
(
2
)
.
Infof
(
"Updating load-balancer attributes for %q"
,
loadBalancerName
)
_
,
err
=
c
.
elbv2
.
ModifyLoadBalancerAttributes
(
&
elbv2
.
ModifyLoadBalancerAttributesInput
{
LoadBalancerArn
:
loadBalancer
.
LoadBalancerArn
,
Attributes
:
changedAttributes
,
})
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Unable to update load balancer attributes during attribute sync: %q"
,
err
)
}
}
// Subnets cannot be modified on NLBs
if
dirty
{
loadBalancers
,
err
:=
c
.
elbv2
.
DescribeLoadBalancers
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment