import { Service } from 'kubernetes-types/core/v1'; import { ExternalLink } from 'lucide-react'; import { EnvironmentId } from '@/react/portainer/environments/types'; import { useEnvironment } from '@/react/portainer/environments/queries'; import { Icon } from '@@/Icon'; import { TextTip } from '@@/Tip/TextTip'; type Props = { environmentId: EnvironmentId; appServices?: Service[]; }; export function ApplicationServicesTable({ environmentId, appServices, }: Props) { const { data: environment } = useEnvironment(environmentId); return ( <>
Accessing the application
{appServices && appServices.length === 0 && ( This application is not exposing any port. )} {appServices && appServices.length > 0 && ( <> This application is exposed through service(s) as below: {appServices.map((service) => ( {service.spec?.type === 'LoadBalancer' && ( )} {service.spec?.type !== 'LoadBalancer' && ( )} ))}
Service name Type Cluster IP External IP Container port Service port(s)
{service.metadata?.name} {service.spec?.type} {service.spec?.clusterIP} {service.status?.loadBalancer?.ingress?.[0] && service.spec?.ports?.[0] && ( Access )} {!service.status?.loadBalancer?.ingress && (
{service.spec.externalIPs?.[0] ? service.spec.externalIPs[0] : 'pending...'}
)}
{service.spec?.externalIPs?.[0] ? service.spec.externalIPs[0] : '-'} {service.spec?.ports?.map((port) => (
{port.targetPort}
))}
{service.spec?.ports?.map((port) => (
{environment?.PublicURL && port.nodePort && ( {port.port} {port.nodePort ? ' : ' : ''} {port.nodePort}/{port.protocol} )} {!environment?.PublicURL && (
{port.port} {port.nodePort ? ' : ' : ''} {port.nodePort}/{port.protocol}
)}
))}
)} ); }