mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-24 13:14:05 -08:00
Merge pull request #8916 from Evesy/main
Add class label to kubernetes ingress discovery
This commit is contained in:
commit
039b651450
|
@ -147,6 +147,7 @@ const (
|
|||
ingressSchemeLabel = metaLabelPrefix + "ingress_scheme"
|
||||
ingressHostLabel = metaLabelPrefix + "ingress_host"
|
||||
ingressPathLabel = metaLabelPrefix + "ingress_path"
|
||||
ingressClassNameLabel = metaLabelPrefix + "ingress_class_name"
|
||||
)
|
||||
|
||||
func ingressLabels(ingress *v1beta1.Ingress) model.LabelSet {
|
||||
|
@ -154,6 +155,9 @@ func ingressLabels(ingress *v1beta1.Ingress) model.LabelSet {
|
|||
ls := make(model.LabelSet, 2*(len(ingress.Labels)+len(ingress.Annotations))+2)
|
||||
ls[ingressNameLabel] = lv(ingress.Name)
|
||||
ls[namespaceLabel] = lv(ingress.Namespace)
|
||||
if ingress.Spec.IngressClassName != nil {
|
||||
ls[ingressClassNameLabel] = lv(*ingress.Spec.IngressClassName)
|
||||
}
|
||||
|
||||
for k, v := range ingress.Labels {
|
||||
ln := strutil.SanitizeLabelName(k)
|
||||
|
|
|
@ -42,7 +42,8 @@ func makeIngress(tls TLSMode) *v1beta1.Ingress {
|
|||
Annotations: map[string]string{"test/annotation": "testannotationvalue"},
|
||||
},
|
||||
Spec: v1beta1.IngressSpec{
|
||||
TLS: nil,
|
||||
IngressClassName: classString("testclass"),
|
||||
TLS: nil,
|
||||
Rules: []v1beta1.IngressRule{
|
||||
{
|
||||
Host: "example.com",
|
||||
|
@ -84,6 +85,10 @@ func makeIngress(tls TLSMode) *v1beta1.Ingress {
|
|||
return ret
|
||||
}
|
||||
|
||||
func classString(v string) *string {
|
||||
return &v
|
||||
}
|
||||
|
||||
func expectedTargetGroups(ns string, tls TLSMode) map[string]*targetgroup.Group {
|
||||
scheme1 := "http"
|
||||
scheme2 := "http"
|
||||
|
@ -126,6 +131,7 @@ func expectedTargetGroups(ns string, tls TLSMode) map[string]*targetgroup.Group
|
|||
"__meta_kubernetes_ingress_labelpresent_test_label": "true",
|
||||
"__meta_kubernetes_ingress_annotation_test_annotation": "testannotationvalue",
|
||||
"__meta_kubernetes_ingress_annotationpresent_test_annotation": "true",
|
||||
"__meta_kubernetes_ingress_class_name": "testclass",
|
||||
},
|
||||
Source: key,
|
||||
},
|
||||
|
|
|
@ -1457,6 +1457,7 @@ Available meta labels:
|
|||
* `__meta_kubernetes_ingress_labelpresent_<labelname>`: `true` for each label from the ingress object.
|
||||
* `__meta_kubernetes_ingress_annotation_<annotationname>`: Each annotation from the ingress object.
|
||||
* `__meta_kubernetes_ingress_annotationpresent_<annotationname>`: `true` for each annotation from the ingress object.
|
||||
* `__meta_kubernetes_ingress_class_name`: Class name from ingress spec, if present.
|
||||
* `__meta_kubernetes_ingress_scheme`: Protocol scheme of ingress, `https` if TLS
|
||||
config is set. Defaults to `http`.
|
||||
* `__meta_kubernetes_ingress_path`: Path from ingress spec. Defaults to `/`.
|
||||
|
|
Loading…
Reference in a new issue