Skip to content

Commit

Permalink
add support for AWS ELB healthcheck probe
Browse files Browse the repository at this point in the history
Signed-off-by: Manuel Boillod <[email protected]>
  • Loading branch information
Manuel Boillod committed Dec 3, 2024
1 parent 993b7bf commit 6b46cfc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
3 changes: 2 additions & 1 deletion interceptor/middleware/routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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))
}
14 changes: 13 additions & 1 deletion interceptor/middleware/routing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down

0 comments on commit 6b46cfc

Please sign in to comment.