Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions ui/src/lib/k8s.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
})
}
Comment thread
zxh326 marked this conversation as resolved.

// Helper function to check if pod has ready condition
function hasPodReadyCondition(conditions?: Array<{ type?: string }>): boolean {
return conditions?.some((condition) => condition.type === 'Ready') ?? false
Expand Down
9 changes: 7 additions & 2 deletions ui/src/pages/service-list-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,20 @@ 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'

const serviceSearchFilter = createSearchFilter<Service>(
(s) => s.metadata?.name,
(s) => s.spec?.type,
(s) => s.spec?.clusterIP
(s) => s.spec?.clusterIP,
(s) => getServicePortSearchValues(s)
)

export function ServiceListPage() {
Expand Down
Loading