mirror of
				https://github.com/karl0ss/homepage.git
				synced 2025-11-04 08:20:58 +00:00 
			
		
		
		
	Enhancement: support instanceName filtering for kubernetes deployment (#2488)
				
					
				
			--------- Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									30e4a2ae3a
								
							
						
					
					
						commit
						eea20defb1
					
				@ -79,6 +79,7 @@ metadata:
 | 
			
		||||
    gethomepage.dev/widget.url: "https://emby.example.com"
 | 
			
		||||
    gethomepage.dev/pod-selector: ""
 | 
			
		||||
    gethomepage.dev/weight: 10 # optional
 | 
			
		||||
    gethomepage.dev/instance: "public" # optional
 | 
			
		||||
spec:
 | 
			
		||||
  rules:
 | 
			
		||||
    - host: emby.example.com
 | 
			
		||||
@ -95,6 +96,8 @@ spec:
 | 
			
		||||
 | 
			
		||||
When the Kubernetes cluster connection has been properly configured, this service will be automatically discovered and added to your Homepage. **You do not need to specify the `namespace` or `app` values, as they will be automatically inferred.**
 | 
			
		||||
 | 
			
		||||
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.
 | 
			
		||||
 | 
			
		||||
### 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:
 | 
			
		||||
@ -116,6 +119,7 @@ metadata:
 | 
			
		||||
    gethomepage.dev/widget.url: "https://emby.example.com"
 | 
			
		||||
    gethomepage.dev/pod-selector: ""
 | 
			
		||||
    gethomepage.dev/weight: 10 # optional
 | 
			
		||||
    gethomepage.dev/instance: "public" # optional
 | 
			
		||||
spec:
 | 
			
		||||
  entryPoints:
 | 
			
		||||
    - websecure
 | 
			
		||||
 | 
			
		||||
@ -169,6 +169,7 @@ export async function checkCRD(kc, name) {
 | 
			
		||||
export async function servicesFromKubernetes() {
 | 
			
		||||
  const ANNOTATION_BASE = "gethomepage.dev";
 | 
			
		||||
  const ANNOTATION_WIDGET_BASE = `${ANNOTATION_BASE}/widget.`;
 | 
			
		||||
  const { instanceName } = getSettings();
 | 
			
		||||
 | 
			
		||||
  checkAndCopyConfig("kubernetes.yaml");
 | 
			
		||||
 | 
			
		||||
@ -238,7 +239,10 @@ export async function servicesFromKubernetes() {
 | 
			
		||||
    const services = ingressList.items
 | 
			
		||||
      .filter(
 | 
			
		||||
        (ingress) =>
 | 
			
		||||
          ingress.metadata.annotations && ingress.metadata.annotations[`${ANNOTATION_BASE}/enabled`] === "true",
 | 
			
		||||
          ingress.metadata.annotations &&
 | 
			
		||||
          ingress.metadata.annotations[`${ANNOTATION_BASE}/enabled`] === "true" &&
 | 
			
		||||
          (!ingress.metadata.annotations[`${ANNOTATION_BASE}/instance`] ||
 | 
			
		||||
            ingress.metadata.annotations[`${ANNOTATION_BASE}/instance`] === instanceName),
 | 
			
		||||
      )
 | 
			
		||||
      .map((ingress) => {
 | 
			
		||||
        let constructedService = {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user