Skip to content

Commit 0609d63

Browse files
authored
Merge pull request #3776 from userAdityaa/gateway
frontend: MapView: Build MapView for Gateway API
2 parents 4f43cbd + 59db9b7 commit 0609d63

File tree

17 files changed

+137
-38
lines changed

17 files changed

+137
-38
lines changed

frontend/src/components/gateway/ClassDetails.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ import GatewayClass, { KubeGatewayClass } from '../../lib/k8s/gatewayClass';
2020
import { ConditionsTable, DetailsGrid } from '../common/Resource';
2121
import SectionBox from '../common/SectionBox';
2222

23-
export default function GatewayClassDetails() {
24-
const { name } = useParams<{ name: string }>();
23+
export default function GatewayClassDetails(props: { name?: string }) {
24+
const params = useParams<{ name: string }>();
25+
const { name = params.name } = props;
2526
const { t } = useTranslation(['glossary', 'translation']);
2627

2728
return (

frontend/src/components/resourceMap/details/KubeNodeDetails.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ import CustomResourceDefinitionDetails from '../../crd/Details';
2525
import CronJobDetails from '../../cronjob/Details';
2626
import DaemonSetDetails from '../../daemonset/Details';
2727
import EndpointDetails from '../../endpoints/Details';
28+
import BackendTLSPolicyDetails from '../../gateway/BackendTLSPolicyDetails';
29+
import GatewayClassDetails from '../../gateway/ClassDetails';
30+
import GatewayDetails from '../../gateway/GatewayDetails';
31+
import GRPCRouteDetails from '../../gateway/GRPCRouteDetails';
32+
import HTTPRouteDetails from '../../gateway/HTTPRouteDetails';
33+
import ReferenceGrantDetails from '../../gateway/ReferenceGrantDetails';
2834
import HpaDetails from '../../horizontalPodAutoscaler/Details';
2935
import IngressClassDetails from '../../ingress/ClassDetails';
3036
import IngressDetails from '../../ingress/Details';
@@ -91,6 +97,13 @@ const kindComponentMap: Record<
9197
IngressClass: IngressClassDetails,
9298
CustomResourceDefinition: CustomResourceDefinitionDetails,
9399
crd: CustomResourceDefinitionDetails,
100+
Gateway: GatewayDetails,
101+
GatewayClass: GatewayClassDetails,
102+
HTTPRoute: HTTPRouteDetails,
103+
GRPCRoute: GRPCRouteDetails,
104+
ReferenceGrant: ReferenceGrantDetails,
105+
BackendTLSPolicy: BackendTLSPolicyDetails,
106+
XBackendTrafficPolicy: BackendTLSPolicyDetails,
94107
};
95108

96109
export const canRenderDetails = (maybeKind: string) =>

frontend/src/components/resourceMap/kubeIcon/img/gateway.svg

Lines changed: 14 additions & 0 deletions
Loading

frontend/src/components/resourceMap/sources/definitions/relations.tsx

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,18 @@
1515
*/
1616

1717
import { useMemo } from 'react';
18+
import BackendTLSPolicy from '../../../../lib/k8s/backendTLSPolicy';
19+
import BackendTrafficPolicy from '../../../../lib/k8s/backendTrafficPolicy';
1820
import ConfigMap from '../../../../lib/k8s/configMap';
1921
import CustomResourceDefinition from '../../../../lib/k8s/crd';
2022
import CronJob from '../../../../lib/k8s/cronJob';
2123
import DaemonSet from '../../../../lib/k8s/daemonSet';
2224
import Deployment from '../../../../lib/k8s/deployment';
2325
import Endpoints from '../../../../lib/k8s/endpoints';
26+
import Gateway from '../../../../lib/k8s/gateway';
27+
import GatewayClass from '../../../../lib/k8s/gatewayClass';
2428
import HPA from '../../../../lib/k8s/hpa';
29+
import HTTPRoute from '../../../../lib/k8s/httpRoute';
2530
import Ingress from '../../../../lib/k8s/ingress';
2631
import Job from '../../../../lib/k8s/job';
2732
import { KubeObject, KubeObjectClass } from '../../../../lib/k8s/KubeObject';
@@ -221,6 +226,38 @@ const jobToCronJob = makeRelation(Job, CronJob, (job, cronJob) =>
221226
job.metadata.ownerReferences?.find(owner => owner.uid === cronJob.metadata.uid)
222227
);
223228

229+
const gatewayToGatewayClass = makeRelation(
230+
Gateway,
231+
GatewayClass,
232+
(gateway, gatewayClass) => gateway.spec.gatewayClassName === gatewayClass.metadata.name
233+
);
234+
235+
const httpRouteToGateway = makeRelation(HTTPRoute, Gateway, (httpRoute, gateway) =>
236+
httpRoute.spec.parentRefs?.find(ref => ref.name === gateway.metadata.name)
237+
);
238+
239+
const httpRouteToService = makeRelation(HTTPRoute, Service, (httpRoute, service) =>
240+
httpRoute.spec.rules?.find(rule =>
241+
rule.backendRefs?.find(backend => backend.name === service.metadata.name)
242+
)
243+
);
244+
245+
const backendTLSPolicyToService = makeRelation(
246+
BackendTLSPolicy,
247+
Service,
248+
(tlsPolicy, service) =>
249+
tlsPolicy.spec.targetRef?.name === service.metadata.name &&
250+
tlsPolicy.spec.targetRef?.kind === 'Service'
251+
);
252+
253+
const backendTrafficPolicyToService = makeRelation(
254+
BackendTrafficPolicy,
255+
Service,
256+
(trafficPolicy, service) =>
257+
trafficPolicy.spec.targetRef?.name === service.metadata.name &&
258+
trafficPolicy.spec.targetRef?.kind === 'Service'
259+
);
260+
224261
export function useGetAllRelations(): Relation[] {
225262
const staticRelations = [
226263
configMapUsedInPods,
@@ -244,6 +281,11 @@ export function useGetAllRelations(): Relation[] {
244281
podToOwner,
245282
repliaceSetToOwner,
246283
jobToCronJob,
284+
gatewayToGatewayClass,
285+
httpRouteToGateway,
286+
httpRouteToService,
287+
backendTLSPolicyToService,
288+
backendTrafficPolicyToService,
247289
];
248290

249291
const crdRelations = useGetCRToOwnerRelations();

frontend/src/components/resourceMap/sources/definitions/sources.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,19 @@
1616

1717
import { Icon } from '@iconify/react';
1818
import React, { useMemo } from 'react';
19+
import BackendTLSPolicy from '../../../../lib/k8s/backendTLSPolicy';
20+
import BackendTrafficPolicy from '../../../../lib/k8s/backendTrafficPolicy';
1921
import ConfigMap from '../../../../lib/k8s/configMap';
2022
import CRD from '../../../../lib/k8s/crd';
2123
import CronJob from '../../../../lib/k8s/cronJob';
2224
import DaemonSet from '../../../../lib/k8s/daemonSet';
2325
import Deployment from '../../../../lib/k8s/deployment';
2426
import Endpoints from '../../../../lib/k8s/endpoints';
27+
import Gateway from '../../../../lib/k8s/gateway';
28+
import GatewayClass from '../../../../lib/k8s/gatewayClass';
29+
import GRPCRoute from '../../../../lib/k8s/grpcRoute';
2530
import HPA from '../../../../lib/k8s/hpa';
31+
import HTTPRoute from '../../../../lib/k8s/httpRoute';
2632
import Ingress from '../../../../lib/k8s/ingress';
2733
import IngressClass from '../../../../lib/k8s/ingressClass';
2834
import Job from '../../../../lib/k8s/job';
@@ -31,6 +37,7 @@ import MutatingWebhookConfiguration from '../../../../lib/k8s/mutatingWebhookCon
3137
import NetworkPolicy from '../../../../lib/k8s/networkpolicy';
3238
import PersistentVolumeClaim from '../../../../lib/k8s/persistentVolumeClaim';
3339
import Pod from '../../../../lib/k8s/pod';
40+
import ReferenceGrant from '../../../../lib/k8s/referenceGrant';
3441
import ReplicaSet from '../../../../lib/k8s/replicaSet';
3542
import Role from '../../../../lib/k8s/role';
3643
import RoleBinding from '../../../../lib/k8s/roleBinding';
@@ -174,6 +181,28 @@ export function useGetAllSources(): GraphSource[] {
174181
// leases
175182
],
176183
},
184+
{
185+
id: 'gateway-beta',
186+
label: 'Gateway (beta)',
187+
icon: (
188+
<Icon
189+
icon="mdi:lan-connect"
190+
width="100%"
191+
height="100%"
192+
color={getKindGroupColor('network')}
193+
/>
194+
),
195+
isEnabledByDefault: false,
196+
sources: [
197+
makeKubeSource(GatewayClass),
198+
makeKubeSource(Gateway),
199+
makeKubeSource(HTTPRoute),
200+
makeKubeSource(GRPCRoute),
201+
makeKubeSource(ReferenceGrant),
202+
makeKubeSource(BackendTLSPolicy),
203+
makeKubeSource(BackendTrafficPolicy),
204+
],
205+
},
177206
];
178207

179208
if (CustomResourceDefinition !== null) {

frontend/src/i18n/locales/de/app.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@
4141
"Help": "Hilfe",
4242
"Documentation": "Dokumentation",
4343
"Open an Issue": "Ein Problem melden",
44-
"Invalid URL": "Ungültige URL",
45-
"Application opened with an invalid URL: {{ url }}": "Anwendung mit einer ungültigen URL geöffnet: {{ url }}",
4644
"Another process is running": "Ein anderer Prozess läuft",
4745
"Looks like another process is already running. Continue by terminating that process automatically, or quit?": "Es sieht so aus, als ob bereits ein anderer Prozess läuft. Fortfahren, indem Sie diesen Prozess automatisch beenden, oder beenden?",
4846
"Continue": "Weiter",
4947
"Failed to quit the other running process": "Konnte den anderen laufenden Prozess nicht beenden",
50-
"Could not quit the other running process, PIDs: {{ process_list }}. Please stop that process and relaunch the app.": "Konnte den anderen laufenden Prozess nicht beenden, PIDs: {{ process_list }}. Bitte stoppen Sie diesen Prozess und starten Sie die App neu."
48+
"Could not quit the other running process, PIDs: {{ process_list }}. Please stop that process and relaunch the app.": "Konnte den anderen laufenden Prozess nicht beenden, PIDs: {{ process_list }}. Bitte stoppen Sie diesen Prozess und starten Sie die App neu.",
49+
"Invalid URL": "Ungültige URL",
50+
"Application opened with an invalid URL: {{ url }}": "Anwendung mit einer ungültigen URL geöffnet: {{ url }}"
5151
}

frontend/src/i18n/locales/en/app.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@
4141
"Help": "Help",
4242
"Documentation": "Documentation",
4343
"Open an Issue": "Open an Issue",
44-
"Invalid URL": "Invalid URL",
45-
"Application opened with an invalid URL: {{ url }}": "Application opened with an invalid URL: {{ url }}",
4644
"Another process is running": "Another process is running",
4745
"Looks like another process is already running. Continue by terminating that process automatically, or quit?": "Looks like another process is already running. Continue by terminating that process automatically, or quit?",
4846
"Continue": "Continue",
4947
"Failed to quit the other running process": "Failed to quit the other running process",
50-
"Could not quit the other running process, PIDs: {{ process_list }}. Please stop that process and relaunch the app.": "Could not quit the other running process, PIDs: {{ process_list }}. Please stop that process and relaunch the app."
48+
"Could not quit the other running process, PIDs: {{ process_list }}. Please stop that process and relaunch the app.": "Could not quit the other running process, PIDs: {{ process_list }}. Please stop that process and relaunch the app.",
49+
"Invalid URL": "Invalid URL",
50+
"Application opened with an invalid URL: {{ url }}": "Application opened with an invalid URL: {{ url }}"
5151
}

frontend/src/i18n/locales/es/app.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@
4141
"Help": "Ayuda",
4242
"Documentation": "Documentación",
4343
"Open an Issue": "Abrir un incidente",
44-
"Invalid URL": "URL inválida",
45-
"Application opened with an invalid URL: {{ url }}": "Aplicación abierta con una URL inválida: {{ url }}",
4644
"Another process is running": "Un otro proceso está corriendo",
4745
"Looks like another process is already running. Continue by terminating that process automatically, or quit?": "Parece que ya hay un otro proceso corriendo. Continuar y terminar el proceso automaticamente ou salir?",
4846
"Continue": "Continuar",
4947
"Failed to quit the other running process": "Fallo al quitar el otro proceso en ejecución",
50-
"Could not quit the other running process, PIDs: {{ process_list }}. Please stop that process and relaunch the app.": "No se ha podido terminar el otro proceso, PIDs: {{ process_list }}. Por favor, termine el otro proceso y vuelva a lanzar la aplicación."
48+
"Could not quit the other running process, PIDs: {{ process_list }}. Please stop that process and relaunch the app.": "No se ha podido terminar el otro proceso, PIDs: {{ process_list }}. Por favor, termine el otro proceso y vuelva a lanzar la aplicación.",
49+
"Invalid URL": "URL inválida",
50+
"Application opened with an invalid URL: {{ url }}": "Aplicación abierta con una URL inválida: {{ url }}"
5151
}

