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
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,29 @@
/>
</a>
</li>
<li
class="css-1gktw5r"
>
<a
class="MuiButtonBase-root MuiListItemButton-root MuiListItemButton-gutters MuiListItemButton-root MuiListItemButton-gutters css-1op30le-MuiButtonBase-root-MuiListItemButton-root"
href="/"
role="button"
tabindex="0"
>
<div
class="MuiListItemText-root css-tlelie-MuiListItemText-root"
>
<span
class="MuiTypography-root MuiTypography-body1 MuiListItemText-primary css-nqgwvn-MuiTypography-root"
>
Endpoint Slices
</span>
</div>
<span
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
/>
</a>
</li>
<li
class="css-1gktw5r"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,29 @@
/>
</a>
</li>
<li
class="css-1gktw5r"
>
<a
class="MuiButtonBase-root MuiListItemButton-root MuiListItemButton-gutters MuiListItemButton-root MuiListItemButton-gutters css-1op30le-MuiButtonBase-root-MuiListItemButton-root"
href="/"
role="button"
tabindex="0"
>
<div
class="MuiListItemText-root css-tlelie-MuiListItemText-root"
>
<span
class="MuiTypography-root MuiTypography-body1 MuiListItemText-primary css-nqgwvn-MuiTypography-root"
>
Endpoint Slices
</span>
</div>
<span
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
/>
</a>
</li>
<li
class="css-1gktw5r"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,29 @@
/>
</a>
</li>
<li
class="css-1gktw5r"
>
<a
class="MuiButtonBase-root MuiListItemButton-root MuiListItemButton-gutters MuiListItemButton-root MuiListItemButton-gutters css-1op30le-MuiButtonBase-root-MuiListItemButton-root"
href="/"
role="button"
tabindex="0"
>
<div
class="MuiListItemText-root css-tlelie-MuiListItemText-root"
>
<span
class="MuiTypography-root MuiTypography-body1 MuiListItemText-primary css-nqgwvn-MuiTypography-root"
>
Endpoint Slices
</span>
</div>
<span
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
/>
</a>
</li>
<li
class="css-1gktw5r"
>
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/components/Sidebar/useSidebarItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ export const useSidebarItems = (sidebarName: string = DefaultSidebars.IN_CLUSTER
name: 'endpoints',
label: t('glossary|Endpoints'),
},
{
name: 'endpointslices',
label: t('glossary|Endpoint Slices'),
},
{
name: 'ingresses',
label: t('glossary|Ingresses'),
Expand Down
141 changes: 141 additions & 0 deletions frontend/src/components/endpointSlices/Details.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/*
* Copyright 2025 The Kubernetes Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import Box from '@mui/material/Box';
import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router-dom';
import EndpointSlice from '../../lib/k8s/endpointSlices';
import { SectionBox, SimpleTable, StatusLabel } from '../common';
import { DetailsGrid } from '../common/Resource';

export default function EndpointSliceDetails(props: {
name?: string;
namespace?: string;
cluster?: string;
}) {
const params = useParams<{ namespace: string; name: string }>();
const { name = params.name, namespace = params.namespace, cluster } = props;
const { t } = useTranslation(['glossary', 'translation']);

return (
<DetailsGrid
resourceType={EndpointSlice}
name={name}
namespace={namespace}
cluster={cluster}
title={t('Endpoint Slice')}
withEvents
extraInfo={item =>
item && [
{
name: t('translation|Address Type'),
value: item.spec.addressType,
},
]
}
extraSections={(item: EndpointSlice) =>
item && [
{
id: 'headlamp.endpoint-slice-endpoints',
section: (
<SectionBox title={t('Endpoints')}>
<SimpleTable
data={item?.spec.endpoints || []}
columns={[
{
label: t('translation|Hostname'),
datum: 'hostname',
sort: true,
},
{
label: t('translation|Node Name'),
datum: 'nodeName',
sort: true,
},
{
label: t('translation|Zone'),
datum: 'zone',
sort: true,
},
{
label: t('Addresses'),
getter: endpoint => endpoint.addresses?.join(','),
},
{
label: t('Conditions'),
getter: endpoint => (
<>
<Box display="inline-block">
<StatusLabel status={endpoint.conditions.ready ? 'success' : 'error'}>
{t('Ready')}
</StatusLabel>
</Box>
<Box display="inline-block">
<StatusLabel status={endpoint.conditions.serving ? 'success' : 'error'}>
{t('Serving')}
</StatusLabel>
</Box>
<Box display="inline-block">
<StatusLabel
status={endpoint.conditions.terminating ? 'success' : 'error'}
>
{t('Terminating')}
</StatusLabel>
</Box>
</>
),
},
]}
defaultSortingColumn={1}
reflectInURL="endpoints"
/>
</SectionBox>
),
},
{
id: 'headlamp.endpoint-slice-ports',
section: (
<SectionBox title={t('Ports')}>
<SimpleTable
data={item?.spec.ports || []}
columns={[
{
label: t('translation|Name'),
datum: 'name',
sort: true,
},
{
label: t('Port'),
datum: 'port',
sort: true,
},
{
label: t('Protocol'),
datum: 'protocol',
sort: true,
},
]}
defaultSortingColumn={1}
reflectInURL="ports"
/>
</SectionBox>
),
},
]
}
/>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/*
* Copyright 2025 The Kubernetes Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { Meta, StoryFn } from '@storybook/react';
import { http, HttpResponse } from 'msw';
import { TestContext } from '../../test';
import EndpointSliceDetails from './Details';

export default {
title: 'endpointslice/EndpointSliceDetailsView',
component: EndpointSliceDetails,
argTypes: {},
parameters: {
msw: {
handlers: {
storyBase: [
http.get('http://localhost:4466/apis/discovery.k8s.io/v1/endpointslices', () =>
HttpResponse.error()
),
http.get('http://localhost:4466/api/v1/namespaces/my-namespace/events', () =>
HttpResponse.error()
),
],
},
},
},
} as Meta;

const Template: StoryFn = () => {
return (
<TestContext routerMap={{ namespace: 'my-namespace', name: 'my-endpoint' }}>
<EndpointSliceDetails />
</TestContext>
);
};

export const Default = Template.bind({});
Default.parameters = {
msw: {
handlers: {
story: [
http.get(
'http://localhost:4466/apis/discovery.k8s.io/v1/namespaces/my-namespace/endpointslices/my-endpoint',
() =>
HttpResponse.json({
kind: 'EndpointSlice',
apiVersion: 'discovery.k8s.io/v1',
metadata: {
name: 'my-endpoint',
namespace: 'my-namespace',
uid: 'phony',
creationTimestamp: new Date('2020-04-25').toISOString(),
resourceVersion: '1',
selfLink: '0',
},
endpoints: [
{
addresses: ['127.0.0.1'],
nodeName: 'mynode',
targetRef: {
kind: 'Pod',
namespace: 'MyNamespace',
name: 'mypod',
uid: 'phony-pod',
resourceVersion: '1',
apiVersion: 'v1',
},
},
{
addresses: ['127.0.0.2'],
nodeName: 'mynode',
targetRef: {
kind: 'Pod',
namespace: 'MyNamespace',
name: 'mypod-1',
uid: 'phony-pod-1',
resourceVersion: '1',
apiVersion: 'v1',
},
},
],
ports: [
{
name: 'myport',
port: 8080,
protocol: 'TCP',
},
],
})
),
],
},
},
};

export const Error = Template.bind({});
Error.parameters = {
msw: {
handlers: {
story: [
http.get(
'http://localhost:4466/apis/discovery.k8s.io/v1/namespaces/my-namespace/endpointslices/my-endpoint',
() => HttpResponse.error()
),
],
},
},
};
Loading
Loading