@skyhook-io/radar-app 1.21.8 → 1.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/package.json +1 -1
  2. package/src/App.tsx +14 -0
  3. package/src/api/client.ts +6 -0
  4. package/src/api/radarFeatures.ts +4 -0
  5. package/src/api/traefik.ts +33 -0
  6. package/src/api/traffic.ts +1 -0
  7. package/src/components/CloudFunnelButton.test.tsx +39 -1
  8. package/src/components/CloudFunnelButton.tsx +10 -3
  9. package/src/components/cnpg/CNPGOverview.test.tsx +75 -3
  10. package/src/components/cnpg/CNPGOverview.tsx +62 -4
  11. package/src/components/home/NetworkPolicyCoverageCard.test.tsx +37 -0
  12. package/src/components/home/NetworkPolicyCoverageCard.tsx +26 -2
  13. package/src/components/resources/renderers/TraefikIngressRouteRenderer.test.tsx +23 -0
  14. package/src/components/resources/renderers/TraefikIngressRouteRenderer.tsx +23 -0
  15. package/src/components/resources/renderers/TraefikMiddlewareRenderer.test.tsx +23 -0
  16. package/src/components/resources/renderers/TraefikMiddlewareRenderer.tsx +29 -0
  17. package/src/components/traffic/TrafficConnectionsTable.test.tsx +23 -0
  18. package/src/components/traffic/TrafficConnectionsTable.tsx +5 -4
  19. package/src/components/traffic/TrafficFilterSidebar.test.tsx +14 -0
  20. package/src/components/traffic/TrafficFilterSidebar.tsx +17 -0
  21. package/src/components/traffic/TrafficFlowList.tsx +5 -5
  22. package/src/components/traffic/TrafficGraph.test.tsx +11 -0
  23. package/src/components/traffic/TrafficGraph.tsx +31 -19
  24. package/src/components/traffic/TrafficView.tsx +17 -6
  25. package/src/components/traffic/traffic-export.test.ts +8 -0
  26. package/src/components/traffic/traffic-export.ts +7 -4
  27. package/src/components/traffic/trafficFilters.test.ts +51 -1
  28. package/src/components/traffic/trafficFilters.ts +39 -11
  29. package/src/components/ui/command-items-crd.test.tsx +23 -8
  30. package/src/components/whats-new/releaseNotes.ts +75 -1
  31. package/src/integrations/resourceHosts.test.tsx +1 -1
  32. package/src/integrations/resourceHosts.tsx +3 -0
@@ -0,0 +1,29 @@
1
+ import { useMemo } from 'react'
2
+ import { TraefikMiddlewareRenderer as BaseTraefikMiddlewareRenderer, type TraefikMiddlewareUsers } from '@skyhook-io/k8s-ui/components/resources/renderers/TraefikMiddlewareRenderer'
3
+ import type { ResourceRef, TraefikRoutesResponse } from '@skyhook-io/k8s-ui'
4
+ import { isRadarFeatureUnsupported } from '../../../api/radarFeatures'
5
+ import { useTraefikMiddlewareUsers } from '../../../api/traefik'
6
+
7
+ // undefined on an older Radar or while loading (IngressRoutes still syncing
8
+ // included); null when the request failed or Radar couldn't read
9
+ // IngressRoutes at all, so an unread answer never reads as "no route".
10
+ export function middlewareUsers(query: { data?: TraefikRoutesResponse; isError: boolean; error?: unknown; support: string }): TraefikMiddlewareUsers | null | undefined {
11
+ if (query.support === 'unsupported' || isRadarFeatureUnsupported(query.error, 'traefikRoutes')) return undefined
12
+ if (query.isError) return null
13
+ if (!query.data) return undefined
14
+ const state = query.data.coverage?.ingressroutes?.state
15
+ if (state === 'syncing') return undefined
16
+ if (state !== 'full' && state !== 'partial') return null
17
+ return {
18
+ routes: query.data.routes.map((r) => ({ group: r.ref.group, namespace: r.ref.namespace, name: r.ref.name })),
19
+ truncated: query.data.truncated,
20
+ partial: state === 'partial',
21
+ }
22
+ }
23
+
24
+ /** Host wrapper: adds which IngressRoutes use the Middleware. */
25
+ export function TraefikMiddlewareRenderer({ data, onNavigate }: { data: any; onNavigate?: (ref: ResourceRef) => void }) {
26
+ const { data: users, isError, error, support } = useTraefikMiddlewareUsers(data?.metadata?.namespace ?? '', data?.metadata?.name ?? '')
27
+ const usedBy = useMemo(() => middlewareUsers({ data: users, isError, error, support }), [users, isError, error, support])
28
+ return <BaseTraefikMiddlewareRenderer data={data} onNavigate={onNavigate} usedBy={usedBy} />
29
+ }
@@ -76,6 +76,16 @@ describe('TrafficConnectionsTable', () => {
76
76
  })
77
77
  })
78
78
 
