Skip to content

Commit

Permalink
Don't index hostNetwork
Browse files Browse the repository at this point in the history
  • Loading branch information
omris94 committed Jul 25, 2024
1 parent 224680e commit cf195ed
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/mapper/pkg/kubefinder/kubefinder.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,12 @@ func (k *KubeFinder) initIndexes(ctx context.Context) error {
err := k.mgr.GetCache().IndexField(ctx, &corev1.Pod{}, podIPIndexField, func(object client.Object) []string {
res := make([]string, 0)
pod := object.(*corev1.Pod)

// host network pods use their node's IP address, it's not safe to assume this IP is unique to this pod
if pod.Spec.HostNetwork || pod.DeletionTimestamp != nil || pod.Status.Phase != corev1.PodRunning {
return res
}
for _, ip := range pod.Status.PodIPs {
if pod.DeletionTimestamp != nil || pod.Status.Phase != corev1.PodRunning {
continue
}
res = append(res, ip.IP)
}
return res
Expand Down

0 comments on commit cf195ed

Please sign in to comment.