mirror of
https://github.com/portainer/portainer.git
synced 2025-07-21 14:29:40 +02:00
feat: kubernets service - display external hostname (#486)
This commit is contained in:
parent
28b222fffa
commit
798fa2396a
4 changed files with 45 additions and 5 deletions
|
@ -36,7 +36,7 @@ type (
|
||||||
|
|
||||||
K8sServiceIngress struct {
|
K8sServiceIngress struct {
|
||||||
IP string `json:"IP"`
|
IP string `json:"IP"`
|
||||||
Host string `json:"Host"`
|
Hostname string `json:"Hostname"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// K8sServiceDeleteRequests is a mapping of namespace names to a slice of
|
// K8sServiceDeleteRequests is a mapping of namespace names to a slice of
|
||||||
|
|
|
@ -82,7 +82,7 @@ func parseService(service corev1.Service) models.K8sServiceInfo {
|
||||||
for _, status := range service.Status.LoadBalancer.Ingress {
|
for _, status := range service.Status.LoadBalancer.Ingress {
|
||||||
ingressStatus = append(ingressStatus, models.K8sServiceIngress{
|
ingressStatus = append(ingressStatus, models.K8sServiceIngress{
|
||||||
IP: status.IP,
|
IP: status.IP,
|
||||||
Host: status.Hostname,
|
Hostname: status.Hostname,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ func (kcl *KubeClient) convertToK8sService(info models.K8sServiceInfo) corev1.Se
|
||||||
for _, i := range info.IngressStatus {
|
for _, i := range info.IngressStatus {
|
||||||
service.Status.LoadBalancer.Ingress = append(
|
service.Status.LoadBalancer.Ingress = append(
|
||||||
service.Status.LoadBalancer.Ingress,
|
service.Status.LoadBalancer.Ingress,
|
||||||
corev1.LoadBalancerIngress{IP: i.IP, Hostname: i.Host},
|
corev1.LoadBalancerIngress{IP: i.IP, Hostname: i.Hostname},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
import { CellContext } from '@tanstack/react-table';
|
||||||
|
|
||||||
|
import { ServiceRowData } from '../types';
|
||||||
|
|
||||||
|
import { columnHelper } from './helper';
|
||||||
|
|
||||||
|
export const externalHost = columnHelper.accessor(
|
||||||
|
(row) => {
|
||||||
|
if (row.Type === 'ExternalName') {
|
||||||
|
return row.ExternalName || '-';
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
row.IngressStatus?.map((status) => status.Hostname)
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(' ,') || '-'
|
||||||
|
);
|
||||||
|
},
|
||||||
|
{
|
||||||
|
header: 'External Host',
|
||||||
|
id: 'externalHost',
|
||||||
|
cell: Cell,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
function Cell({ row }: CellContext<ServiceRowData, string>) {
|
||||||
|
if (row.original.Type === 'ExternalName') {
|
||||||
|
return <div>{row.original.ExternalName || '-'}</div>;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
{row.original.IngressStatus?.map((status) => status.Hostname)
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(' ,') || '-'}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ import { type } from './type';
|
||||||
import { namespace } from './namespace';
|
import { namespace } from './namespace';
|
||||||
import { ports } from './ports';
|
import { ports } from './ports';
|
||||||
import { clusterIP } from './clusterIP';
|
import { clusterIP } from './clusterIP';
|
||||||
|
import { externalHost } from './externalHost';
|
||||||
import { externalIP } from './externalIP';
|
import { externalIP } from './externalIP';
|
||||||
import { targetPorts } from './targetPorts';
|
import { targetPorts } from './targetPorts';
|
||||||
import { application } from './application';
|
import { application } from './application';
|
||||||
|
@ -16,6 +17,7 @@ export const columns = [
|
||||||
ports,
|
ports,
|
||||||
targetPorts,
|
targetPorts,
|
||||||
clusterIP,
|
clusterIP,
|
||||||
|
externalHost,
|
||||||
externalIP,
|
externalIP,
|
||||||
created,
|
created,
|
||||||
];
|
];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue