discovery/kubernetes/ingress: fix scheme discovery (Closes
@@ -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),
