@@ -44,6 +44,8 @@ func TestEndpointStore(t *testing.T) {
44
44
# TYPE kube_endpoint_labels gauge
45
45
# HELP kube_endpoint_ports Information about the Endpoint ports.
46
46
# TYPE kube_endpoint_ports gauge
47
+ # HELP kube_endpoint_address Information about Endpoint available and non available addresses.
48
+ # TYPE kube_endpoint_address gauge
47
49
`
48
50
cases := []generateMetricsTestCase {
49
51
{
@@ -61,6 +63,9 @@ func TestEndpointStore(t *testing.T) {
61
63
Addresses : []v1.EndpointAddress {
62
64
{IP : "127.0.0.1" }, {IP : "10.0.0.1" },
63
65
},
66
+ NotReadyAddresses : []v1.EndpointAddress {
67
+ {IP : "10.0.0.10" },
68
+ },
64
69
Ports : []v1.EndpointPort {
65
70
{Port : 8080 , Name : "http" , Protocol : v1 .ProtocolTCP }, {Port : 8081 , Name : "app" , Protocol : v1 .ProtocolTCP },
66
71
},
@@ -86,7 +91,7 @@ func TestEndpointStore(t *testing.T) {
86
91
Want : metadata + `
87
92
kube_endpoint_annotations{endpoint="test-endpoint",namespace="default"} 1
88
93
kube_endpoint_address_available{endpoint="test-endpoint",namespace="default"} 6
89
- kube_endpoint_address_not_ready{endpoint="test-endpoint",namespace="default"} 4
94
+ kube_endpoint_address_not_ready{endpoint="test-endpoint",namespace="default"} 6
90
95
kube_endpoint_created{endpoint="test-endpoint",namespace="default"} 1.5e+09
91
96
kube_endpoint_info{endpoint="test-endpoint",namespace="default"} 1
92
97
kube_endpoint_labels{endpoint="test-endpoint",namespace="default"} 1
@@ -96,6 +101,12 @@ func TestEndpointStore(t *testing.T) {
96
101
kube_endpoint_ports{endpoint="test-endpoint",namespace="default",port_name="prometheus",port_protocol="TCP",port_number="9090"} 1
97
102
kube_endpoint_ports{endpoint="test-endpoint",namespace="default",port_name="syslog",port_protocol="UDP",port_number="1234"} 1
98
103
kube_endpoint_ports{endpoint="test-endpoint",namespace="default",port_name="syslog-tcp",port_protocol="TCP",port_number="5678"} 1
104
+ kube_endpoint_address{endpoint="test-endpoint",namespace="default",available_ip="127.0.0.1"} 1
105
+ kube_endpoint_address{endpoint="test-endpoint",namespace="default",available_ip="10.0.0.1"} 1
106
+ kube_endpoint_address{endpoint="test-endpoint",namespace="default",available_ip="172.22.23.202"} 1
107
+ kube_endpoint_address{endpoint="test-endpoint",namespace="default",unavailable_ip="192.168.1.3"} 1
108
+ kube_endpoint_address{endpoint="test-endpoint",namespace="default",unavailable_ip="192.168.2.2"} 1
109
+ kube_endpoint_address{endpoint="test-endpoint",namespace="default",unavailable_ip="10.0.0.10"} 1
99
110
` ,
100
111
},
101
112
{
@@ -113,6 +124,9 @@ func TestEndpointStore(t *testing.T) {
113
124
Addresses : []v1.EndpointAddress {
114
125
{IP : "127.0.0.1" }, {IP : "10.0.0.1" },
115
126
},
127
+ NotReadyAddresses : []v1.EndpointAddress {
128
+ {IP : "10.0.0.10" },
129
+ },
116
130
Ports : []v1.EndpointPort {
117
131
{Port : 8080 , Protocol : v1 .ProtocolTCP },
118
132
},
@@ -122,11 +136,14 @@ func TestEndpointStore(t *testing.T) {
122
136
Want : metadata + `
123
137
kube_endpoint_annotations{endpoint="single-port-endpoint",namespace="default"} 1
124
138
kube_endpoint_address_available{endpoint="single-port-endpoint",namespace="default"} 2
125
- kube_endpoint_address_not_ready{endpoint="single-port-endpoint",namespace="default"} 0
139
+ kube_endpoint_address_not_ready{endpoint="single-port-endpoint",namespace="default"} 1
126
140
kube_endpoint_created{endpoint="single-port-endpoint",namespace="default"} 1.5e+09
127
141
kube_endpoint_info{endpoint="single-port-endpoint",namespace="default"} 1
128
142
kube_endpoint_labels{endpoint="single-port-endpoint",namespace="default"} 1
129
143
kube_endpoint_ports{endpoint="single-port-endpoint",namespace="default",port_name="",port_number="8080",port_protocol="TCP"} 1
144
+ kube_endpoint_address{endpoint="single-port-endpoint",namespace="default",available_ip="127.0.0.1"} 1
145
+ kube_endpoint_address{endpoint="single-port-endpoint",namespace="default",available_ip="10.0.0.1"} 1
146
+ kube_endpoint_address{endpoint="single-port-endpoint",namespace="default",unavailable_ip="10.0.0.10"} 1
130
147
` ,
131
148
},
132
149
}
@@ -157,6 +174,8 @@ func TestEndpointStoreWithLabels(t *testing.T) {
157
174
# TYPE kube_endpoint_labels gauge
158
175
# HELP kube_endpoint_ports Information about the Endpoint ports.
159
176
# TYPE kube_endpoint_ports gauge
177
+ # HELP kube_endpoint_address Information about Endpoint available and non available addresses.
178
+ # TYPE kube_endpoint_address gauge
160
179
`
161
180
cases := []generateMetricsTestCase {
162
181
{
@@ -177,6 +196,9 @@ func TestEndpointStoreWithLabels(t *testing.T) {
177
196
Addresses : []v1.EndpointAddress {
178
197
{IP : "127.0.0.1" }, {IP : "10.0.0.1" },
179
198
},
199
+ NotReadyAddresses : []v1.EndpointAddress {
200
+ {IP : "10.0.0.10" },
201
+ },
180
202
Ports : []v1.EndpointPort {
181
203
{Port : 8080 , Name : "http" , Protocol : v1 .ProtocolTCP }, {Port : 8081 , Name : "app" , Protocol : v1 .ProtocolTCP },
182
204
},
@@ -201,7 +223,7 @@ func TestEndpointStoreWithLabels(t *testing.T) {
201
223
},
202
224
Want : metadata + `
203
225
kube_endpoint_address_available{endpoint="test-endpoint",namespace="default"} 6
204
- kube_endpoint_address_not_ready{endpoint="test-endpoint",namespace="default"} 4
226
+ kube_endpoint_address_not_ready{endpoint="test-endpoint",namespace="default"} 6
205
227
kube_endpoint_annotations{endpoint="test-endpoint",annotation_app="foobar",namespace="default"} 1
206
228
kube_endpoint_created{endpoint="test-endpoint",namespace="default"} 1.5e+09
207
229
kube_endpoint_info{endpoint="test-endpoint",namespace="default"} 1
@@ -212,6 +234,12 @@ func TestEndpointStoreWithLabels(t *testing.T) {
212
234
kube_endpoint_ports{endpoint="test-endpoint",namespace="default",port_name="prometheus",port_protocol="TCP",port_number="9090"} 1
213
235
kube_endpoint_ports{endpoint="test-endpoint",namespace="default",port_name="syslog",port_protocol="UDP",port_number="1234"} 1
214
236
kube_endpoint_ports{endpoint="test-endpoint",namespace="default",port_name="syslog-tcp",port_protocol="TCP",port_number="5678"} 1
237
+ kube_endpoint_address{endpoint="test-endpoint",namespace="default",available_ip="127.0.0.1"} 1
238
+ kube_endpoint_address{endpoint="test-endpoint",namespace="default",available_ip="10.0.0.1"} 1
239
+ kube_endpoint_address{endpoint="test-endpoint",namespace="default",available_ip="172.22.23.202"} 1
240
+ kube_endpoint_address{endpoint="test-endpoint",namespace="default",unavailable_ip="192.168.1.3"} 1
241
+ kube_endpoint_address{endpoint="test-endpoint",namespace="default",unavailable_ip="192.168.2.2"} 1
242
+ kube_endpoint_address{endpoint="test-endpoint",namespace="default",unavailable_ip="10.0.0.10"} 1
215
243
` ,
216
244
},
217
245
{
@@ -232,6 +260,9 @@ func TestEndpointStoreWithLabels(t *testing.T) {
232
260
Addresses : []v1.EndpointAddress {
233
261
{IP : "127.0.0.1" }, {IP : "10.0.0.1" },
234
262
},
263
+ NotReadyAddresses : []v1.EndpointAddress {
264
+ {IP : "10.0.0.10" },
265
+ },
235
266
Ports : []v1.EndpointPort {
236
267
{Port : 8080 , Protocol : v1 .ProtocolTCP },
237
268
},
@@ -241,11 +272,14 @@ func TestEndpointStoreWithLabels(t *testing.T) {
241
272
Want : metadata + `
242
273
kube_endpoint_annotations{endpoint="single-port-endpoint",annotation_app="single-foobar",namespace="default"} 1
243
274
kube_endpoint_address_available{endpoint="single-port-endpoint",namespace="default"} 2
244
- kube_endpoint_address_not_ready{endpoint="single-port-endpoint",namespace="default"} 0
275
+ kube_endpoint_address_not_ready{endpoint="single-port-endpoint",namespace="default"} 1
245
276
kube_endpoint_created{endpoint="single-port-endpoint",namespace="default"} 1.5e+09
246
277
kube_endpoint_info{endpoint="single-port-endpoint",namespace="default"} 1
247
278
kube_endpoint_labels{endpoint="single-port-endpoint",label_app="single-foobar",namespace="default"} 1
248
279
kube_endpoint_ports{endpoint="single-port-endpoint",namespace="default",port_name="",port_number="8080",port_protocol="TCP"} 1
280
+ kube_endpoint_address{endpoint="single-port-endpoint",namespace="default",available_ip="127.0.0.1"} 1
281
+ kube_endpoint_address{endpoint="single-port-endpoint",namespace="default",available_ip="10.0.0.1"} 1
282
+ kube_endpoint_address{endpoint="single-port-endpoint",namespace="default",unavailable_ip="10.0.0.10"} 1
249
283
` ,
250
284
},
251
285
}
0 commit comments