-
Notifications
You must be signed in to change notification settings - Fork 88
Enable Support for creating Dual Stack NLB #766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ type Adapter struct { | |
ingressDefaultSecurityGroup string | ||
ingressDefaultSSLPolicy string | ||
ingressDefaultLoadBalancerType string | ||
ingressIpAddressType string | ||
clusterLocalDomain string | ||
routeGroupSupport bool | ||
} | ||
|
@@ -123,7 +124,7 @@ func (c *ConfigMap) String() string { | |
} | ||
|
||
// NewAdapter creates an Adapter for Kubernetes using a given configuration. | ||
func NewAdapter(config *Config, ingressAPIVersion string, ingressClassFilters []string, ingressDefaultSecurityGroup, ingressDefaultSSLPolicy, ingressDefaultLoadBalancerType, clusterLocalDomain string, disableInstrumentedHttpClient bool) (*Adapter, error) { | ||
func NewAdapter(config *Config, ingressAPIVersion string, ingressClassFilters []string, ingressDefaultSecurityGroup, ingressDefaultSSLPolicy, ingressDefaultLoadBalancerType, clusterLocalDomain, ingressIpAddressType string, disableInstrumentedHttpClient bool) (*Adapter, error) { | ||
if config == nil || config.BaseURL == "" { | ||
return nil, ErrInvalidConfiguration | ||
} | ||
|
@@ -139,6 +140,7 @@ func NewAdapter(config *Config, ingressAPIVersion string, ingressClassFilters [] | |
ingressDefaultSecurityGroup: ingressDefaultSecurityGroup, | ||
ingressDefaultSSLPolicy: ingressDefaultSSLPolicy, | ||
ingressDefaultLoadBalancerType: loadBalancerTypesAWSToIngress[ingressDefaultLoadBalancerType], | ||
ingressIpAddressType: ingressIpAddressType, | ||
clusterLocalDomain: clusterLocalDomain, | ||
routeGroupSupport: true, | ||
}, nil | ||
|
@@ -200,9 +202,23 @@ func (a *Adapter) newIngress(typ IngressType, metadata kubeItemMetadata, host st | |
shared = false | ||
} | ||
|
||
ipAddressType := aws.IPAddressTypeIPV4 | ||
if getAnnotationsString(annotations, ingressALBIPAddressType, "") == aws.IPAddressTypeDualstack { | ||
ipAddressType := a.ingressIpAddressType | ||
albIPType := getAnnotationsString(annotations, ingressALBIPAddressType, "") | ||
ipType := getAnnotationsString(annotations, ingressIPAddressType, "") | ||
if albIPType != "" { | ||
log.Warnf("Deprecated annotation %q in use for %q resource named %q in namespace %q", ingressALBIPAddressType, typ, metadata.Name, metadata.Namespace) | ||
|
||
if ipType != "" { | ||
log.Warnf("Both annotations are set for %q resource named %q in namespace %q, deprecated annotation %q=%q will be ignored, using %q=%q", | ||
typ, metadata.Name, metadata.Namespace, ingressALBIPAddressType, albIPType, ingressIPAddressType, ipType) | ||
} | ||
} | ||
Comment on lines
+206
to
+215
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure we should bother deprecating or just support both like ipType := getAnnotationsString(annotations, ingressIPAddressType,
getAnnotationsString(annotations, ingressALBIPAddressType, "")) anyways after extracting the values I think we should end up with a single variable ipType to have a simple switch over it below. |
||
// Prefer ingressIPAddressType if set, otherwise fallback to deprecated ingressALBIPAddressType | ||
switch { | ||
AlexanderYastrebov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
case ipType == aws.IPAddressTypeDualstack || albIPType == aws.IPAddressTypeDualstack: | ||
ipAddressType = aws.IPAddressTypeDualstack | ||
case ipType == aws.IPAddressTypeIPV4 || albIPType == aws.IPAddressTypeIPV4: | ||
ipAddressType = aws.IPAddressTypeIPV4 | ||
} | ||
|
||
sslPolicy := getAnnotationsString(annotations, ingressSSLPolicyAnnotation, a.ingressDefaultSSLPolicy) | ||
|
@@ -243,11 +259,6 @@ func (a *Adapter) newIngress(typ IngressType, metadata kubeItemMetadata, host st | |
// convert to the internal naming e.g. nlb -> network | ||
loadBalancerType = loadBalancerTypesIngressToAWS[loadBalancerType] | ||
|
||
if loadBalancerType == aws.LoadBalancerTypeNetwork { | ||
// ensure ipv4 for network load balancers | ||
ipAddressType = aws.IPAddressTypeIPV4 | ||
} | ||
|
||
http2 := true | ||
if getAnnotationsString(annotations, ingressHTTP2Annotation, "") == "false" { | ||
http2 = false | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: networking.k8s.io/v1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. all the test data is copied from existing data and then updated to use dualstack |
||
kind: Ingress | ||
metadata: | ||
name: myingress | ||
spec: | ||
rules: | ||
- host: foo.bar.org | ||
http: | ||
paths: | ||
- backend: | ||
service: | ||
name: foo-bar-service | ||
port: | ||
name: main-port | ||
path: / | ||
pathType: ImplementationSpecific |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
[ | ||
{ | ||
"parameterKey": "LoadBalancerSchemeParameter", | ||
"parameterValue": "internet-facing" | ||
}, | ||
{ | ||
"parameterKey": "LoadBalancerSecurityGroupParameter", | ||
"parameterValue": "42" | ||
}, | ||
{ | ||
"parameterKey": "LoadBalancerSubnetsParameter", | ||
"parameterValue": "foo1" | ||
}, | ||
{ | ||
"parameterKey": "TargetGroupVPCIDParameter", | ||
"parameterValue": "1" | ||
}, | ||
{ | ||
"parameterKey": "TargetGroupTargetPortParameter", | ||
"parameterValue": "0" | ||
}, | ||
{ | ||
"parameterKey": "ListenerSslPolicyParameter", | ||
"parameterValue": "ELBSecurityPolicy-2016-08" | ||
}, | ||
{ | ||
"parameterKey": "IpAddressType", | ||
"parameterValue": "dualstack" | ||
}, | ||
{ | ||
"parameterKey": "Type", | ||
"parameterValue": "application" | ||
}, | ||
{ | ||
"parameterKey": "HTTP2", | ||
"parameterValue": "true" | ||
}, | ||
{ | ||
"parameterKey": "TargetGroupHealthCheckPathParameter", | ||
"parameterValue": "" | ||
}, | ||
{ | ||
"parameterKey": "TargetGroupHealthCheckPortParameter", | ||
"parameterValue": "0" | ||
}, | ||
{ | ||
"parameterKey": "TargetGroupHealthCheckIntervalParameter", | ||
"parameterValue": "0" | ||
}, | ||
{ | ||
"parameterKey": "TargetGroupHealthCheckTimeoutParameter", | ||
"parameterValue": "0" | ||
} | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[ | ||
{ | ||
"key": "kubernetes:application", | ||
"value": "" | ||
},{ | ||
"key": "kubernetes.io/cluster/aws:123:eu-central-1:kube-1", | ||
"value": "owned" | ||
},{ | ||
"key": "ingress:certificate-arn/DUMMY", | ||
"value": "0001-01-01T00:00:00Z" | ||
} | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is strange - looks like
a.ingressIpAddressType
was never used before for anything (or broken at some point) although we have a flag for it. Could you please check history to understand that?With this change we'll use flag value as the default ip address type for all ingresses so if any deployment happened to have
-ip-addr-type=dualstack
this will update all loadbalancers iiuc.