From bb5cdfedffc2ab0057d3083d80b4781d8915723b Mon Sep 17 00:00:00 2001 From: Aldy J Date: Wed, 5 Jun 2024 09:21:39 +0700 Subject: [PATCH] Support multiple instance annotation for Kubernetes Automatic Service Discovery --- 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 6ba995c49ec..c76813f4793 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 8e2f12d5419..7de077bffb5 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 = {