Skip to content

Commit b8c217a

Browse files
fix(topology): adds check on service and routes to match same namespace as workloads (#1389)
fix(topology): adds check on service and routes to match same namespace as worloads
1 parent bf23e4a commit b8c217a

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

plugins/topology/src/__fixtures__/1-deployments.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export const customResourceRoute = {
22
metadata: {
33
name: 'hello-minikube2',
4-
namespace: 'jai-test',
4+
namespace: 'test-app',
55
uid: '17c0f520-3878-4834-96a1-b19854f0d06f',
66
resourceVersion: '174049',
77
creationTimestamp: '2023-05-22T08:14:25Z',

plugins/topology/src/utils/resource-utils.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ export const getServicesForResource = (
106106
}
107107
const template = getPodTemplate(resource);
108108
return services.filter((service: V1Service) => {
109+
if (resource.metadata?.namespace !== service.metadata?.namespace)
110+
return false;
109111
const specSelector = service.spec?.selector || {};
110112
const selector = new LabelSelector(specSelector);
111113
return selector.matches(template);
@@ -262,7 +264,11 @@ export const getRoutesDataForResourceServices = (
262264

263265
const routesData: RoutesData = routes.reduce(
264266
(acc: RoutesData, route: RouteKind) => {
265-
if (route.spec?.to?.name && servicesNames.includes(route.spec.to.name)) {
267+
if (
268+
route.spec?.to?.name &&
269+
servicesNames.includes(route.spec.to.name) &&
270+
resource.metadata?.namespace === route.metadata?.namespace
271+
) {
266272
acc.push({
267273
route,
268274
url: getRouteWebURL(route),

0 commit comments

Comments
 (0)