Skip to content

Commit

Permalink
Merge pull request #393 from itamaro/glbc-healthcheck-with-host-header
Browse files Browse the repository at this point in the history
Implement support for GCE health check with HTTP Host Header in GLBC
  • Loading branch information
nicksardo committed Jun 20, 2017
2 parents 9ec862b + 488dd07 commit 103d082
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
10 changes: 9 additions & 1 deletion controllers/gce/backends/backends.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,9 +458,17 @@ func applyProbeSettingsToHC(p *api_v1.Probe, hc *healthchecks.HealthCheck) {
if !strings.HasPrefix(healthPath, "/") {
healthPath = "/" + healthPath
}
// Extract host from HTTP headers
host := p.Handler.HTTPGet.Host
for _, header := range p.Handler.HTTPGet.HTTPHeaders {
if header.Name == "Host" {
host = header.Value
break
}
}

hc.RequestPath = healthPath
hc.Host = p.Handler.HTTPGet.Host
hc.Host = host
hc.Description = "Kubernetes L7 health check generated with readiness probe settings."
hc.CheckIntervalSec = int64(p.PeriodSeconds) + int64(healthchecks.DefaultHealthCheckInterval.Seconds())
hc.TimeoutSec = int64(p.TimeoutSeconds)
Expand Down
5 changes: 3 additions & 2 deletions controllers/gce/controller/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,10 +592,11 @@ func (t *GCETranslator) getHTTPProbe(svc api_v1.Service, targetPort intstr.IntOr

// isSimpleHTTPProbe returns true if the given Probe is:
// - an HTTPGet probe, as opposed to a tcp or exec probe
// - has no special host or headers fields
// - has no special host or headers fields, except for possibly an HTTP Host header
func isSimpleHTTPProbe(probe *api_v1.Probe) bool {
return (probe != nil && probe.Handler.HTTPGet != nil && probe.Handler.HTTPGet.Host == "" &&
len(probe.Handler.HTTPGet.HTTPHeaders) == 0)
(len(probe.Handler.HTTPGet.HTTPHeaders) == 0 ||
(len(probe.Handler.HTTPGet.HTTPHeaders) == 1 && probe.Handler.HTTPGet.HTTPHeaders[0].Name == "Host")))
}

// GetProbe returns a probe that's used for the given nodeport
Expand Down

0 comments on commit 103d082

Please sign in to comment.