Skip to content

Commit

Permalink
feat: Set LB service session affinity to "clientIP"
Browse files Browse the repository at this point in the history
Enabling sticky sessions for the LB service may improve the robustness
of TURN connection routing during scale-out/in.
  • Loading branch information
rg0now committed Jul 31, 2024
1 parent 450f86e commit f3b1e46
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 4 additions & 3 deletions internal/renderer/service_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,10 @@ func (r *Renderer) createLbService4Gateway(c *RenderContext, gw *gwapiv1.Gateway
Annotations: requestedAnnotations,
},
Spec: corev1.ServiceSpec{
Type: opdefault.DefaultServiceType,
Selector: map[string]string{},
Ports: []corev1.ServicePort{},
Type: opdefault.DefaultServiceType,
Selector: map[string]string{},
Ports: []corev1.ServicePort{},
SessionAffinity: corev1.ServiceAffinityClientIP,
},
}
} else {
Expand Down
2 changes: 2 additions & 0 deletions internal/renderer/service_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,8 @@ func TestRenderServiceUtil(t *testing.T) {
assert.Equal(t, corev1.ServiceTypeLoadBalancer, spec.Type, "lb type")
assert.Equal(t, defaultExternalTrafficPolicy, spec.ExternalTrafficPolicy,
"ext traffic policy default")
assert.Equal(t, corev1.ServiceAffinityClientIP, spec.SessionAffinity,
"session faffinity")

sp := spec.Ports
assert.Len(t, sp, 1, "service-port len")
Expand Down

0 comments on commit f3b1e46

Please sign in to comment.