File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
internal/controller/provisioner Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -463,9 +463,12 @@ func buildNginxService(
463
463
Ports : servicePorts ,
464
464
ExternalTrafficPolicy : servicePolicy ,
465
465
Selector : selectorLabels ,
466
+ IPFamilyPolicy : helpers .GetPointer (corev1 .IPFamilyPolicyPreferDualStack ),
466
467
},
467
468
}
468
469
470
+ setIPFamily (nProxyCfg , svc )
471
+
469
472
if serviceCfg .LoadBalancerIP != nil {
470
473
svc .Spec .LoadBalancerIP = * serviceCfg .LoadBalancerIP
471
474
}
@@ -479,6 +482,12 @@ func buildNginxService(
479
482
return svc
480
483
}
481
484
485
+ func setIPFamily (nProxyCfg * graph.EffectiveNginxProxy , svc * corev1.Service ) {
486
+ if nProxyCfg != nil && nProxyCfg .IPFamily != nil && * nProxyCfg .IPFamily != ngfAPIv1alpha2 .Dual {
487
+ svc .Spec .IPFamilyPolicy = helpers .GetPointer (corev1 .IPFamilyPolicySingleStack )
488
+ }
489
+ }
490
+
482
491
func (p * NginxProvisioner ) buildNginxDeployment (
483
492
objectMeta metav1.ObjectMeta ,
484
493
nProxyCfg * graph.EffectiveNginxProxy ,
Original file line number Diff line number Diff line change @@ -161,6 +161,7 @@ func TestBuildNginxResourceObjects(t *testing.T) {
161
161
validateMeta (svc )
162
162
g .Expect (svc .Spec .Type ).To (Equal (defaultServiceType ))
163
163
g .Expect (svc .Spec .ExternalTrafficPolicy ).To (Equal (defaultServicePolicy ))
164
+ g .Expect (* svc .Spec .IPFamilyPolicy ).To (Equal (corev1 .IPFamilyPolicyPreferDualStack ))
164
165
165
166
// service ports is sorted in ascending order by port number when we make the nginx object
166
167
g .Expect (svc .Spec .Ports ).To (Equal ([]corev1.ServicePort {
@@ -260,6 +261,7 @@ func TestBuildNginxResourceObjects_NginxProxyConfig(t *testing.T) {
260
261
261
262
resourceName := "gw-nginx"
262
263
nProxyCfg := & graph.EffectiveNginxProxy {
264
+ IPFamily : helpers .GetPointer (ngfAPIv1alpha2 .IPv4 ),
263
265
Logging : & ngfAPIv1alpha2.NginxLogging {
264
266
ErrorLevel : helpers .GetPointer (ngfAPIv1alpha2 .NginxLogLevelDebug ),
265
267
AgentLevel : helpers .GetPointer (ngfAPIv1alpha2 .AgentLogLevelDebug ),
@@ -321,6 +323,7 @@ func TestBuildNginxResourceObjects_NginxProxyConfig(t *testing.T) {
321
323
g .Expect (svc .Spec .LoadBalancerIP ).To (Equal ("1.2.3.4" ))
322
324
g .Expect (* svc .Spec .LoadBalancerClass ).To (Equal ("myLoadBalancerClass" ))
323
325
g .Expect (svc .Spec .LoadBalancerSourceRanges ).To (Equal ([]string {"5.6.7.8" }))
326
+ g .Expect (* svc .Spec .IPFamilyPolicy ).To (Equal (corev1 .IPFamilyPolicySingleStack ))
324
327
325
328
depObj := objects [5 ]
326
329
dep , ok := depObj .(* appsv1.Deployment )
You can’t perform that action at this time.
0 commit comments