discovery/kubernetes/ingress: fix scheme discovery (Closes #4327)

Signed-off-by: Dmitry Bashkatov <dbashkatov@gmail.com>
This commit is contained in:
Dmitry Bashkatov 2018-07-02 13:02:40 +03:00
parent 9cdca50bdd
commit e2baf89eac
1 changed files with 13 additions and 2 deletions

View File

@ -176,13 +176,24 @@ func (s *Ingress) buildIngress(ingress *v1beta1.Ingress) *targetgroup.Group {
}
tg.Labels = ingressLabels(ingress)
schema := "http"
tlsHosts := make(map[string]struct{})
if ingress.Spec.TLS != nil {
schema = "https"
for _, tls := range ingress.Spec.TLS {
for _, host := range tls.Hosts {
tlsHosts[host] = struct{}{}
}
}
}
for _, rule := range ingress.Spec.Rules {
paths := pathsFromIngressRule(&rule.IngressRuleValue)
schema := "http"
_, isTLS := tlsHosts[rule.Host]
if isTLS {
schema = "https"
}
for _, path := range paths {
tg.Targets = append(tg.Targets, model.LabelSet{
model.AddressLabel: lv(rule.Host),