Skip to content

Commit

Permalink
Attempt to return empty 200s for Kube probes
Browse files Browse the repository at this point in the history
  • Loading branch information
tombh committed Jul 21, 2018
1 parent 582dddf commit 023836b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions interfacer/src/browsh/raw_text_server.go
Expand Up @@ -107,6 +107,11 @@ func handleHTTPServerRequest(w http.ResponseWriter, r *http.Request) {
return
}
}
Log(r.Header.Get("User-Agent"))
if isKubeReadinessProbe(r.Header.Get("User-Agent")) {
io.WriteString(w, "healthy")
return
}
if strings.TrimSpace(urlForBrowsh) == "" {
if strings.Contains(r.Host, "text.") {
message = "Welcome to the Browsh plain text client.\n" +
Expand Down Expand Up @@ -163,6 +168,14 @@ func isDisallowedUserAgent(userAgent string) bool {
return false
}

func isKubeReadinessProbe(userAgent string) bool {
r, _ := regexp.Compile("kube-probe")
if r.MatchString(userAgent) {
return true
}
return false
}

func isProductionHTTP(r *http.Request) bool {
if strings.Contains(r.Host, "brow.sh") {
return r.Header.Get("X-Forwarded-Proto") == "http"
Expand Down

0 comments on commit 023836b

Please sign in to comment.