mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
* [service discovery] add service type metadata to kubernetes_sd_config service role Signed-off-by: fuling <fuling.lgz@alibaba-inc.com> * [fix] ServiceType -> string Signed-off-by: fuling <fuling.lgz@alibaba-inc.com> * [fix] fix testcase Signed-off-by: fuling <fuling.lgz@alibaba-inc.com> * [style] Signed-off-by: fuling <fuling.lgz@alibaba-inc.com> * [doc] add service type Signed-off-by: fuling <fuling.lgz@alibaba-inc.com> * [doc] sort Signed-off-by: fuling <fuling.lgz@alibaba-inc.com>
This commit is contained in:
parent
46129fdebb
commit
029b45aa30
|
@ -152,6 +152,7 @@ const (
|
|||
servicePortProtocolLabel = metaLabelPrefix + "service_port_protocol"
|
||||
serviceClusterIPLabel = metaLabelPrefix + "service_cluster_ip"
|
||||
serviceExternalNameLabel = metaLabelPrefix + "service_external_name"
|
||||
serviceType = metaLabelPrefix + "service_type"
|
||||
)
|
||||
|
||||
func serviceLabels(svc *apiv1.Service) model.LabelSet {
|
||||
|
@ -188,6 +189,7 @@ func (s *Service) buildService(svc *apiv1.Service) *targetgroup.Group {
|
|||
model.AddressLabel: lv(addr),
|
||||
servicePortNameLabel: lv(port.Name),
|
||||
servicePortProtocolLabel: lv(string(port.Protocol)),
|
||||
serviceType: lv(string(svc.Spec.Type)),
|
||||
}
|
||||
|
||||
if svc.Spec.Type == apiv1.ServiceTypeExternalName {
|
||||
|
|
|
@ -112,6 +112,7 @@ func TestServiceDiscoveryAdd(t *testing.T) {
|
|||
{
|
||||
"__meta_kubernetes_service_port_protocol": "TCP",
|
||||
"__address__": "testservice.default.svc:30900",
|
||||
"__meta_kubernetes_service_type": "ClusterIP",
|
||||
"__meta_kubernetes_service_cluster_ip": "10.0.0.1",
|
||||
"__meta_kubernetes_service_port_name": "testport",
|
||||
},
|
||||
|
@ -127,6 +128,7 @@ func TestServiceDiscoveryAdd(t *testing.T) {
|
|||
{
|
||||
"__meta_kubernetes_service_port_protocol": "TCP",
|
||||
"__address__": "testservice-external.default.svc:31900",
|
||||
"__meta_kubernetes_service_type": "ExternalName",
|
||||
"__meta_kubernetes_service_port_name": "testport",
|
||||
"__meta_kubernetes_service_external_name": "FooExternalName",
|
||||
},
|
||||
|
@ -175,12 +177,14 @@ func TestServiceDiscoveryUpdate(t *testing.T) {
|
|||
{
|
||||
"__meta_kubernetes_service_port_protocol": "TCP",
|
||||
"__address__": "testservice.default.svc:30900",
|
||||
"__meta_kubernetes_service_type": "ClusterIP",
|
||||
"__meta_kubernetes_service_cluster_ip": "10.0.0.1",
|
||||
"__meta_kubernetes_service_port_name": "testport0",
|
||||
},
|
||||
{
|
||||
"__meta_kubernetes_service_port_protocol": "UDP",
|
||||
"__address__": "testservice.default.svc:30901",
|
||||
"__meta_kubernetes_service_type": "ClusterIP",
|
||||
"__meta_kubernetes_service_cluster_ip": "10.0.0.1",
|
||||
"__meta_kubernetes_service_port_name": "testport1",
|
||||
},
|
||||
|
@ -218,6 +222,7 @@ func TestServiceDiscoveryNamespaces(t *testing.T) {
|
|||
{
|
||||
"__meta_kubernetes_service_port_protocol": "TCP",
|
||||
"__address__": "testservice.ns1.svc:30900",
|
||||
"__meta_kubernetes_service_type": "ClusterIP",
|
||||
"__meta_kubernetes_service_cluster_ip": "10.0.0.1",
|
||||
"__meta_kubernetes_service_port_name": "testport",
|
||||
},
|
||||
|
@ -233,6 +238,7 @@ func TestServiceDiscoveryNamespaces(t *testing.T) {
|
|||
{
|
||||
"__meta_kubernetes_service_port_protocol": "TCP",
|
||||
"__address__": "testservice.ns2.svc:30900",
|
||||
"__meta_kubernetes_service_type": "ClusterIP",
|
||||
"__meta_kubernetes_service_cluster_ip": "10.0.0.1",
|
||||
"__meta_kubernetes_service_port_name": "testport",
|
||||
},
|
||||
|
|
|
@ -743,6 +743,7 @@ Available meta labels:
|
|||
* `__meta_kubernetes_service_name`: The name of the service object.
|
||||
* `__meta_kubernetes_service_port_name`: Name of the service port for the target.
|
||||
* `__meta_kubernetes_service_port_protocol`: Protocol of the service port for the target.
|
||||
* `__meta_kubernetes_service_type`: The type of the service.
|
||||
|
||||
#### `pod`
|
||||
|
||||
|
|
Loading…
Reference in a new issue