forked from labring/sealos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
为kubepanel network 添加service (labring#4705)
* 为kubepanel network 添加service 前端页面部分 * kubepanel添加service 后端接口新增 kubepanel添加service 后端接口新增 * 修改 撤回配置文件 * 撤回配置 * 撤回 * 撤回 * Update go.work.sum * Update pnpm-lock.yaml * Update pnpm-lock.yaml
- Loading branch information
1 parent
9c17847
commit 7974ba5
Showing
9 changed files
with
179 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
...nd/providers/kubepanel/src/pages/kubepanel/kube-object/network/service/service-detail.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { KubeObjectInfoList } from '@/components/kube/object/detail/kube-object-detail-info-list'; | ||
import { | ||
ComputedIngressRoute, | ||
ILoadBalancerIngress, | ||
Service, | ||
computeRuleDeclarations | ||
} from '@/k8slens/kube-object'; | ||
import { DrawerPanel } from '@/components/common/drawer/drawer-panel'; | ||
import { Drawer } from '@/components/common/drawer/drawer'; | ||
import { DrawerItem } from '@/components/common/drawer/drawer-item'; | ||
import { Button, Table } from 'antd'; | ||
import { ColumnsType } from 'antd/lib/table'; | ||
|
||
const rulesColumns: ColumnsType<ComputedIngressRoute> = [ | ||
{ | ||
key: 'path', | ||
title: 'Path', | ||
dataIndex: 'pathname', | ||
render: (pathname: string) => (pathname === '' ? '_' : pathname) | ||
}, | ||
{ | ||
key: 'link', | ||
title: 'Link', | ||
render: (_, { displayAsLink, url }) => | ||
displayAsLink ? ( | ||
<Button | ||
href={url} | ||
rel="noreferrer" | ||
target="_blank" | ||
type="link" | ||
onClick={(e) => e.stopPropagation()} | ||
> | ||
{url} | ||
</Button> | ||
) : ( | ||
url | ||
) | ||
}, | ||
{ | ||
key: 'backends', | ||
title: 'Backends', | ||
dataIndex: 'service' | ||
} | ||
]; | ||
|
||
const pointsColumns: ColumnsType<ILoadBalancerIngress> = [ | ||
{ | ||
key: 'hostname', | ||
title: 'Hostname', | ||
dataIndex: 'hostname', | ||
render: (hostname?: string) => (hostname ? '_' : hostname) | ||
}, | ||
{ | ||
key: 'ip', | ||
title: 'IP', | ||
dataIndex: 'ip', | ||
render: (ip?: string) => (ip ? '_' : ip) | ||
} | ||
]; | ||
|
||
const IngressPoints = ({ points }: { points?: ILoadBalancerIngress[] }) => { | ||
if (!points || points.length === 0) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Table size="small" bordered columns={pointsColumns} dataSource={points} pagination={false} /> | ||
); | ||
}; | ||
|
||
const ServiceDetail = ({ obj: service, open, onClose }: DetailDrawerProps<Service>) => { | ||
if (!service || !(service instanceof Service)) return null; | ||
return ( | ||
<Drawer open={open} title={`Service: ${service.getName()}`} onClose={onClose}> | ||
<DrawerPanel> | ||
<KubeObjectInfoList obj={service} /> | ||
<DrawerItem name="Cluster IP" value={service.getClusterIp()} /> | ||
<DrawerItem name="External IPs" value={service.getExternalIps().join(", ")} /> | ||
<DrawerItem name="Type" value={service.getType()} /> | ||
<DrawerItem name="Ports" value={service.getPorts().map(port => port.toString()).join(", ")} /> | ||
{/* Add other relevant details here */} | ||
</DrawerPanel> | ||
</Drawer> | ||
) | ||
}; | ||
|
||
export default ServiceDetail; |
66 changes: 66 additions & 0 deletions
66
frontend/providers/kubepanel/src/pages/kubepanel/kube-object/network/service/service.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { KubeObjectAge } from '@/components/kube/object/kube-object-age'; | ||
import { KubeObject,KubeObjectMetadata,KubeObjectScope,Service, computeRouteDeclarations } from '@/k8slens/kube-object'; | ||
import { ColumnsType } from 'antd/lib/table'; | ||
import { useServiceStore } from '@/store/kube'; | ||
import { Button } from 'antd'; | ||
import ServiceDetail from './service-detail'; | ||
import { PanelTable } from '@/components/common/panel-table/table'; | ||
import { ActionButton } from '@/components/common/action/action-button'; | ||
|
||
const columns: ColumnsType<Service> = [ | ||
{ | ||
title: 'ClusterIps', | ||
key: 'ClusterIps', | ||
render: (_, service: Service) => service.getClusterIps().map(ip => <p key={ip}>{ip}</p>) | ||
}, | ||
{ | ||
title: 'Type', | ||
key: 'type', | ||
render: (_, service: Service) => <span>{service.getType()}</span> | ||
}, | ||
{ | ||
title: 'Selector', | ||
key: 'selector', | ||
render: (_, service: Service) => service.getSelector().map(selector => <p key={selector}>{selector}</p>) | ||
}, | ||
{ | ||
title: 'Ports', | ||
key: 'ports', | ||
render: (_, service: Service) => | ||
service.getPorts().map(port => ( | ||
<div key={port.toString()} className="overflow-hidden"> | ||
{port.toString()} | ||
</div> | ||
)) | ||
}, | ||
{ | ||
title: 'Load Balancer IPs', | ||
key: 'load-balancer-ips', | ||
render: (_, service: Service) => service.getExternalIps().map(ip => <p key={ip}>{ip}</p>) | ||
}, | ||
{ | ||
title: 'Status', | ||
key: 'status', | ||
render: (_, service: Service) => <span>{service.getStatus()}</span> | ||
}, | ||
]; | ||
|
||
const ServiceOverviewPage = () => { | ||
const { items, initialize, isLoaded, watch } = useServiceStore(); | ||
|
||
return ( | ||
<PanelTable | ||
columns={columns} | ||
dataSource={items} | ||
loading={!isLoaded} | ||
sectionTitle="service" | ||
DetailDrawer={ServiceDetail} | ||
getRowKey={(service) => service.getId()} | ||
initializers={[initialize]} | ||
watchers={[watch]} | ||
getDetailItem={(service) => service} | ||
/> | ||
); | ||
}; | ||
|
||
export default ServiceOverviewPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ServiceStore} from '@/types/state'; | ||
import { create } from 'zustand'; | ||
import { createKubeStoreSlice } from './kube.store'; | ||
import { Service } from '@/k8slens/kube-object'; | ||
|
||
export const useServiceStore = create<ServiceStore>()((...a) => ({ | ||
...createKubeStoreSlice<Service>(Service.kind, Service)(...a) | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters