diff --git a/ui/src/lib/k8s.ts b/ui/src/lib/k8s.ts index 84c6adea..7d2b5679 100644 --- a/ui/src/lib/k8s.ts +++ b/ui/src/lib/k8s.ts @@ -402,6 +402,16 @@ export function getServiceExternalIP(service: Service): string { } } +/** Tokens used by the Services list search (name/type/IP + port / nodePort / targetPort). */ +export function getServicePortSearchValues(service: Service): string[] { + return (service.spec?.ports ?? []).map((port) => { + const protocol = (port.protocol ?? 'TCP').toLowerCase() + return port.nodePort != null + ? `${port.port}:${port.nodePort}/${protocol}` + : `${port.port}/${protocol}` + }) +} + // Helper function to check if pod has ready condition function hasPodReadyCondition(conditions?: Array<{ type?: string }>): boolean { return conditions?.some((condition) => condition.type === 'Ready') ?? false diff --git a/ui/src/pages/service-list-page.tsx b/ui/src/pages/service-list-page.tsx index c709c25e..bf014087 100644 --- a/ui/src/pages/service-list-page.tsx +++ b/ui/src/pages/service-list-page.tsx @@ -4,7 +4,11 @@ import { Service } from 'kubernetes-types/core/v1' import { useTranslation } from 'react-i18next' import { Link } from 'react-router-dom' -import { createSearchFilter, getServiceExternalIP } from '@/lib/k8s' +import { + createSearchFilter, + getServiceExternalIP, + getServicePortSearchValues, +} from '@/lib/k8s' import { formatDate } from '@/lib/utils' import { Badge } from '@/components/ui/badge' import { ResourceTable } from '@/components/resource-table' @@ -12,7 +16,8 @@ import { ResourceTable } from '@/components/resource-table' const serviceSearchFilter = createSearchFilter( (s) => s.metadata?.name, (s) => s.spec?.type, - (s) => s.spec?.clusterIP + (s) => s.spec?.clusterIP, + (s) => getServicePortSearchValues(s) ) export function ServiceListPage() {