|
|
|
@ -50,7 +50,8 @@ func makeMultiPortPods() *v1.Pod {
|
|
|
|
|
NodeName: "testnode",
|
|
|
|
|
Containers: []v1.Container{
|
|
|
|
|
{
|
|
|
|
|
Name: "testcontainer0",
|
|
|
|
|
Name: "testcontainer0",
|
|
|
|
|
Image: "testcontainer0:latest",
|
|
|
|
|
Ports: []v1.ContainerPort{
|
|
|
|
|
{
|
|
|
|
|
Name: "testport0",
|
|
|
|
@ -65,7 +66,8 @@ func makeMultiPortPods() *v1.Pod {
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Name: "testcontainer1",
|
|
|
|
|
Name: "testcontainer1",
|
|
|
|
|
Image: "testcontainer1:latest",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
@ -94,7 +96,8 @@ func makePods() *v1.Pod {
|
|
|
|
|
NodeName: "testnode",
|
|
|
|
|
Containers: []v1.Container{
|
|
|
|
|
{
|
|
|
|
|
Name: "testcontainer",
|
|
|
|
|
Name: "testcontainer",
|
|
|
|
|
Image: "testcontainer:latest",
|
|
|
|
|
Ports: []v1.ContainerPort{
|
|
|
|
|
{
|
|
|
|
|
Name: "testport",
|
|
|
|
@ -130,7 +133,8 @@ func makeInitContainerPods() *v1.Pod {
|
|
|
|
|
NodeName: "testnode",
|
|
|
|
|
Containers: []v1.Container{
|
|
|
|
|
{
|
|
|
|
|
Name: "testcontainer",
|
|
|
|
|
Name: "testcontainer",
|
|
|
|
|
Image: "testcontainer:latest",
|
|
|
|
|
Ports: []v1.ContainerPort{
|
|
|
|
|
{
|
|
|
|
|
Name: "testport",
|
|
|
|
@ -143,7 +147,8 @@ func makeInitContainerPods() *v1.Pod {
|
|
|
|
|
|
|
|
|
|
InitContainers: []v1.Container{
|
|
|
|
|
{
|
|
|
|
|
Name: "initcontainer",
|
|
|
|
|
Name: "initcontainer",
|
|
|
|
|
Image: "initcontainer:latest",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
@ -169,6 +174,7 @@ func expectedPodTargetGroups(ns string) map[string]*targetgroup.Group {
|
|
|
|
|
{
|
|
|
|
|
"__address__": "1.2.3.4:9000",
|
|
|
|
|
"__meta_kubernetes_pod_container_name": "testcontainer",
|
|
|
|
|
"__meta_kubernetes_pod_container_image": "testcontainer:latest",
|
|
|
|
|
"__meta_kubernetes_pod_container_port_name": "testport",
|
|
|
|
|
"__meta_kubernetes_pod_container_port_number": "9000",
|
|
|
|
|
"__meta_kubernetes_pod_container_port_protocol": "TCP",
|
|
|
|
@ -219,6 +225,7 @@ func TestPodDiscoveryBeforeRun(t *testing.T) {
|
|
|
|
|
{
|
|
|
|
|
"__address__": "1.2.3.4:9000",
|
|
|
|
|
"__meta_kubernetes_pod_container_name": "testcontainer0",
|
|
|
|
|
"__meta_kubernetes_pod_container_image": "testcontainer0:latest",
|
|
|
|
|
"__meta_kubernetes_pod_container_port_name": "testport0",
|
|
|
|
|
"__meta_kubernetes_pod_container_port_number": "9000",
|
|
|
|
|
"__meta_kubernetes_pod_container_port_protocol": "TCP",
|
|
|
|
@ -227,15 +234,17 @@ func TestPodDiscoveryBeforeRun(t *testing.T) {
|
|
|
|
|
{
|
|
|
|
|
"__address__": "1.2.3.4:9001",
|
|
|
|
|
"__meta_kubernetes_pod_container_name": "testcontainer0",
|
|
|
|
|
"__meta_kubernetes_pod_container_image": "testcontainer0:latest",
|
|
|
|
|
"__meta_kubernetes_pod_container_port_name": "testport1",
|
|
|
|
|
"__meta_kubernetes_pod_container_port_number": "9001",
|
|
|
|
|
"__meta_kubernetes_pod_container_port_protocol": "UDP",
|
|
|
|
|
"__meta_kubernetes_pod_container_init": "false",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"__address__": "1.2.3.4",
|
|
|
|
|
"__meta_kubernetes_pod_container_name": "testcontainer1",
|
|
|
|
|
"__meta_kubernetes_pod_container_init": "false",
|
|
|
|
|
"__address__": "1.2.3.4",
|
|
|
|
|
"__meta_kubernetes_pod_container_name": "testcontainer1",
|
|
|
|
|
"__meta_kubernetes_pod_container_image": "testcontainer1:latest",
|
|
|
|
|
"__meta_kubernetes_pod_container_init": "false",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
Labels: model.LabelSet{
|
|
|
|
@ -267,9 +276,10 @@ func TestPodDiscoveryInitContainer(t *testing.T) {
|
|
|
|
|
key := fmt.Sprintf("pod/%s/testpod", ns)
|
|
|
|
|
expected := expectedPodTargetGroups(ns)
|
|
|
|
|
expected[key].Targets = append(expected[key].Targets, model.LabelSet{
|
|
|
|
|
"__address__": "1.2.3.4",
|
|
|
|
|
"__meta_kubernetes_pod_container_name": "initcontainer",
|
|
|
|
|
"__meta_kubernetes_pod_container_init": "true",
|
|
|
|
|
"__address__": "1.2.3.4",
|
|
|
|
|
"__meta_kubernetes_pod_container_name": "initcontainer",
|
|
|
|
|
"__meta_kubernetes_pod_container_image": "initcontainer:latest",
|
|
|
|
|
"__meta_kubernetes_pod_container_init": "true",
|
|
|
|
|
})
|
|
|
|
|
expected[key].Labels["__meta_kubernetes_pod_phase"] = "Pending"
|
|
|
|
|
expected[key].Labels["__meta_kubernetes_pod_ready"] = "false"
|
|
|
|
@ -329,7 +339,8 @@ func TestPodDiscoveryUpdate(t *testing.T) {
|
|
|
|
|
NodeName: "testnode",
|
|
|
|
|
Containers: []v1.Container{
|
|
|
|
|
{
|
|
|
|
|
Name: "testcontainer",
|
|
|
|
|
Name: "testcontainer",
|
|
|
|
|
Image: "testcontainer:latest",
|
|
|
|
|
Ports: []v1.ContainerPort{
|
|
|
|
|
{
|
|
|
|
|
Name: "testport",
|
|
|
|
|