diff --git a/discovery/kubernetes/endpoints_test.go b/discovery/kubernetes/endpoints_test.go index 04c0d01ffc..bd7f072fdf 100644 --- a/discovery/kubernetes/endpoints_test.go +++ b/discovery/kubernetes/endpoints_test.go @@ -357,7 +357,7 @@ func TestEndpointsDiscoveryWithService(t *testing.T) { Name: "testendpoints", Namespace: "default", Labels: map[string]string{ - "app": "test", + "app/name": "test", }, }, } @@ -387,11 +387,11 @@ func TestEndpointsDiscoveryWithService(t *testing.T) { }, }, Labels: model.LabelSet{ - "__meta_kubernetes_namespace": "default", - "__meta_kubernetes_endpoints_name": "testendpoints", - "__meta_kubernetes_service_label_app": "test", - "__meta_kubernetes_service_labelpresent_app": "true", - "__meta_kubernetes_service_name": "testendpoints", + "__meta_kubernetes_namespace": "default", + "__meta_kubernetes_endpoints_name": "testendpoints", + "__meta_kubernetes_service_label_app_name": "test", + "__meta_kubernetes_service_labelpresent_app_name": "true", + "__meta_kubernetes_service_name": "testendpoints", }, Source: "endpoints/default/testendpoints", }, @@ -410,7 +410,7 @@ func TestEndpointsDiscoveryWithServiceUpdate(t *testing.T) { Name: "testendpoints", Namespace: "default", Labels: map[string]string{ - "app": "test", + "app/name": "test", }, }, } @@ -422,7 +422,7 @@ func TestEndpointsDiscoveryWithServiceUpdate(t *testing.T) { Name: "testendpoints", Namespace: "default", Labels: map[string]string{ - "app": "svc", + "app/name": "svc", "component": "testing", }, }, @@ -455,8 +455,8 @@ func TestEndpointsDiscoveryWithServiceUpdate(t *testing.T) { Labels: model.LabelSet{ "__meta_kubernetes_namespace": "default", "__meta_kubernetes_endpoints_name": "testendpoints", - "__meta_kubernetes_service_label_app": "svc", - "__meta_kubernetes_service_labelpresent_app": "true", + "__meta_kubernetes_service_label_app_name": "svc", + "__meta_kubernetes_service_labelpresent_app_name": "true", "__meta_kubernetes_service_name": "testendpoints", "__meta_kubernetes_service_label_component": "testing", "__meta_kubernetes_service_labelpresent_component": "true", diff --git a/discovery/kubernetes/ingress_test.go b/discovery/kubernetes/ingress_test.go index d7973e8b13..ffe3bffc33 100644 --- a/discovery/kubernetes/ingress_test.go +++ b/discovery/kubernetes/ingress_test.go @@ -36,8 +36,8 @@ func makeIngress(tls TLSMode) *v1beta1.Ingress { ObjectMeta: metav1.ObjectMeta{ Name: "testingress", Namespace: "default", - Labels: map[string]string{"testlabel": "testvalue"}, - Annotations: map[string]string{"testannotation": "testannotationvalue"}, + Labels: map[string]string{"test/label": "testvalue"}, + Annotations: map[string]string{"test/annotation": "testannotationvalue"}, }, Spec: v1beta1.IngressSpec{ TLS: nil, @@ -118,12 +118,12 @@ func expectedTargetGroups(ns string, tls TLSMode) map[string]*targetgroup.Group }, }, Labels: model.LabelSet{ - "__meta_kubernetes_ingress_name": "testingress", - "__meta_kubernetes_namespace": lv(ns), - "__meta_kubernetes_ingress_label_testlabel": "testvalue", - "__meta_kubernetes_ingress_labelpresent_testlabel": "true", - "__meta_kubernetes_ingress_annotation_testannotation": "testannotationvalue", - "__meta_kubernetes_ingress_annotationpresent_testannotation": "true", + "__meta_kubernetes_ingress_name": "testingress", + "__meta_kubernetes_namespace": lv(ns), + "__meta_kubernetes_ingress_label_test_label": "testvalue", + "__meta_kubernetes_ingress_labelpresent_test_label": "true", + "__meta_kubernetes_ingress_annotation_test_annotation": "testannotationvalue", + "__meta_kubernetes_ingress_annotationpresent_test_annotation": "true", }, Source: key, }, diff --git a/discovery/kubernetes/node_test.go b/discovery/kubernetes/node_test.go index 2eaf49bf34..da92eefced 100644 --- a/discovery/kubernetes/node_test.go +++ b/discovery/kubernetes/node_test.go @@ -59,8 +59,8 @@ func TestNodeDiscoveryBeforeStart(t *testing.T) { obj := makeNode( "test", "1.2.3.4", - map[string]string{"testlabel": "testvalue"}, - map[string]string{"testannotation": "testannotationvalue"}, + map[string]string{"test-label": "testvalue"}, + map[string]string{"test-annotation": "testannotationvalue"}, ) c.CoreV1().Nodes().Create(obj) }, @@ -75,11 +75,11 @@ func TestNodeDiscoveryBeforeStart(t *testing.T) { }, }, Labels: model.LabelSet{ - "__meta_kubernetes_node_name": "test", - "__meta_kubernetes_node_label_testlabel": "testvalue", - "__meta_kubernetes_node_labelpresent_testlabel": "true", - "__meta_kubernetes_node_annotation_testannotation": "testannotationvalue", - "__meta_kubernetes_node_annotationpresent_testannotation": "true", + "__meta_kubernetes_node_name": "test", + "__meta_kubernetes_node_label_test_label": "testvalue", + "__meta_kubernetes_node_labelpresent_test_label": "true", + "__meta_kubernetes_node_annotation_test_annotation": "testannotationvalue", + "__meta_kubernetes_node_annotationpresent_test_annotation": "true", }, Source: "node/test", }, diff --git a/discovery/kubernetes/pod.go b/discovery/kubernetes/pod.go index baa5313314..5ee8e959d6 100644 --- a/discovery/kubernetes/pod.go +++ b/discovery/kubernetes/pod.go @@ -188,7 +188,7 @@ func podLabels(pod *apiv1.Pod) model.LabelSet { for k, v := range pod.Labels { ln := strutil.SanitizeLabelName(k) - ls[model.LabelName(podLabelPrefix+k)] = lv(v) + ls[model.LabelName(podLabelPrefix+ln)] = lv(v) ls[model.LabelName(podLabelPresentPrefix+ln)] = presentValue } diff --git a/discovery/kubernetes/pod_test.go b/discovery/kubernetes/pod_test.go index 0548716a35..fecdbffd90 100644 --- a/discovery/kubernetes/pod_test.go +++ b/discovery/kubernetes/pod_test.go @@ -33,8 +33,8 @@ func makeMultiPortPods() *v1.Pod { ObjectMeta: metav1.ObjectMeta{ Name: "testpod", Namespace: "default", - Labels: map[string]string{"testlabel": "testvalue"}, - Annotations: map[string]string{"testannotation": "testannotationvalue"}, + Labels: map[string]string{"test/label": "testvalue"}, + Annotations: map[string]string{"test/annotation": "testannotationvalue"}, UID: types.UID("abc123"), OwnerReferences: []metav1.OwnerReference{ { @@ -178,20 +178,20 @@ func TestPodDiscoveryBeforeRun(t *testing.T) { }, }, Labels: model.LabelSet{ - "__meta_kubernetes_pod_name": "testpod", - "__meta_kubernetes_namespace": "default", - "__meta_kubernetes_pod_label_testlabel": "testvalue", - "__meta_kubernetes_pod_labelpresent_testlabel": "true", - "__meta_kubernetes_pod_annotation_testannotation": "testannotationvalue", - "__meta_kubernetes_pod_annotationpresent_testannotation": "true", - "__meta_kubernetes_pod_node_name": "testnode", - "__meta_kubernetes_pod_ip": "1.2.3.4", - "__meta_kubernetes_pod_host_ip": "2.3.4.5", - "__meta_kubernetes_pod_ready": "true", - "__meta_kubernetes_pod_phase": "Running", - "__meta_kubernetes_pod_uid": "abc123", - "__meta_kubernetes_pod_controller_kind": "testcontrollerkind", - "__meta_kubernetes_pod_controller_name": "testcontrollername", + "__meta_kubernetes_pod_name": "testpod", + "__meta_kubernetes_namespace": "default", + "__meta_kubernetes_pod_label_test_label": "testvalue", + "__meta_kubernetes_pod_labelpresent_test_label": "true", + "__meta_kubernetes_pod_annotation_test_annotation": "testannotationvalue", + "__meta_kubernetes_pod_annotationpresent_test_annotation": "true", + "__meta_kubernetes_pod_node_name": "testnode", + "__meta_kubernetes_pod_ip": "1.2.3.4", + "__meta_kubernetes_pod_host_ip": "2.3.4.5", + "__meta_kubernetes_pod_ready": "true", + "__meta_kubernetes_pod_phase": "Running", + "__meta_kubernetes_pod_uid": "abc123", + "__meta_kubernetes_pod_controller_kind": "testcontrollerkind", + "__meta_kubernetes_pod_controller_name": "testcontrollername", }, Source: "pod/default/testpod", }, diff --git a/discovery/kubernetes/service_test.go b/discovery/kubernetes/service_test.go index 585bbd49a2..783b5d06bf 100644 --- a/discovery/kubernetes/service_test.go +++ b/discovery/kubernetes/service_test.go @@ -28,8 +28,8 @@ func makeMultiPortService() *v1.Service { ObjectMeta: metav1.ObjectMeta{ Name: "testservice", Namespace: "default", - Labels: map[string]string{"testlabel": "testvalue"}, - Annotations: map[string]string{"testannotation": "testannotationvalue"}, + Labels: map[string]string{"test-label": "testvalue"}, + Annotations: map[string]string{"test-annotation": "testannotationvalue"}, }, Spec: v1.ServiceSpec{ Ports: []v1.ServicePort{ @@ -186,12 +186,12 @@ func TestServiceDiscoveryUpdate(t *testing.T) { }, }, Labels: model.LabelSet{ - "__meta_kubernetes_service_name": "testservice", - "__meta_kubernetes_namespace": "default", - "__meta_kubernetes_service_label_testlabel": "testvalue", - "__meta_kubernetes_service_labelpresent_testlabel": "true", - "__meta_kubernetes_service_annotation_testannotation": "testannotationvalue", - "__meta_kubernetes_service_annotationpresent_testannotation": "true", + "__meta_kubernetes_service_name": "testservice", + "__meta_kubernetes_namespace": "default", + "__meta_kubernetes_service_label_test_label": "testvalue", + "__meta_kubernetes_service_labelpresent_test_label": "true", + "__meta_kubernetes_service_annotation_test_annotation": "testannotationvalue", + "__meta_kubernetes_service_annotationpresent_test_annotation": "true", }, Source: "svc/default/testservice", },