From 2730721414e46ec9b2de2cb448eb41b17c7afed8 Mon Sep 17 00:00:00 2001 From: atropos Date: Mon, 28 Aug 2023 18:20:12 +0100 Subject: [PATCH] Making both Containo and Io work regardless if they are both present or not --- src/utils/config/service-helpers.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/utils/config/service-helpers.js b/src/utils/config/service-helpers.js index cabe386a..b7ebddaa 100644 --- a/src/utils/config/service-helpers.js +++ b/src/utils/config/service-helpers.js @@ -158,22 +158,26 @@ export async function servicesFromKubernetes() { return null; }); - const traefikIngressList = await crd.listClusterCustomObject("traefik.io", "v1alpha1", "ingressroutes") + const traefikIngressListContaino = await crd.listClusterCustomObject("traefik.containo.us", "v1alpha1", "ingressroutes") .then((response) => response.body) .catch(async (error) => { - logger.error("Error getting traefik ingresses from traefik.io: %d %s %s", error.statusCode, error.body, error.response); + if (error.statusCode != 404) { + logger.error("Error getting traefik ingresses from traefik.containo.us: %d %s %s", error.statusCode, error.body, error.response); + } - // Fallback to the old traefik CRD group - const fallbackIngressList = await crd.listClusterCustomObject("traefik.containo.us", "v1alpha1", "ingressroutes") - .then((response) => response.body) - .catch((fallbackError) => { - logger.error("Error getting traefik ingresses from traefik.containo.us: %d %s %s", fallbackError.statusCode, fallbackError.body, fallbackError.response); - return null; - }); - - return fallbackIngressList; + return null; }); + const traefikIngressListIo = await crd.listClusterCustomObject("traefik.io", "v1alpha1", "ingressroutes") + .then((response) => response.body) + .catch(async (error) => { + if (error.statusCode != 404) { + logger.error("Error getting traefik ingresses from traefik.io: %d %s %s", error.statusCode, error.body, error.response); + } return null; + }); + + const traefikIngressList = [...new Set([...(traefikIngressListContaino || []), ...(traefikIngressListIo || [])])]; + if (traefikIngressList && traefikIngressList.items.length > 0) { const traefikServices = traefikIngressList.items .filter((ingress) => ingress.metadata.annotations && ingress.metadata.annotations[`${ANNOTATION_BASE}/href`])