add support for AWS ELB healthcheck probe (#1199)

Signed-off-by: Manuel Boillod <manuel.boillod@ratp.fr>
Co-authored-by: Manuel Boillod <manuel.boillod@ratp.fr>
This commit is contained in:
Manuel Boillod 2024-12-03 19:50:43 +01:00 committed by GitHub
parent 993b7bf242
commit ade3bb090b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 2 deletions

View File

@ -27,6 +27,8 @@ This changelog keeps track of work items that have been completed and are ready
- **General**: Support setting multiple TLS certs for different domains on the interceptor proxy ([#1116](https://github.com/kedacore/http-add-on/issues/1116))
- **General**: TODO ([#TODO](https://github.com/kedacore/http-add-on/issues/TODO))
- **Interceptor**: Add support for for AWS ELB healthcheck probe ([#1198](https://github.com/kedacore/http-add-on/issues/1198))
### Improvements
- **General**: TODO ([#TODO](https://github.com/kedacore/http-add-on/issues/TODO))

View File

@ -17,6 +17,7 @@ import (
var (
kubernetesProbeUserAgent = regexp.MustCompile(`(^|\s)kube-probe/`)
googleHCUserAgent = regexp.MustCompile(`(^|\s)GoogleHC/`)
awsELBserAgent = regexp.MustCompile(`(^|\s)ELB-HealthChecker/`)
)
type Routing struct {
@ -112,5 +113,5 @@ func (rm *Routing) streamFromHTTPSO(ctx context.Context, httpso *httpv1alpha1.HT
func (rm *Routing) isProbe(r *http.Request) bool {
ua := r.UserAgent()
return kubernetesProbeUserAgent.Match([]byte(ua)) || googleHCUserAgent.Match([]byte(ua))
return kubernetesProbeUserAgent.Match([]byte(ua)) || googleHCUserAgent.Match([]byte(ua)) || awsELBserAgent.Match([]byte(ua))
}

View File

@ -304,7 +304,19 @@ var _ = Describe("RoutingMiddleware", func() {
Expect(b).To(BeTrue())
})
It("returns false if the request is not from kube-probe or GoogleHC", func() {
It("returns true if the request is from AWS ELB", func() {
const (
uaVal = "Go-http-client/1.1 ELB-HealthChecker/2.0 (linux/amd64) kubernetes/4c94112"
)
r.Header.Set(uaKey, uaVal)
var rm Routing
b := rm.isProbe(r)
Expect(b).To(BeTrue())
})
It("returns false if the request is not from kube-probe or GoogleHC or ELB-HealthChecker", func() {
const (
uaVal = "Go-http-client/1.1 kubectl/v1.27.1 (linux/amd64) kubernetes/4c94112"
)