mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-21 03:16:00 -08:00
discovery/kubernetes/ingress: fix scheme discovery (Closes #4327)
Signed-off-by: Dmitry Bashkatov <dbashkatov@gmail.com>
This commit is contained in:
parent
9cdca50bdd
commit
e2baf89eac
|
@ -176,13 +176,24 @@ func (s *Ingress) buildIngress(ingress *v1beta1.Ingress) *targetgroup.Group {
|
||||||
}
|
}
|
||||||
tg.Labels = ingressLabels(ingress)
|
tg.Labels = ingressLabels(ingress)
|
||||||
|
|
||||||
schema := "http"
|
tlsHosts := make(map[string]struct{})
|
||||||
if ingress.Spec.TLS != nil {
|
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 {
|
for _, rule := range ingress.Spec.Rules {
|
||||||
paths := pathsFromIngressRule(&rule.IngressRuleValue)
|
paths := pathsFromIngressRule(&rule.IngressRuleValue)
|
||||||
|
|
||||||
|
schema := "http"
|
||||||
|
_, isTLS := tlsHosts[rule.Host]
|
||||||
|
if isTLS {
|
||||||
|
schema = "https"
|
||||||
|
}
|
||||||
|
|
||||||
for _, path := range paths {
|
for _, path := range paths {
|
||||||
tg.Targets = append(tg.Targets, model.LabelSet{
|
tg.Targets = append(tg.Targets, model.LabelSet{
|
||||||
model.AddressLabel: lv(rule.Host),
|
model.AddressLabel: lv(rule.Host),
|
||||||
|
|
Loading…
Reference in a new issue