Skip to content

Commit

Permalink
NETOBSERV-722: decorate node flows with actual node IP and name fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Mario Macias committed Dec 20, 2022
1 parent 4835cc5 commit 35b18ea
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/pipeline/transform/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,14 @@ func (k *KubeData) initNodeInformer(informerFactory informers.SharedInformerFact
return nil, fmt.Errorf("was expecting a Node. Got: %T", i)
}
ips := make([]string, 0, len(node.Status.Addresses))
hostIP := ""
for _, address := range node.Status.Addresses {
ip := net.ParseIP(address.Address)
if ip != nil {
ips = append(ips, ip.String())
if hostIP == "" {
hostIP = ip.String()
}
}
}
// CNI-dependent logic (must work regardless of whether the CNI is installed)
Expand All @@ -199,6 +203,11 @@ func (k *KubeData) initNodeInformer(informerFactory informers.SharedInformerFact
},
ips: ips,
Type: typeNode,
// We duplicate HostIP and HostName information to simplify later filtering e.g. by
// Host IP, where we want to get all the Pod flows by src/dst host, but also the actual
// host-to-host flows by the same field.
HostIP: hostIP,
HostName: node.Name,
}, nil
}); err != nil {
return fmt.Errorf("can't set nodes transform: %w", err)
Expand Down

0 comments on commit 35b18ea

Please sign in to comment.