Skip to content

Commit

Permalink
Merge pull request #13935 from simonpasquier/more-endpointslices-meta…
Browse files Browse the repository at this point in the history
…data

discovery(k8s): add metadata labels to endpointslices
  • Loading branch information
simonpasquier committed Apr 19, 2024
2 parents b5b5e1e + 7704cde commit f36915b
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 4 deletions.
10 changes: 10 additions & 0 deletions discovery/kubernetes/endpointslice.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,9 @@ const (
endpointSliceEndpointConditionsReadyLabel = metaLabelPrefix + "endpointslice_endpoint_conditions_ready"
endpointSliceEndpointConditionsServingLabel = metaLabelPrefix + "endpointslice_endpoint_conditions_serving"
endpointSliceEndpointConditionsTerminatingLabel = metaLabelPrefix + "endpointslice_endpoint_conditions_terminating"
endpointSliceEndpointZoneLabel = metaLabelPrefix + "endpointslice_endpoint_zone"
endpointSliceEndpointHostnameLabel = metaLabelPrefix + "endpointslice_endpoint_hostname"
endpointSliceEndpointNodenameLabel = metaLabelPrefix + "endpointslice_endpoint_node_name"
endpointSliceAddressTargetKindLabel = metaLabelPrefix + "endpointslice_address_target_kind"
endpointSliceAddressTargetNameLabel = metaLabelPrefix + "endpointslice_address_target_name"
endpointSliceEndpointTopologyLabelPrefix = metaLabelPrefix + "endpointslice_endpoint_topology_"
Expand Down Expand Up @@ -338,6 +340,14 @@ func (e *EndpointSlice) buildEndpointSlice(eps endpointSliceAdaptor) *targetgrou
target[model.LabelName(endpointSliceAddressTargetNameLabel)] = lv(ep.targetRef().Name)
}

if ep.nodename() != nil {
target[endpointSliceEndpointNodenameLabel] = lv(*ep.nodename())
}

if ep.zone() != nil {
target[model.LabelName(endpointSliceEndpointZoneLabel)] = lv(*ep.zone())
}

for k, v := range ep.topology() {
ln := strutil.SanitizeLabelName(k)
target[model.LabelName(endpointSliceEndpointTopologyLabelPrefix+ln)] = lv(v)
Expand Down
9 changes: 9 additions & 0 deletions discovery/kubernetes/endpointslice_adaptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type endpointSliceEndpointAdaptor interface {
addresses() []string
hostname() *string
nodename() *string
zone() *string
conditions() endpointSliceEndpointConditionsAdaptor
targetRef() *corev1.ObjectReference
topology() map[string]string
Expand Down Expand Up @@ -181,6 +182,10 @@ func (e *endpointSliceEndpointAdaptorV1) nodename() *string {
return e.endpoint.NodeName
}

func (e *endpointSliceEndpointAdaptorV1) zone() *string {
return e.endpoint.Zone
}

func (e *endpointSliceEndpointAdaptorV1) conditions() endpointSliceEndpointConditionsAdaptor {
return newEndpointSliceEndpointConditionsAdaptorFromV1(e.endpoint.Conditions)
}
Expand Down Expand Up @@ -233,6 +238,10 @@ func (e *endpointSliceEndpointAdaptorV1beta1) nodename() *string {
return e.endpoint.NodeName
}

func (e *endpointSliceEndpointAdaptorV1beta1) zone() *string {
return nil
}

func (e *endpointSliceEndpointAdaptorV1beta1) conditions() endpointSliceEndpointConditionsAdaptor {
return newEndpointSliceEndpointConditionsAdaptorFromV1beta1(e.endpoint.Conditions)
}
Expand Down

0 comments on commit f36915b

Please sign in to comment.