diff --git a/aggregator/persist.go b/aggregator/persist.go index 19c87a9..b337165 100644 --- a/aggregator/persist.go +++ b/aggregator/persist.go @@ -82,6 +82,7 @@ func (a *Aggregator) processSvc(d k8s.K8sResourceMessage) { service := d.Object.(*corev1.Service) ports := []struct { + Name string "json:\"name\"" Src int32 "json:\"src\"" Dest int32 "json:\"dest\"" Protocol string "json:\"protocol\"" @@ -89,10 +90,12 @@ func (a *Aggregator) processSvc(d k8s.K8sResourceMessage) { for _, port := range service.Spec.Ports { ports = append(ports, struct { + Name string "json:\"name\"" Src int32 "json:\"src\"" Dest int32 "json:\"dest\"" Protocol string "json:\"protocol\"" }{ + Name: port.Name, // https://kubernetes.io/docs/concepts/services-networking/service/#field-spec-ports Src: port.Port, Dest: int32(port.TargetPort.IntValue()), Protocol: string(port.Protocol), @@ -268,6 +271,7 @@ func (a *Aggregator) processEndpoints(ep k8s.K8sResourceMessage) { ports = append(ports, datastore.AddressPort{ Port: port.Port, Protocol: string(port.Protocol), + Name: port.Name, }) } diff --git a/datastore/dto.go b/datastore/dto.go index b6bff10..7ae5e28 100644 --- a/datastore/dto.go +++ b/datastore/dto.go @@ -19,6 +19,7 @@ type Service struct { ClusterIP string ClusterIPs []string Ports []struct { + Name string `json:"name"` Src int32 `json:"src"` Dest int32 `json:"dest"` Protocol string `json:"protocol"` @@ -72,6 +73,7 @@ type AddressIP struct { type AddressPort struct { Port int32 `json:"port"` // Port number Protocol string `json:"protocol"` // TCP or UDP + Name string `json:"name"` } // Subsets diff --git a/datastore/payload.go b/datastore/payload.go index e50cf5c..17e90ee 100644 --- a/datastore/payload.go +++ b/datastore/payload.go @@ -46,6 +46,7 @@ type SvcEvent struct { Type string `json:"type"` ClusterIPs []string `json:"cluster_ips"` Ports []struct { + Name string `json:"name"` Src int32 `json:"src"` Dest int32 `json:"dest"` Protocol string `json:"protocol"`