79
+ describe('TrafficConnectionsTable ports taken from a Service', () => {
80
+ it('says the port was taken from the Service, not observed', () => {
81
+ const props = { isRateBased: false, selection: null, onSelect: vi.fn(), onFocus: vi.fn() }
82
+ act(() => root.render(<TrafficConnectionsTable {...props} flows={[{ ...tcp, portSource: 'service' }]} />))
83
+ expect(container.querySelector('[role="row"]')!.textContent).toContain('5432 (from Service)')
84
+ act(() => root.render(<TrafficConnectionsTable {...props} flows={[{ ...tcp, port: 0, portSource: 'serviceMultiple' }]} />))
85
+ expect(container.querySelector('[role="row"]')!.textContent).toContain('multiple (from Service)')
86
+ })
87
+ })
88
+
79
89
  describe('TrafficConnectionsTable protocol data', () => {
80
90
  it('renders compact protocol figures without their mixed sum', () => {
81
91
  const mixed = { ...tcp, bytesSent: 38668, bytesRecv: 652404, bytesByProtocol: {
@@ -92,3 +102,16 @@ describe('TrafficConnectionsTable protocol data', () => {
92
102
  expect(container.textContent).not.toMatch(/674\.9 KB|691,?072/)
93
103
  })
94
104
  })
105
+
106
+ describe('TrafficConnectionsTable likely overlay', () => {
107
+ it('selects the overlay row apart from the other traffic between the same nodes', () => {
108
+ const other = { ...tcp, source: { name: 'node-a', namespace: '', kind: 'Pod' }, destination: { name: 'node-b', namespace: '', kind: 'Pod' }, port: 0 }
109
+ const overlay = { ...other, protocol: 'udp', likelyOverlay: true }
110
+ const onSelect = vi.fn()
111
+ const props = { flows: [other, overlay], isRateBased: false, onSelect, onFocus: vi.fn() }
112
+ act(() => root.render(<TrafficConnectionsTable {...props} selection={null} />))
113
+ act(() => container.querySelectorAll<HTMLElement>('[role="row"]')[1].click())
114
+ act(() => root.render(<TrafficConnectionsTable {...props} selection={onSelect.mock.calls[0][0]} />))
115
+ expect([...container.querySelectorAll('[role="row"]')].map(r => r.getAttribute('aria-selected'))).toEqual(['false', 'true'])
116
+ })
117
+ })
@@ -8,7 +8,7 @@ import { SEVERITY_TEXT } from '@skyhook-io/k8s-ui/utils/badge-colors'
8
8
  import { Tooltip } from '../ui/Tooltip'
9
9
  import type { TrafficGraphSelection } from './TrafficGraph'
10
10
  import {
11
- dataByProtocol, connectionRows, displayVolume, edgesOnPort, flowDrops, flowErrors, formatRate, graphEndpointId, hasStatusData, isExternalKind,
11
+ dataByProtocol, connectionRows, displayVolume, edgesOnPort, flowDrops, flowErrors, formatRate, graphEndpointId, hasStatusData, isExternalKind, portLabel,
12
12
  type GraphFlow, type TrafficFocus,
13
13
  } from './trafficFilters'
14
14
 
@@ -40,6 +40,7 @@ function rowSelection(flow: AggregatedFlow): TrafficGraphSelection {
40
40
  destId: graphEndpointId(flow.destination),
41
41
  port: flow.port,
42
42
  directionUnknown: !!flow.directionUnknown,
43
+ ...(flow.likelyOverlay && { likelyOverlay: true }),
43
44
  }
44
45
  }
45
46
 
@@ -47,7 +48,7 @@ function selectedRows(rows: GraphFlow[], selection: TrafficGraphSelection | null
47
48
  if (selection?.type !== 'edge' || selection.port === undefined) return new Set()
48
49
  const between = rows.filter(flow =>
49
50
  graphEndpointId(flow.source) === selection.sourceId && graphEndpointId(flow.destination) === selection.destId &&
50
- !!flow.directionUnknown === !!selection.directionUnknown)
51
+ !!flow.directionUnknown === !!selection.directionUnknown && !!flow.likelyOverlay === !!selection.likelyOverlay)
51
52
  return new Set(edgesOnPort(between, f => f, selection.port))
52
53
  }
53
54
 
@@ -106,7 +107,7 @@ export function TrafficConnectionsTable({ flows, isRateBased, selection, onSelec
106
107
  <Virtuoso
107
108
  className="flex-1"
108
109
  data={rows}
109
- computeItemKey={(_, flow) => `${graphEndpointId(flow.source)}->${graphEndpointId(flow.destination)}:${flow.port}${flow.directionUnknown ? ':u' : ''}`}
110
+ computeItemKey={(_, flow) => `${graphEndpointId(flow.source)}->${graphEndpointId(flow.destination)}:${flow.port}${flow.directionUnknown ? ':u' : ''}${flow.likelyOverlay ? ':v' : ''}`}
110
111
  itemContent={(_, flow) => {
111
112
  const sel = rowSelection(flow)
112
113
  const isSelected = selected.has(flow)
@@ -129,7 +130,7 @@ export function TrafficConnectionsTable({ flows, isRateBased, selection, onSelec
129
130
  : <ArrowRight className="h-3 w-3 text-theme-text-tertiary" />}
130
131
  {endpoint(flow.destination)}
131
132
  <span className="truncate text-theme-text-secondary tabular-nums">
132
- {flow.port > 0 ? flow.port : '—'}
133
+ {portLabel(flow.port, flow.portSource) ?? '—'}
133
134
  {(flow.l7Protocol || flow.protocol) && (
134
135
  <span className="ml-1 text-theme-text-tertiary">{flow.l7Protocol || flow.protocol.toUpperCase()}</span>
135
136
  )}
@@ -75,3 +75,17 @@ describe('TrafficFilterSidebar verdict filter', () => {
75
75
  expect(container.textContent).not.toContain('Verdict')
76
76
  })
77
77
  })
78
+
79
+ describe('TrafficFilterSidebar overlay toggle', () => {
80
+ it('is offered only when the source marked flows as likely overlay, off by default', () => {
81
+ act(() => root.render(<TrafficFilterSidebar {...props({ setHideOverlay: vi.fn() })} />))
82
+ expect(container.textContent).not.toContain('Hide node-to-node overlay')
83
+
84
+ const setHideOverlay = vi.fn()
85
+ act(() => root.render(<TrafficFilterSidebar {...props({ hasOverlayFlows: true, hideOverlay: false, setHideOverlay })} />))
86
+ expect(container.textContent).toContain('Hide node-to-node overlay')
87
+ const toggle = Array.from(container.querySelectorAll('button')).find(b => b.textContent?.includes('Hide node-to-node overlay'))!
88
+ act(() => toggle.click())
89
+ expect(setHideOverlay).toHaveBeenCalledWith(true)
90
+ })
91
+ })
@@ -12,6 +12,7 @@ import {
12
12
  Puzzle,
13
13
  Boxes,
14
14
  ShieldAlert,
15
+ Server,
15
16
  } from 'lucide-react'
16
17
  import { clsx } from 'clsx'
17
18
  import { SEVERITY_BADGE } from '@skyhook-io/k8s-ui/utils/badge-colors'
@@ -35,6 +36,10 @@ interface TrafficFilterSidebarProps {
35
36
  setHideSystem: (v: boolean) => void
36
37
  hideExternal: boolean
37
38
  setHideExternal: (v: boolean) => void
39
+ /** Offered only when the source marked some flows as likely overlay. */
40
+ hasOverlayFlows?: boolean
41
+ hideOverlay?: boolean
42
+ setHideOverlay?: (v: boolean) => void
38
43
  minConnections: number
39
44
  setMinConnections: (v: number) => void
40
45
 
@@ -151,6 +156,9 @@ export const TrafficFilterSidebar = memo(function TrafficFilterSidebar({
151
156
  setHideSystem,
152
157
  hideExternal,
153
158
  setHideExternal,
159
+ hasOverlayFlows,
160
+ hideOverlay,
161
+ setHideOverlay,
154
162
  minConnections,
155
163
  setMinConnections,
156
164
  showNamespaceGroups,
@@ -257,6 +265,15 @@ export const TrafficFilterSidebar = memo(function TrafficFilterSidebar({
257
265
  onToggle={() => setHideExternal(!hideExternal)}
258
266
  icon={Globe}
259
267
  />
268
+ {hasOverlayFlows && setHideOverlay && (
269
+ <ToggleOption
270
+ label="Hide node-to-node overlay"
271
+ description="UDP between two nodes is likely CNI overlay (VXLAN, Geneve) carrying pod traffic already on the map. Unless Beyla reports the port, a guess: WireGuard or DNS between nodes look the same."
272
+ enabled={!!hideOverlay}
273
+ onToggle={() => setHideOverlay(!hideOverlay)}
274
+ icon={Server}
275
+ />
276
+ )}
260
277
  </div>
261
278
 
262
279
  {/* Cluster Addons 3-way toggle */}
@@ -8,7 +8,7 @@ import { SEVERITY_BADGE, SEVERITY_TEXT } from '@skyhook-io/k8s-ui/utils/badge-co
8
8
  import { pluralize, StatusDot } from '@skyhook-io/k8s-ui'
9
9
  import type { StatusTone } from '@skyhook-io/k8s-ui'
10
10
  import { useFlowSearch } from './TrafficFlowListContext'
11
- import { isPolicyDropReason, protocolLabel } from './trafficFilters'
11
+ import { isPolicyDropReason, portLabel, protocolLabel } from './trafficFilters'
12
12
  import { useQuery } from '@tanstack/react-query'
13
13
  import { fetchJSON } from '../../api/client'
14
14
  import { Tooltip } from '../ui/Tooltip'
@@ -208,7 +208,7 @@ export function TrafficFlowList({ flows, responsesCallerOriented }: TrafficFlowL
208
208
  </>
209
209
  )}
210
210
  {!isHTTP && !isDNS && (
211
- <span className="text-theme-text-tertiary uppercase">{flow.port ? `${flow.protocol}:${flow.port}` : flow.protocol}</span>
211
+ <span className="text-theme-text-tertiary"><span className="uppercase">{flow.protocol}</span>{portLabel(flow.port, flow.portSource) && `:${portLabel(flow.port, flow.portSource)}`}</span>
212
212
  )}
213
213
  </div>
214
214
 
@@ -255,10 +255,10 @@ export function TrafficFlowList({ flows, responsesCallerOriented }: TrafficFlowL
255
255
  <span className="text-theme-text-primary">{protocolLabel(flow.l7Protocol, flow.protocol)}</span>
256
256
  {flow.httpProtocol && <span className="text-theme-text-tertiary"> ({flow.httpProtocol})</span>}
257
257
  </div>
258
- {flow.port !== 0 && (
258
+ {portLabel(flow.port, flow.portSource) && (
259
259
  <div>
260
260
  <span className="text-theme-text-tertiary">Port: </span>
261
- <span className="text-theme-text-primary">{flow.port}</span>
261
+ <span className="text-theme-text-primary">{portLabel(flow.port, flow.portSource)}</span>
262
262
  </div>
263
263
  )}
264
264
  {flow.trafficDirection && (
@@ -440,7 +440,7 @@ function PolicyCorrelation({ flow }: { flow: TrafficFlow }) {
440
440
  if (src?.name) params.set('sourcePodName', src.name)
441
441
  if (src?.kind) params.set('sourceKind', src.kind)
442
442
  if (src?.ip) params.set('sourceIP', src.ip)
443
- if (flow.port) params.set('port', String(flow.port))
443
+ if (flow.port && !flow.portSource) params.set('port', String(flow.port))
444
444
  if (flow.protocol) params.set('protocol', flow.protocol)
445
445
  return fetchJSON(`/network-policies/evaluate?${params}`)
446
446
  },
@@ -297,3 +297,14 @@ describe('TrafficNode title', () => {
297
297
  expect(container.querySelector(`[title="${label}"]`)!.closest('[aria-hidden="true"]')).not.toBeNull()
298
298
  })
299
299
  })
300
+
301
+ it('draws likely-overlay traffic between two nodes as its own edge', async () => {
302
+ const nodeA = { name: 'node-a', namespace: '', kind: 'External' }
303
+ const nodeB = { name: 'node-b', namespace: '', kind: 'External' }
304
+ const tcp: AggregatedFlow = { source: nodeA, destination: nodeB, protocol: 'tcp', port: 0, connections: 0, bytesSent: 10, bytesRecv: 0, flowCount: 1, lastSeen: '' }
305
+ const overlay: AggregatedFlow = { ...tcp, protocol: 'udp', bytesSent: 1000, likelyOverlay: true }
306
+ await act(async () => root.render(<TrafficGraph flows={[tcp, overlay]} trafficSource="beyla" onLayoutUnavailable={vi.fn()} windowSeconds={60} />))
307
+ const ids = [...container.querySelectorAll('[data-edge]')].map(e => e.getAttribute('data-edge'))
308
+ expect(ids).toContain('node-a->node-b:0')
309
+ expect(ids).toContain('node-a->node-b:0:overlay')
310
+ })
@@ -16,7 +16,7 @@ import {
16
16
  } from '@xyflow/react'
17
17
  import '@xyflow/react/dist/style.css'
18
18
  import type { ELK } from 'elkjs/lib/elk.bundled.js'
19
- import type { AggregatedFlow } from '../../types'
19
+ import type { AggregatedFlow, TrafficPortSource } from '../../types'
20
20
  import { clsx } from 'clsx'
21
21
  import { X, ArrowRight, Globe, Server, Activity, Puzzle, Crosshair } from 'lucide-react'
22
22
  import { GraphExportButton, MiddleEllipsis, PaneLoader } from '@skyhook-io/k8s-ui'
@@ -26,7 +26,7 @@ import { getNamespaceColor } from '../../utils/traffic-colors'
26
26
  import { Tooltip } from '../ui/Tooltip'
27
27
  import { TrafficData } from './TrafficData'
28
28
  import { describeTrafficNode } from './traffic-export'
29
- import { dataByProtocol, protocolsOf, throughputLabel, totalDataByProtocol, protocolName, isRateBasedSource, isExternalKind, requestRateOf, errorRateOf, formatRate, formatConnections, formatVolume, MAX_VISIBLE_PORTS, displayVolume, latencyWeightOf, edgesOnPort, protocolLabel, type TrafficFocus } from './trafficFilters'
29
+ import { dataByProtocol, protocolsOf, throughputLabel, totalDataByProtocol, protocolName, isRateBasedSource, isExternalKind, requestRateOf, errorRateOf, formatRate, formatConnections, formatVolume, MAX_VISIBLE_PORTS, displayVolume, latencyWeightOf, edgesOnPort, protocolLabel, portLabel, type TrafficFocus } from './trafficFilters'
30
30
 
31
31
  // ELK is 1.5 MB; load it with the first traffic layout, not with the app.
32
32
  let elkPromise: Promise<ELK> | null = null
@@ -64,8 +64,9 @@ export interface TrafficGraphSelection {
64
64
  sourceId?: string
65
65
  destId?: string
66
66
  port?: number
67
- // The graph draws traffic of unknown direction as its own edge.
67
+ // The graph draws traffic of unknown direction, and likely overlay, as its own edge.
68
68
  directionUnknown?: boolean
69
+ likelyOverlay?: boolean
69
70
  }
70
71
 
71
72
  interface TrafficGraphProps {
@@ -157,6 +158,8 @@ function StatusDistributionBar({ counts }: { counts: Record<string, number> }) {
157
158
  interface PortInfo {
158
159
  port: number
159
160
  connections: number
161
+ /** Set when no edge observed this port: taken from a Service, or, on port 0, several Service ports. */
162
+ portSource?: TrafficPortSource
160
163
  }
161
164
 
162
165
  interface TrafficNodeData extends Record<string, unknown> {
@@ -301,15 +304,15 @@ export function TrafficNode({ data }: { data: TrafficNodeData }) {
301
304
  </div>
302
305
  )}
303
306
  {/* Ports section */}
304
- {data.ports && data.ports.filter(p => p.port !== 0).length > 0 && (
307
+ {data.ports && data.ports.filter(p => portLabel(p.port, p.portSource) !== null).length > 0 && (
305
308
  <div className="mt-1.5 space-y-0.5">
306
- {data.ports.filter(p => p.port !== 0).slice(0, MAX_VISIBLE_PORTS).map((portInfo) => (
309
+ {data.ports.filter(p => portLabel(p.port, p.portSource) !== null).slice(0, MAX_VISIBLE_PORTS).map((portInfo) => (
307
310
  <div key={portInfo.port} className="flex items-center justify-between gap-1 text-xs">
308
311
  <span className={clsx(
309
312
  'font-mono',
310
313
  (hasNamespaceColor || isAddonNode) ? 'text-cyan-300' : 'text-blue-600 dark:text-blue-300'
311
314
  )}>
312
- :{portInfo.port}
315
+ :{portLabel(portInfo.port, portInfo.portSource)}
313
316
  </span>
314
317
  {/* A port serving traffic with no HTTP has no request rate to show, and
315
318
  "0" beside the port reads as an idle port rather than an unmeasured
@@ -328,18 +331,18 @@ export function TrafficNode({ data }: { data: TrafficNodeData }) {
328
331
  )}
329
332
  </div>
330
333
  ))}
331
- {data.ports.filter(p => p.port !== 0).length > MAX_VISIBLE_PORTS && (
334
+ {data.ports.filter(p => portLabel(p.port, p.portSource) !== null).length > MAX_VISIBLE_PORTS && (
332
335
  <div className={clsx(
333
336
  'text-xs',
334
337
  (hasNamespaceColor || isAddonNode) ? 'text-white/50' : 'text-theme-text-tertiary'
335
338
  )}>
336
- +{data.ports.filter(p => p.port !== 0).length - MAX_VISIBLE_PORTS} more
339
+ +{data.ports.filter(p => portLabel(p.port, p.portSource) !== null).length - MAX_VISIBLE_PORTS} more
337
340
  </div>
338
341
  )}
339
342
  </div>
340
343
  )}
341
344
  {/* Total connections (only if no ports shown, or all ports are 0) */}
342
- {(!data.ports || data.ports.filter(p => p.port !== 0).length === 0) && data.totalConnections != null && data.totalConnections > 0 && (
345
+ {(!data.ports || data.ports.filter(p => portLabel(p.port, p.portSource) !== null).length === 0) && data.totalConnections != null && data.totalConnections > 0 && (
343
346
  <div className="mt-1">
344
347
  <span className={clsx(
345
348
  'text-xs truncate',
@@ -754,8 +757,8 @@ function DetailsPanel({
754
757
  ) : (
755
758
  <ArrowRight className="h-3 w-3 text-theme-text-tertiary shrink-0" />
756
759
  )}
757
- {flow.port !== 0 && (
758
- <span className="text-blue-400 font-mono">:{flow.port}</span>
760
+ {portLabel(flow.port, flow.portSource) && (
761
+ <span className="text-blue-400 font-mono">:{portLabel(flow.port, flow.portSource)}</span>
759
762
  )}
760
763
  </div>
761
764
  <div className="flex items-center gap-2 text-[10px]">
@@ -806,8 +809,8 @@ function DetailsPanel({
806
809
  <span className="text-theme-text-primary truncate flex-1">
807
810
  {flow.destination.name}
808
811
  </span>
809
- {flow.port !== 0 && (
810
- <span className="text-blue-400 font-mono">:{flow.port}</span>
812
+ {portLabel(flow.port, flow.portSource) && (
813
+ <span className="text-blue-400 font-mono">:{portLabel(flow.port, flow.portSource)}</span>
811
814
  )}
812
815
  </div>
813
816
  <div className="flex items-center gap-2 text-[10px]">
@@ -858,10 +861,10 @@ function DetailsPanel({
858
861
  </div>
859
862
 
860
863
  <div className="grid grid-cols-2 gap-2 text-xs">
861
- {edgeData.port !== 0 && (
864
+ {portLabel(edgeData.port, edgeData.flow?.portSource) && (
862
865
  <div className="p-2 rounded bg-theme-elevated">
863
866
  <div className="text-theme-text-tertiary">Port</div>
864
- <div className="text-theme-text-primary font-medium">{edgeData.port}</div>
867
+ <div className="text-theme-text-primary font-medium">{portLabel(edgeData.port, edgeData.flow?.portSource)}</div>
865
868
  </div>
866
869
  )}
867
870
  <div className="p-2 rounded bg-theme-elevated">
@@ -1151,7 +1154,8 @@ function isFocusable(id: string, data: TrafficNodeData | undefined): boolean {
1151
1154
  // one would silently replace the other. Only unoriented edges are suffixed, so
1152
1155
  // every id a source that always orients its flows produces is unchanged.
1153
1156
  function trafficEdgeId(sourceId: string, destId: string, flow: AggregatedFlow): string {
1154
- return `${sourceId}->${destId}:${flow.port}${flow.directionUnknown ? ':unoriented' : ''}`
1157
+ // The server keeps likely-overlay traffic apart from the rest between the same nodes.
1158
+ return `${sourceId}->${destId}:${flow.port}${flow.directionUnknown ? ':unoriented' : ''}${flow.likelyOverlay ? ':overlay' : ''}`
1155
1159
  }
1156
1160
 
1157
1161
  export function TrafficGraph({ flows, hotPathThreshold = 0, showNamespaceGroups = false, serviceCategories, addonMode = 'show', trafficSource = '', selection: viewSelection, onSelectionChange, onFocus, focusedId, onLayoutUnavailable, windowSeconds, onDownloadBlob }: TrafficGraphProps) {
@@ -1194,6 +1198,8 @@ export function TrafficGraph({ flows, hotPathThreshold = 0, showNamespaceGroups
1194
1198
 
1195
1199
  // Track primary port for each node (most common destination port)
1196
1200
  const nodePorts = new Map<string, Map<number, number>>() // nodeId -> port -> connection count
1201
+ const observedPorts = new Set<string>() // `${nodeId}|${port}` seen on an edge that observed it
1202
+ const multiplePorts = new Set<string>() // nodes an edge reached on several possible Service ports
1197
1203
 
1198
1204
  // Count connections per node
1199
1205
  flows.forEach((flow) => {
@@ -1218,6 +1224,8 @@ export function TrafficGraph({ flows, hotPathThreshold = 0, showNamespaceGroups
1218
1224
  if (!nodePorts.has(destId)) nodePorts.set(destId, new Map())
1219
1225
  const portCounts = nodePorts.get(destId)!
1220
1226
  portCounts.set(flow.port, (portCounts.get(flow.port) || 0) + volume)
1227
+ if (!flow.portSource) observedPorts.add(`${destId}|${flow.port}`)
1228
+ if (flow.portSource === 'serviceMultiple') multiplePorts.add(destId)
1221
1229
  if (flow.connections >= hotPathThreshold && hotPathThreshold > 0) hotNodes.add(destId)
1222
1230
  }
1223
1231
  })
@@ -1228,7 +1236,10 @@ export function TrafficGraph({ flows, hotPathThreshold = 0, showNamespaceGroups
1228
1236
  if (!ports || ports.size === 0) return []
1229
1237
  const portList: PortInfo[] = []
1230
1238
  ports.forEach((connections, port) => {
1231
- portList.push({ port, connections })
1239
+ const portSource: TrafficPortSource | undefined = port === 0
1240
+ ? (multiplePorts.has(nodeId) ? 'serviceMultiple' : undefined)
1241
+ : (observedPorts.has(`${nodeId}|${port}`) ? undefined : 'service')
1242
+ portList.push({ port, connections, ...(portSource && { portSource }) })
1232
1243
  })
1233
1244
  // Sort by connection count descending
1234
1245
  return portList.sort((a, b) => b.connections - a.connections)
@@ -1739,7 +1750,8 @@ export function TrafficGraph({ flows, hotPathThreshold = 0, showNamespaceGroups
1739
1750
  }
1740
1751
  const between = layoutedEdges.filter(e =>
1741
1752
  e.source === viewSelection.sourceId && e.target === viewSelection.destId &&
1742
- !!flowByEdgeId.get(e.id)?.directionUnknown === !!viewSelection.directionUnknown)
1753
+ !!flowByEdgeId.get(e.id)?.directionUnknown === !!viewSelection.directionUnknown &&
1754
+ !!flowByEdgeId.get(e.id)?.likelyOverlay === !!viewSelection.likelyOverlay)
1743
1755
  const [edge] = edgesOnPort(between, e => flowByEdgeId.get(e.id), viewSelection.port)
1744
1756
  setSelection(edge ? edgeSelection(edge, flowByEdgeId.get(edge.id)) : null)
1745
1757
  }, [viewSelection, layoutedNodes, layoutedEdges, flowByEdgeId])
@@ -1768,7 +1780,7 @@ export function TrafficGraph({ flows, hotPathThreshold = 0, showNamespaceGroups
1768
1780
  const onEdgeClick: EdgeMouseHandler<Edge> = useCallback((_event, edge) => {
1769
1781
  const flow = flowByEdgeId.get(edge.id)
1770
1782
  setSelection(edgeSelection(edge, flow))
1771
- onSelectionChange?.({ type: 'edge', sourceId: edge.source, destId: edge.target, port: flow?.port, directionUnknown: !!flow?.directionUnknown })
1783
+ onSelectionChange?.({ type: 'edge', sourceId: edge.source, destId: edge.target, port: flow?.port, directionUnknown: !!flow?.directionUnknown, ...(flow?.likelyOverlay && { likelyOverlay: true }) })
1772
1784
  }, [flowByEdgeId, onSelectionChange])
1773
1785
 
1774
1786
  const onPaneClick = useCallback(() => {
@@ -20,7 +20,7 @@ import { useDesktopBlobDownload } from '../../hooks/useDesktopDownload'
20
20
  import { Tooltip } from '../ui/Tooltip'
21
21
  import { SEVERITY_TEXT } from '@skyhook-io/k8s-ui/utils/badge-colors'
22
22
  import { DURATION_DOCK } from '@skyhook-io/k8s-ui/utils/animation'
23
- import { matchesStatusRanges, bucketsFromCounts, bucketsFromStatus, isRateBasedSource, keepAvailable, effectiveThreshold, volumeUnit, type VolumeUnit, isExternalKind, groupAddonFlows, mergeFlowVolume, coverageLabel, type GraphFlow, endpointPair, graphEndpoint, graphEndpointId, mergeRawPairs, mergedEdgePort, selectedEdgeMatcher, selectionRawPairs, selectionMatch, graphSize, GRAPH_DRAW_BUDGET, GRAPH_DRAW_CEILING, parseFocus, focusParam, focusId, focusNeighborhood, touchesFocus, endpointSummaries, namespaceSummaries, verdictChoices, type TrafficFocus, warningRetries, warningBannerTitle, emptyWarningHeadline, rateWindowSeconds } from './trafficFilters'
23
+ import { matchesStatusRanges, bucketsFromCounts, bucketsFromStatus, isRateBasedSource, keepAvailable, effectiveThreshold, volumeUnit, type VolumeUnit, isExternalKind, groupAddonFlows, mergeFlowVolume, coverageLabel, type GraphFlow, endpointPair, graphEndpoint, graphEndpointId, mergeRawPairs, mergeEdgePortInto, selectedEdgeMatcher, selectionRawPairs, selectionMatch, graphSize, GRAPH_DRAW_BUDGET, GRAPH_DRAW_CEILING, parseFocus, focusParam, focusId, focusNeighborhood, touchesFocus, endpointSummaries, namespaceSummaries, verdictChoices, type TrafficFocus, warningRetries, warningBannerTitle, emptyWarningHeadline, rateWindowSeconds } from './trafficFilters'
24
24
 
25
25
  // Where a warning about which cluster the traffic belongs to points: how the map
26
26
  // keeps to this cluster in a shared metrics store, and how to set its label.
@@ -397,6 +397,8 @@ export function TrafficView({ namespaces, onSetNamespaces }: TrafficViewProps) {
397
397
  const [timeRange, setTimeRange] = useState<string>('5m')
398
398
  const [hideSystem, setHideSystem] = useState(true)
399
399
  const [hideExternal, setHideExternal] = useState(false)
400
+ // Off by default: the classification is a guess, and real traffic matches it.
401
+ const [hideOverlay, setHideOverlay] = useState(false)
400
402
  const [minConnections, setMinConnections] = useState(0)
401
403
  // The unit the threshold above was picked under. Stored because the number alone
402
404
  // is ambiguous: 100 is a valid step in both scales and means something different
@@ -609,6 +611,8 @@ export function TrafficView({ namespaces, onSetNamespaces }: TrafficViewProps) {
609
611
  const activeDnsPattern = l7Capabilities.hasDNSQueries ? dnsPattern : ''
610
612
  const activeMinConnections = effectiveThreshold(minConnections, minConnectionsUnit, volumeUnit(isRateBased))
611
613
 
614
+ const hasOverlayFlows = useMemo(() => !!flowsData?.aggregated?.some(f => f.likelyOverlay), [flowsData?.aggregated])
615
+
612
616
  const filteredFlows = useMemo<AggregatedFlow[]>(() => {
613
617
  if (!flowsData?.aggregated) return []
614
618
 
@@ -638,6 +642,8 @@ export function TrafficView({ namespaces, onSetNamespaces }: TrafficViewProps) {
638
642
  return false
639
643
  }
640
644
 
645
+ if (hideOverlay && flow.likelyOverlay) return false
646
+
641
647
  // If hiding external, skip flows with external endpoints
642
648
  if (hideExternal) {
643
649
  if (isExternal(flow.source.kind) || isExternal(flow.destination.kind)) {
@@ -687,7 +693,7 @@ export function TrafficView({ namespaces, onSetNamespaces }: TrafficViewProps) {
687
693
 
688
694
  return true
689
695
  })
690
- }, [flowsData?.aggregated, hideSystem, hideExternal, activeMinConnections, hiddenNamespaces, addonMode, l7Protocol, activeMethods, activeStatusRanges, activeVerdicts, activeDnsPattern])
696
+ }, [flowsData?.aggregated, hideSystem, hideExternal, hideOverlay, activeMinConnections, hiddenNamespaces, addonMode, l7Protocol, activeMethods, activeStatusRanges, activeVerdicts, activeDnsPattern])
691
697
 
692
698
  // The graph's filters, applied to individual records for the list view
693
699
  const rawFlowPasses = useCallback((flow: TrafficFlow) => {
@@ -706,6 +712,7 @@ export function TrafficView({ namespaces, onSetNamespaces }: TrafficViewProps) {
706
712
  if (isAlwaysFiltered(flow.source.name) || isAlwaysFiltered(flow.destination.name)) return false
707
713
 
708
714
  if (hideExternal && (isExternal(flow.source.kind) || isExternal(flow.destination.kind))) return false
715
+ if (hideOverlay && flow.likelyOverlay) return false
709
716
 
710
717
  if (addonMode === 'hide') {
711
718
  if (isClusterAddon(sourceName, flow.source.namespace) || isClusterAddon(destName, flow.destination.namespace)) return false
@@ -734,7 +741,7 @@ export function TrafficView({ namespaces, onSetNamespaces }: TrafficViewProps) {
734
741
  }
735
742
 
736
743
  return true
737
- }, [hideSystem, hideExternal, hiddenNamespaces, addonMode, l7Protocol, activeMethods, activeStatusRanges, activeVerdicts, activeDnsPattern, drawnEndpoint])
744
+ }, [hideSystem, hideExternal, hideOverlay, hiddenNamespaces, addonMode, l7Protocol, activeMethods, activeStatusRanges, activeVerdicts, activeDnsPattern, drawnEndpoint])
738
745
 
739
746
  const filteredRawFlows = useMemo(
740
747
  () => (flowsData?.flows ?? []).filter(rawFlowPasses),
@@ -845,13 +852,13 @@ export function TrafficView({ namespaces, onSetNamespaces }: TrafficViewProps) {
845
852
  // Traffic whose direction is known is kept apart from traffic whose direction
846
853
  // is not, the same way the backend aggregation keys it: merging them would
847
854
  // give one edge a single arrowhead answer that is wrong for half its bytes.
848
- const key = `${sourceKey}->${destKey}|${flow.directionUnknown ? 'u' : 'o'}`
855
+ const key = `${sourceKey}->${destKey}|${flow.directionUnknown ? 'u' : 'o'}${flow.likelyOverlay ? '|v' : ''}`
849
856
 
850
857
  const existing = aggregatedMap.get(key)
851
858
  if (existing) {
852
859
  mergeFlowVolume(existing, flow)
853
860
  mergeRawPairs(existing, flow)
854
- existing.port = mergedEdgePort(existing.port, flow.port)
861
+ mergeEdgePortInto(existing, flow)
855
862
  // Everything merged here shares the key's direction-known state, so the
856
863
  // flag is already correct on the entry that was created first.
857
864
  } else {
@@ -898,6 +905,7 @@ export function TrafficView({ namespaces, onSetNamespaces }: TrafficViewProps) {
898
905
  if (existing) {
899
906
  mergeFlowVolume(existing, flow)
900
907
  mergeRawPairs(existing, flow)
908
+ mergeEdgePortInto(existing, flow)
901
909
  } else {
902
910
  // Create new "Internet" → destination flow
903
911
  internetFlowsMap.set(destKey, {
@@ -948,7 +956,7 @@ export function TrafficView({ namespaces, onSetNamespaces }: TrafficViewProps) {
948
956
  // Everything that makes it a different view. A refresh doesn't, so a view
949
957
  // that was drawn keeps being drawn as its size drifts past the budget.
950
958
  const viewKey = JSON.stringify([
951
- sourcesData?.active ?? '', namespaces, timeRange, focusKey ?? '', groupByWorkload, hideSystem, hideExternal, activeMinConnections,
959
+ sourcesData?.active ?? '', namespaces, timeRange, focusKey ?? '', groupByWorkload, hideSystem, hideExternal, hideOverlay, activeMinConnections,
952
960
  [...hiddenNamespaces].sort(), addonMode, aggregateExternal, detectServices, collapseInternet,
953
961
  l7Protocol, [...activeMethods].sort(), [...activeStatusRanges].sort(), [...activeVerdicts].sort(), activeDnsPattern,
954
962
  ])
@@ -1295,6 +1303,9 @@ export function TrafficView({ namespaces, onSetNamespaces }: TrafficViewProps) {
1295
1303
  setHideSystem={setHideSystem}
1296
1304
  hideExternal={hideExternal}
1297
1305
  setHideExternal={setHideExternal}
1306
+ hasOverlayFlows={hasOverlayFlows}
1307
+ hideOverlay={hideOverlay}
1308
+ setHideOverlay={setHideOverlay}
1298
1309
  minConnections={activeMinConnections}
1299
1310
  setMinConnections={chooseMinConnections}
1300
1311
  showNamespaceGroups={showNamespaceGroups}
@@ -49,3 +49,11 @@ describe('describeTrafficNode', () => {
49
49
  expect(describeTrafficNode({ id: 'addon-internet', type: 'traffic', data: { kind: 'AddonInternet', label: 'Internet' } })?.shape).toBe('internet')
50
50
  })
51
51
  })
52
+
53
+ describe('describeTrafficNode ports taken from a Service', () => {
54
+ it('marks them as on the card', () => {
55
+ const ports = [{ port: 5432, connections: 3, portSource: 'service' }, { port: 0, connections: 1, portSource: 'serviceMultiple' }, { port: 80, connections: 2 }]
56
+ const node = describeTrafficNode({ id: 'shop/db', type: 'traffic', data: { kind: 'Pod', label: 'db', ports } })
57
+ expect(node?.rows?.map(r => r.text)).toEqual([':5432 (from Service)', ':multiple (from Service)', ':80'])
58
+ })
59
+ })
@@ -1,7 +1,8 @@
1
1
  import { CircleQuestionMark, Database, Globe, Puzzle, Server } from 'lucide-react'
2
2
  import { getTopologyIcon } from '@skyhook-io/k8s-ui'
3
3
  import type { GraphBoxRow, GraphNodeMapper } from '@skyhook-io/k8s-ui/utils/graph-model'
4
- import { formatVolume, isExternalKind, MAX_VISIBLE_PORTS } from './trafficFilters'
4
+ import { formatVolume, isExternalKind, MAX_VISIBLE_PORTS, portLabel } from './trafficFilters'
5
+ import type { TrafficPortSource } from '../../types'
5
6
 
6
7
  // Hex values of the Tailwind 500 shades the traffic nodes use for these categories.
7
8
  const CATEGORY_COLORS: Record<string, string> = {
@@ -37,11 +38,13 @@ function trafficRows(data: Record<string, unknown>, hot: boolean): GraphBoxRow[]
37
38
  if (typeof p !== 'object' || p === null || !('port' in p)) return []
38
39
  const port = num(p.port)
39
40
  const connections = ('connections' in p ? num(p.connections) : undefined) ?? 0
40
- return port ? [{ port, connections }] : []
41
+ const source = 'portSource' in p && (p.portSource === 'service' || p.portSource === 'serviceMultiple') ? p.portSource as TrafficPortSource : undefined
42
+ const label = portLabel(port ?? 0, source)
43
+ return label ? [{ label, connections }] : []
41
44
  })
42
45
  if (ports.length > 0) {
43
- const rows: GraphBoxRow[] = ports.slice(0, MAX_VISIBLE_PORTS).map(({ port, connections }) => ({
44
- text: `:${port}`,
46
+ const rows: GraphBoxRow[] = ports.slice(0, MAX_VISIBLE_PORTS).map(({ label, connections }) => ({
47
+ text: `:${label}`,
45
48
  code: true,
46
49
  hot,
47
50
  // No figure for a port with no measured traffic, as on the card.
@@ -1,6 +1,6 @@
1
1
  import { describe, it, expect } from 'vitest'
2
2
  import type { AggregatedFlow, TrafficFlow } from '../../types'
3
- import { dataByProtocol, protocolsOf, totalDataByProtocol, rateWindowSeconds, throughputLabel, protocolName, matchesStatusRanges, bucketsFromCounts, bucketsFromStatus, isRateBasedSource, keepAvailable, effectiveThreshold, volumeUnit, isExternalKind, isPolicyDropReason, requestRateOf, errorRateOf, formatRate, displayVolume, groupAddonFlows, mergeFlowVolume, dedupeHTTPPairs, coverageLabel, latencyWeightOf, endpointPair, selectionRawPairs, mergeRawPairs, graphEndpoint, graphSize, parseFocus, focusParam, focusId, touchesFocus, focusNeighborhood, endpointSummaries, searchEndpoints, namespaceSummaries, namespaceOverBudget, hasStatusData, connectionRows, selectionMatch, edgeCarriesPort, edgesOnPort, mergedEdgePort, selectedEdgeMatcher, verdictChoices, warningRetries, warningBannerTitle, emptyWarningHeadline, protocolLabel, type GraphFlow } from './trafficFilters'
3
+ import { dataByProtocol, protocolsOf, totalDataByProtocol, rateWindowSeconds, throughputLabel, protocolName, matchesStatusRanges, bucketsFromCounts, bucketsFromStatus, isRateBasedSource, keepAvailable, effectiveThreshold, volumeUnit, isExternalKind, isPolicyDropReason, requestRateOf, errorRateOf, formatRate, displayVolume, groupAddonFlows, mergeFlowVolume, dedupeHTTPPairs, coverageLabel, latencyWeightOf, endpointPair, selectionRawPairs, mergeRawPairs, graphEndpoint, graphSize, parseFocus, focusParam, focusId, touchesFocus, focusNeighborhood, endpointSummaries, searchEndpoints, namespaceSummaries, namespaceOverBudget, hasStatusData, connectionRows, selectionMatch, edgeCarriesPort, edgesOnPort, mergedEdgePort, mergeEdgePortInto, portLabel, selectedEdgeMatcher, verdictChoices, warningRetries, warningBannerTitle, emptyWarningHeadline, protocolLabel, type GraphFlow } from './trafficFilters'
4
4
 
5
5
  describe('matchesStatusRanges', () => {
6
6
  it('does not filter when nothing is selected', () => {
@@ -885,3 +885,53 @@ describe('throughputLabel', () => {
885
885
  expect(throughputLabel({ ...base, bytesByProtocol: { tcp: { bytesSent: 0, bytesRecv: 0 } } }, 60)).toBe('')
886
886
  })
887
887
  })
888
+
889
+ describe('portLabel', () => {
890
+ it('marks a port taken from a Service', () => {
891
+ expect(portLabel(5432, 'service')).toBe('5432 (from Service)')
892
+ expect(portLabel(0, 'serviceMultiple')).toBe('multiple (from Service)')
893
+ expect(portLabel(80)).toBe('80')
894
+ expect(portLabel(0)).toBeNull()
895
+ })
896
+ })
897
+
898
+ describe('mergeEdgePortInto', () => {
899
+ const merge = (a: { port: number; portSource?: 'service' | 'serviceMultiple' }, b: typeof a) => {
900
+ const into = { ...a }
901
+ mergeEdgePortInto(into, b)
902
+ return into
903
+ }
904
+ it('keeps the marking of the port it shows', () => {
905
+ expect(merge({ port: 0 }, { port: 5432, portSource: 'service' })).toEqual({ port: 5432, portSource: 'service' })
906
+ expect(merge({ port: 9000, portSource: 'service' }, { port: 80 })).toEqual({ port: 80, portSource: undefined })
907
+ expect(merge({ port: 80 }, { port: 9000, portSource: 'service' })).toEqual({ port: 80 })
908
+ })
909
+ it('lets an observed port outrank the same number from a Service', () => {
910
+ expect(merge({ port: 80, portSource: 'service' }, { port: 80 })).toEqual({ port: 80, portSource: undefined })
911
+ })
912
+ it('keeps "multiple" when no part has a port', () => {
913
+ expect(merge({ port: 0 }, { port: 0, portSource: 'serviceMultiple' })).toEqual({ port: 0, portSource: 'serviceMultiple' })
914
+ expect(merge({ port: 0, portSource: 'serviceMultiple' }, { port: 0 })).toEqual({ port: 0, portSource: 'serviceMultiple' })
915
+ })
916
+ })
917
+
918
+ describe('likely-overlay edges in a selection', () => {
919
+ const tcp: AggregatedFlow = {
920
+ source: { namespace: '', name: 'node-a', kind: 'Pod' }, destination: { namespace: '', name: 'node-b', kind: 'Pod' },
921
+ protocol: 'tcp', port: 0, flowCount: 1, bytesSent: 0, bytesRecv: 0, connections: 0, lastSeen: '',
922
+ }
923
+ const overlay: AggregatedFlow = { ...tcp, protocol: 'udp', likelyOverlay: true }
924
+ const flows: GraphFlow[] = [tcp, overlay].map(f => ({ ...f, rawPairs: [endpointPair(f)] }))
925
+
926
+ it('selects the edge the user clicked, not the other traffic between the two nodes', () => {
927
+ expect(selectionRawPairs(flows, { type: 'edge', sourceId: 'node-a', destId: 'node-b', port: 0 })).toEqual([endpointPair(tcp)])
928
+ expect(selectionRawPairs(flows, { type: 'edge', sourceId: 'node-a', destId: 'node-b', port: 0, likelyOverlay: true })).toEqual([endpointPair(overlay)])
929
+ })
930
+
931
+ it('keeps overlay records off the other edge', () => {
932
+ const on = selectedEdgeMatcher([endpointPair(tcp)], true, e => e)
933
+ const record = (f: AggregatedFlow) => ({ ...f, lastSeen: '2025-01-01T00:00:00Z' }) as unknown as TrafficFlow
934
+ expect(on(record(tcp))).toBe(true)
935
+ expect(on(record(overlay))).toBe(false)
936
+ })
937
+ })