frontend/src/i18n/locales/fr/app.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@
4141
"Help": "Aide",
4242
"Documentation": "Documentation",
4343
"Open an Issue": "Ouvrir un problème",
44-
"Invalid URL": "URL invalide",
45-
"Application opened with an invalid URL: {{ url }}": "Application ouverte avec une URL invalide : {{ url }}",
4644
"Another process is running": "Un autre processus est en cours",
4745
"Looks like another process is already running. Continue by terminating that process automatically, or quit?": "Il semble qu'un autre processus soit déjà en cours. Continuer en terminant ce processus automatiquement, ou quitter ?",
4846
"Continue": "Continuer",
4947
"Failed to quit the other running process": "Échec de la fermeture de l'autre processus en cours",
50-
"Could not quit the other running process, PIDs: {{ process_list }}. Please stop that process and relaunch the app.": "Impossible de quitter l'autre processus en cours, PIDs : {{ process_list }}. Veuillez arrêter ce processus et relancer l'application."
48+
"Could not quit the other running process, PIDs: {{ process_list }}. Please stop that process and relaunch the app.": "Impossible de quitter l'autre processus en cours, PIDs : {{ process_list }}. Veuillez arrêter ce processus et relancer l'application.",
49+
"Invalid URL": "URL invalide",
50+
"Application opened with an invalid URL: {{ url }}": "Application ouverte avec une URL invalide : {{ url }}"
5151
}

