Implement support for GCE health check with HTTP Host Header in GLBC
This commit is contained in:
parent
ca5f402322
commit
488dd077b0
2 changed files with 12 additions and 3 deletions
|
@ -458,9 +458,17 @@ func applyProbeSettingsToHC(p *api_v1.Probe, hc *healthchecks.HealthCheck) {
|
||||||
if !strings.HasPrefix(healthPath, "/") {
|
if !strings.HasPrefix(healthPath, "/") {
|
||||||
healthPath = "/" + 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.RequestPath = healthPath
|
||||||
hc.Host = p.Handler.HTTPGet.Host
|
hc.Host = host
|
||||||
hc.Description = "Kubernetes L7 health check generated with readiness probe settings."
|
hc.Description = "Kubernetes L7 health check generated with readiness probe settings."
|
||||||
hc.CheckIntervalSec = int64(p.PeriodSeconds) + int64(healthchecks.DefaultHealthCheckInterval.Seconds())
|
hc.CheckIntervalSec = int64(p.PeriodSeconds) + int64(healthchecks.DefaultHealthCheckInterval.Seconds())
|
||||||
hc.TimeoutSec = int64(p.TimeoutSeconds)
|
hc.TimeoutSec = int64(p.TimeoutSeconds)
|
||||||
|
|
|
@ -592,10 +592,11 @@ func (t *GCETranslator) getHTTPProbe(svc api_v1.Service, targetPort intstr.IntOr
|
||||||
|
|
||||||
// isSimpleHTTPProbe returns true if the given Probe is:
|
// isSimpleHTTPProbe returns true if the given Probe is:
|
||||||
// - an HTTPGet probe, as opposed to a tcp or exec probe
|
// - 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 {
|
func isSimpleHTTPProbe(probe *api_v1.Probe) bool {
|
||||||
return (probe != nil && probe.Handler.HTTPGet != nil && probe.Handler.HTTPGet.Host == "" &&
|
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
|
// GetProbe returns a probe that's used for the given nodeport
|
||||||
|
|
Loading…
Reference in a new issue