|
|
@ -19,6 +19,7 @@ import (
|
|
|
|
"github.com/prometheus/common/model"
|
|
|
|
"github.com/prometheus/common/model"
|
|
|
|
"github.com/prometheus/prometheus/config"
|
|
|
|
"github.com/prometheus/prometheus/config"
|
|
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
|
|
|
|
|
|
"k8s.io/apimachinery/pkg/types"
|
|
|
|
"k8s.io/client-go/pkg/api/v1"
|
|
|
|
"k8s.io/client-go/pkg/api/v1"
|
|
|
|
"k8s.io/client-go/tools/cache"
|
|
|
|
"k8s.io/client-go/tools/cache"
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -43,6 +44,7 @@ func makeMultiPortPod() *v1.Pod {
|
|
|
|
Namespace: "default",
|
|
|
|
Namespace: "default",
|
|
|
|
Labels: map[string]string{"testlabel": "testvalue"},
|
|
|
|
Labels: map[string]string{"testlabel": "testvalue"},
|
|
|
|
Annotations: map[string]string{"testannotation": "testannotationvalue"},
|
|
|
|
Annotations: map[string]string{"testannotation": "testannotationvalue"},
|
|
|
|
|
|
|
|
UID: types.UID("abc123"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Spec: v1.PodSpec{
|
|
|
|
Spec: v1.PodSpec{
|
|
|
|
NodeName: "testnode",
|
|
|
|
NodeName: "testnode",
|
|
|
@ -85,6 +87,7 @@ func makePod() *v1.Pod {
|
|
|
|
ObjectMeta: metav1.ObjectMeta{
|
|
|
|
ObjectMeta: metav1.ObjectMeta{
|
|
|
|
Name: "testpod",
|
|
|
|
Name: "testpod",
|
|
|
|
Namespace: "default",
|
|
|
|
Namespace: "default",
|
|
|
|
|
|
|
|
UID: types.UID("abc123"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Spec: v1.PodSpec{
|
|
|
|
Spec: v1.PodSpec{
|
|
|
|
NodeName: "testnode",
|
|
|
|
NodeName: "testnode",
|
|
|
@ -151,6 +154,7 @@ func TestPodDiscoveryInitial(t *testing.T) {
|
|
|
|
"__meta_kubernetes_pod_ip": "1.2.3.4",
|
|
|
|
"__meta_kubernetes_pod_ip": "1.2.3.4",
|
|
|
|
"__meta_kubernetes_pod_host_ip": "2.3.4.5",
|
|
|
|
"__meta_kubernetes_pod_host_ip": "2.3.4.5",
|
|
|
|
"__meta_kubernetes_pod_ready": "true",
|
|
|
|
"__meta_kubernetes_pod_ready": "true",
|
|
|
|
|
|
|
|
"__meta_kubernetes_pod_uid": "abc123",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Source: "pod/default/testpod",
|
|
|
|
Source: "pod/default/testpod",
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -182,6 +186,7 @@ func TestPodDiscoveryAdd(t *testing.T) {
|
|
|
|
"__meta_kubernetes_pod_ip": "1.2.3.4",
|
|
|
|
"__meta_kubernetes_pod_ip": "1.2.3.4",
|
|
|
|
"__meta_kubernetes_pod_host_ip": "2.3.4.5",
|
|
|
|
"__meta_kubernetes_pod_host_ip": "2.3.4.5",
|
|
|
|
"__meta_kubernetes_pod_ready": "true",
|
|
|
|
"__meta_kubernetes_pod_ready": "true",
|
|
|
|
|
|
|
|
"__meta_kubernetes_pod_uid": "abc123",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Source: "pod/default/testpod",
|
|
|
|
Source: "pod/default/testpod",
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -214,6 +219,7 @@ func TestPodDiscoveryDelete(t *testing.T) {
|
|
|
|
"__meta_kubernetes_pod_ip": "1.2.3.4",
|
|
|
|
"__meta_kubernetes_pod_ip": "1.2.3.4",
|
|
|
|
"__meta_kubernetes_pod_host_ip": "2.3.4.5",
|
|
|
|
"__meta_kubernetes_pod_host_ip": "2.3.4.5",
|
|
|
|
"__meta_kubernetes_pod_ready": "true",
|
|
|
|
"__meta_kubernetes_pod_ready": "true",
|
|
|
|
|
|
|
|
"__meta_kubernetes_pod_uid": "abc123",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Source: "pod/default/testpod",
|
|
|
|
Source: "pod/default/testpod",
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -251,6 +257,7 @@ func TestPodDiscoveryDeleteUnknownCacheState(t *testing.T) {
|
|
|
|
"__meta_kubernetes_pod_ip": "1.2.3.4",
|
|
|
|
"__meta_kubernetes_pod_ip": "1.2.3.4",
|
|
|
|
"__meta_kubernetes_pod_host_ip": "2.3.4.5",
|
|
|
|
"__meta_kubernetes_pod_host_ip": "2.3.4.5",
|
|
|
|
"__meta_kubernetes_pod_ready": "true",
|
|
|
|
"__meta_kubernetes_pod_ready": "true",
|
|
|
|
|
|
|
|
"__meta_kubernetes_pod_uid": "abc123",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Source: "pod/default/testpod",
|
|
|
|
Source: "pod/default/testpod",
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -312,6 +319,7 @@ func TestPodDiscoveryUpdate(t *testing.T) {
|
|
|
|
"__meta_kubernetes_pod_ip": "1.2.3.4",
|
|
|
|
"__meta_kubernetes_pod_ip": "1.2.3.4",
|
|
|
|
"__meta_kubernetes_pod_host_ip": "2.3.4.5",
|
|
|
|
"__meta_kubernetes_pod_host_ip": "2.3.4.5",
|
|
|
|
"__meta_kubernetes_pod_ready": "unknown",
|
|
|
|
"__meta_kubernetes_pod_ready": "unknown",
|
|
|
|
|
|
|
|
"__meta_kubernetes_pod_uid": "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Source: "pod/default/testpod",
|
|
|
|
Source: "pod/default/testpod",
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -334,6 +342,7 @@ func TestPodDiscoveryUpdate(t *testing.T) {
|
|
|
|
"__meta_kubernetes_pod_ip": "1.2.3.4",
|
|
|
|
"__meta_kubernetes_pod_ip": "1.2.3.4",
|
|
|
|
"__meta_kubernetes_pod_host_ip": "2.3.4.5",
|
|
|
|
"__meta_kubernetes_pod_host_ip": "2.3.4.5",
|
|
|
|
"__meta_kubernetes_pod_ready": "true",
|
|
|
|
"__meta_kubernetes_pod_ready": "true",
|
|
|
|
|
|
|
|
"__meta_kubernetes_pod_uid": "abc123",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Source: "pod/default/testpod",
|
|
|
|
Source: "pod/default/testpod",
|
|
|
|
},
|
|
|
|
},
|
|
|
|