From 35dd7ec230fa5f7863d016e2acc91d13de584cf8 Mon Sep 17 00:00:00 2001 From: Aldy J Date: Wed, 5 Jun 2024 11:29:13 +0700 Subject: [PATCH] Enhancement: support multiple instance annotation for Kubernetes Automatic Service Discovery (#3590) --- docs/configs/kubernetes.md | 2 ++ src/utils/config/service-helpers.js | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/configs/kubernetes.md b/docs/configs/kubernetes.md index 6ba995c49..c76813f47 100644 --- a/docs/configs/kubernetes.md +++ b/docs/configs/kubernetes.md @@ -98,6 +98,8 @@ When the Kubernetes cluster connection has been properly configured, this servic If you are using multiple instances of homepage, an `instance` annotation can be specified to limit services to a specific instance. If no instance is provided, the service will be visible on all instances. +If you have a single service that needs to be shown on multiple specific instances of homepage (but not on all of them), the service can be annotated by multiple `instance.name` annotations, where `name` can be the names of your specific multiple homepage instances. For example, a service that is annotated with `gethomepage.dev/instance.public: ""` and `gethomepage.dev/instance.internal: ""` will be shown on `public` and `internal` homepage instances. + ### Traefik IngressRoute support Homepage can also read ingresses defined using the Traefik IngressRoute custom resource definition. Due to the complex nature of Traefik routing rules, it is required for the `gethomepage.dev/href` annotation to be set: diff --git a/src/utils/config/service-helpers.js b/src/utils/config/service-helpers.js index 8e2f12d54..7de077bff 100644 --- a/src/utils/config/service-helpers.js +++ b/src/utils/config/service-helpers.js @@ -254,7 +254,8 @@ export async function servicesFromKubernetes() { ingress.metadata.annotations && ingress.metadata.annotations[`${ANNOTATION_BASE}/enabled`] === "true" && (!ingress.metadata.annotations[`${ANNOTATION_BASE}/instance`] || - ingress.metadata.annotations[`${ANNOTATION_BASE}/instance`] === instanceName), + ingress.metadata.annotations[`${ANNOTATION_BASE}/instance`] === instanceName || + `${ANNOTATION_BASE}/instance.${instanceName}` in ingress.metadata.annotations), ) .map((ingress) => { let constructedService = {