Support domain configuration for sticky cookies

This commit is contained in:
Jorge 2025-03-06 09:38:04 +01:00 committed by GitHub
parent fa76ed57d3
commit 740b4cfd25
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 184 additions and 0 deletions

View file

@ -260,6 +260,7 @@ func (c configBuilder) buildServicesLB(ctx context.Context, namespace string, tS
HTTPOnly: tService.Weighted.Sticky.Cookie.HTTPOnly,
SameSite: tService.Weighted.Sticky.Cookie.SameSite,
MaxAge: tService.Weighted.Sticky.Cookie.MaxAge,
Domain: tService.Weighted.Sticky.Cookie.Domain,
},
}
sticky.Cookie.SetDefaults()
@ -382,6 +383,7 @@ func (c configBuilder) buildServersLB(namespace string, svc traefikv1alpha1.Load
HTTPOnly: svc.Sticky.Cookie.HTTPOnly,
SameSite: svc.Sticky.Cookie.SameSite,
MaxAge: svc.Sticky.Cookie.MaxAge,
Domain: svc.Sticky.Cookie.Domain,
},
}
lb.Sticky.Cookie.SetDefaults()

View file

@ -121,6 +121,7 @@ func Test_parseServiceConfig(t *testing.T) {
"traefik.ingress.kubernetes.io/service.sticky.cookie.name": "foobar",
"traefik.ingress.kubernetes.io/service.sticky.cookie.secure": "true",
"traefik.ingress.kubernetes.io/service.sticky.cookie.samesite": "none",
"traefik.ingress.kubernetes.io/service.sticky.cookie.domain": "foo.com",
"traefik.ingress.kubernetes.io/service.sticky.cookie.path": "foobar",
},
expected: &ServiceConfig{
@ -131,6 +132,7 @@ func Test_parseServiceConfig(t *testing.T) {
Secure: true,
HTTPOnly: true,
SameSite: "none",
Domain: "foo.com",
Path: pointer("foobar"),
},
},