frontend/src/i18n/locales/hi/app.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@
4141
"Help": "सहायता",
4242
"Documentation": "दस्तावेज़ीकरण",
4343
"Open an Issue": "एक इशू खोलें",
44-
"Invalid URL": "अमान्य URL",
45-
"Application opened with an invalid URL: {{ url }}": "अनुप्रयोग एक अमान्य URL के साथ खोला गया: {{ url }}",
4644
"Another process is running": "एक अन्य प्रक्रिया चल रही है",
4745
"Looks like another process is already running. Continue by terminating that process automatically, or quit?": "लगता है कि एक अन्य प्रक्रिया पहले से ही चल रही है। उस प्रक्रिया को स्वचालित रूप से समाप्त करके जारी रखें, या बाहर निकलें?",
4846
"Continue": "जारी रखें",
4947
"Failed to quit the other running process": "अन्य चल रही प्रक्रिया से बाहर निकलने में विफल",
50-
"Could not quit the other running process, PIDs: {{ process_list }}. Please stop that process and relaunch the app.": "अन्य चल रही प्रक्रिया से बाहर नहीं निकल सका, PIDs: {{ process_list }}। कृपया उस प्रक्रिया को रोकें और ऐप को फिर से लॉन्च करें।"
48+
"Could not quit the other running process, PIDs: {{ process_list }}. Please stop that process and relaunch the app.": "अन्य चल रही प्रक्रिया से बाहर नहीं निकल सका, PIDs: {{ process_list }}। कृपया उस प्रक्रिया को रोकें और ऐप को फिर से लॉन्च करें।",
49+
"Invalid URL": "अमान्य URL",
50+
"Application opened with an invalid URL: {{ url }}": "अनुप्रयोग एक अमान्य URL के साथ खोला गया: {{ url }}"
5151
}

0 commit comments

Comments
 (0)