Skip to content

Commit

Permalink
Merge pull request #1161 from MrLemur/add-traefik-ingressroute
Browse files Browse the repository at this point in the history
Feature: Add Traefik IngressRoute support for Kubernetes
  • Loading branch information
shamoon authored Apr 4, 2023
2 parents 8378066 + df714c7 commit a0fa636
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/utils/config/service-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import path from "path";
import yaml from "js-yaml";
import Docker from "dockerode";
import * as shvl from "shvl";
import { NetworkingV1Api } from "@kubernetes/client-node";
import { CustomObjectsApi, NetworkingV1Api } from "@kubernetes/client-node";

import createLogger from "utils/logger";
import checkAndCopyConfig, { substituteEnvironmentVars } from "utils/config/config";
Expand Down Expand Up @@ -145,13 +145,28 @@ export async function servicesFromKubernetes() {
return [];
}
const networking = kc.makeApiClient(NetworkingV1Api);
const crd = kc.makeApiClient(CustomObjectsApi);

const ingressList = await networking.listIngressForAllNamespaces(null, null, null, null)
.then((response) => response.body)
.catch((error) => {
logger.error("Error getting ingresses: %d %s %s", error.statusCode, error.body, error.response);
return null;
});

const traefikIngressList = await crd.listClusterCustomObject("traefik.containo.us", "v1alpha1", "ingressroutes")
.then((response) => response.body)
.catch((error) => {
logger.error("Error getting traefik ingresses: %d %s %s", error.statusCode, error.body, error.response);
return null;
});

if (traefikIngressList && traefikIngressList.items.length > 0) {
const traefikServices = traefikIngressList.items
.filter((ingress) => ingress.metadata.annotations && ingress.metadata.annotations[`${ANNOTATION_BASE}/href`])
ingressList.items.push(...traefikServices);
}

if (!ingressList) {
return [];
}
Expand Down

0 comments on commit a0fa636

Please sign in to comment.