Skip to content

Commit 7782462

Browse files
committed
Enhance Dashboard functionality with advanced filtering options: Introduce selectors for Gateway, HTTPRoute, and Ingress resources, along with domain filtering capabilities. Update README to include comprehensive examples and documentation for new features. Modify controllers to support filtering logic based on user-defined criteria, improving resource management in Kubernetes.
1 parent fbe8bf6 commit 7782462

File tree

15 files changed

+880
-91
lines changed

15 files changed

+880
-91
lines changed

README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,79 @@ helm install homer-operator oci://ghcr.io/rajsinghtech/homer-operator/charts/hom
200200
--set operator.enableGatewayAPI=true
201201
```
202202

203+
#### Advanced Filtering Options
204+
205+
Control exactly which resources are included in your dashboard with comprehensive filtering options:
206+
207+
```yaml
208+
apiVersion: homer.rajsingh.info/v1alpha1
209+
kind: Dashboard
210+
metadata:
211+
name: production-dashboard
212+
spec:
213+
# Filter HTTPRoutes by Gateway labels
214+
gatewaySelector:
215+
matchLabels:
216+
environment: "production"
217+
gateway: "public"
218+
matchExpressions:
219+
- key: "app.kubernetes.io/name"
220+
operator: In
221+
values: ["istio-gateway", "envoy-gateway", "nginx-gateway"]
222+
223+
# Filter HTTPRoutes by their own labels
224+
httpRouteSelector:
225+
matchLabels:
226+
team: "platform"
227+
tier: "frontend"
228+
matchExpressions:
229+
- key: "app.kubernetes.io/component"
230+
operator: In
231+
values: ["api", "service", "web"]
232+
233+
# Filter Ingresses by labels
234+
ingressSelector:
235+
matchLabels:
236+
environment: "production"
237+
public: "true"
238+
matchExpressions:
239+
- key: "kubernetes.io/ingress.class"
240+
operator: In
241+
values: ["nginx", "traefik"]
242+
243+
# Filter by hostname/domain (works for both HTTPRoutes and Ingresses)
244+
domainFilters:
245+
- "mycompany.com" # Exact match: mycompany.com
246+
- "internal.local" # Subdomain match: *.internal.local
247+
- "rajsingh.info" # Both exact and subdomain matching
248+
249+
homerConfig:
250+
title: "🏭 Production Services"
251+
subtitle: "Filtered production endpoints"
252+
# ... rest of config
253+
```
254+
255+
**Filtering Capabilities:**
256+
257+
| Filter Type | Description | Applies To | Default Behavior |
258+
|-------------|-------------|------------|------------------|
259+
| `gatewaySelector` | Filter HTTPRoutes by parent Gateway labels | HTTPRoutes only | Include all HTTPRoutes |
260+
| `httpRouteSelector` | Filter HTTPRoutes by their own labels | HTTPRoutes only | Include all HTTPRoutes |
261+
| `ingressSelector` | Filter Ingresses by their labels | Ingresses only | Include all Ingresses |
262+
| `domainFilters` | Filter by hostname/domain names | Both HTTPRoutes & Ingresses | Include all domains |
263+
264+
**Domain Filtering Examples:**
265+
- `example.com` - Matches exactly `example.com`
266+
- `internal.local` - Matches `api.internal.local`, `web.internal.local`, etc.
267+
- Multiple filters are OR'd together (any match includes the resource)
268+
269+
**Real-world Use Cases:**
270+
- **Environment Separation**: Production vs staging dashboards
271+
- **Team Dashboards**: Platform team vs application team services
272+
- **Security Zones**: Public vs internal service separation
273+
- **Domain Organization**: Company domains vs personal projects
274+
- **Gateway Migration**: Gradual migration between gateway implementations
275+
203276
### Annotation-driven Service Discovery
204277

205278
Control how your services appear on dashboards using annotations on both Ingress and HTTPRoute resources:

api/v1alpha1/dashboard_types.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,18 @@ type DashboardSpec struct {
4545

4646
// Secrets configures Secret references for sensitive smart card data.
4747
Secrets *SmartCardSecrets `json:"secrets,omitempty"`
48+
49+
// GatewaySelector optionally filters HTTPRoutes by Gateway labels. If not specified, all HTTPRoutes are included.
50+
GatewaySelector *metav1.LabelSelector `json:"gatewaySelector,omitempty"`
51+
52+
// HTTPRouteSelector optionally filters HTTPRoutes by labels. If not specified, all HTTPRoutes are included.
53+
HTTPRouteSelector *metav1.LabelSelector `json:"httpRouteSelector,omitempty"`
54+
55+
// IngressSelector optionally filters Ingresses by labels. If not specified, all Ingresses are included.
56+
IngressSelector *metav1.LabelSelector `json:"ingressSelector,omitempty"`
57+
58+
// DomainFilters optionally filters HTTPRoutes and Ingresses by domain names. If not specified, all domains are included.
59+
DomainFilters []string `json:"domainFilters,omitempty"`
4860
}
4961

5062
// DashboardStatus defines the observed state of Dashboard

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/homer-operator/templates/crd.yaml

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,59 @@ spec:
124124
is stored.
125125
type: string
126126
type: object
127+
domainFilters:
128+
description: DomainFilters optionally filters HTTPRoutes and Ingresses
129+
by domain names. If not specified, all domains are included.
130+
items:
131+
type: string
132+
type: array
133+
gatewaySelector:
134+
description: GatewaySelector optionally filters HTTPRoutes by Gateway
135+
labels. If not specified, all HTTPRoutes are included.
136+
properties:
137+
matchExpressions:
138+
description: matchExpressions is a list of label selector requirements.
139+
The requirements are ANDed.
140+
items:
141+
description: |-
142+
A label selector requirement is a selector that contains values, a key, and an operator that
143+
relates the key and values.
144+
properties:
145+
key:
146+
description: key is the label key that the selector applies
147+
to.
148+
type: string
149+
operator:
150+
description: |-
151+
operator represents a key's relationship to a set of values.
152+
Valid operators are In, NotIn, Exists and DoesNotExist.
153+
type: string
154+
values:
155+
description: |-
156+
values is an array of string values. If the operator is In or NotIn,
157+
the values array must be non-empty. If the operator is Exists or DoesNotExist,
158+
the values array must be empty. This array is replaced during a strategic
159+
merge patch.
160+
items:
161+
type: string
162+
type: array
163+
x-kubernetes-list-type: atomic
164+
required:
165+
- key
166+
- operator
167+
type: object
168+
type: array
169+
x-kubernetes-list-type: atomic
170+
matchLabels:
171+
additionalProperties:
172+
type: string
173+
description: |-
174+
matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
175+
map is equivalent to an element of matchExpressions, whose key field is "key", the
176+
operator is "In", and the values array contains only "value". The requirements are ANDed.
177+
type: object
178+
type: object
179+
x-kubernetes-map-type: atomic
127180
homerConfig:
128181
description: HomerConfig is base/default Homer configuration.
129182
properties:
@@ -361,6 +414,100 @@ spec:
361414
required:
362415
- header
363416
type: object
417+
httpRouteSelector:
418+
description: HTTPRouteSelector optionally filters HTTPRoutes by labels.
419+
If not specified, all HTTPRoutes are included.
420+
properties:
421+
matchExpressions:
422+
description: matchExpressions is a list of label selector requirements.
423+
The requirements are ANDed.
424+
items:
425+
description: |-
426+
A label selector requirement is a selector that contains values, a key, and an operator that
427+
relates the key and values.
428+
properties:
429+
key:
430+
description: key is the label key that the selector applies
431+
to.
432+
type: string
433+
operator:
434+
description: |-
435+
operator represents a key's relationship to a set of values.
436+
Valid operators are In, NotIn, Exists and DoesNotExist.
437+
type: string
438+
values:
439+
description: |-
440+
values is an array of string values. If the operator is In or NotIn,
441+
the values array must be non-empty. If the operator is Exists or DoesNotExist,
442+
the values array must be empty. This array is replaced during a strategic
443+
merge patch.
444+
items:
445+
type: string
446+
type: array
447+
x-kubernetes-list-type: atomic
448+
required:
449+
- key
450+
- operator
451+
type: object
452+
type: array
453+
x-kubernetes-list-type: atomic
454+
matchLabels:
455+
additionalProperties:
456+
type: string
457+
description: |-
458+
matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
459+
map is equivalent to an element of matchExpressions, whose key field is "key", the
460+
operator is "In", and the values array contains only "value". The requirements are ANDed.
461+
type: object
462+
type: object
463+
x-kubernetes-map-type: atomic
464+
ingressSelector:
465+
description: IngressSelector optionally filters Ingresses by labels.
466+
If not specified, all Ingresses are included.
467+
properties:
468+
matchExpressions:
469+
description: matchExpressions is a list of label selector requirements.
470+
The requirements are ANDed.
471+
items:
472+
description: |-
473+
A label selector requirement is a selector that contains values, a key, and an operator that
474+
relates the key and values.
475+
properties:
476+
key:
477+
description: key is the label key that the selector applies
478+
to.
479+
type: string
480+
operator:
481+
description: |-
482+
operator represents a key's relationship to a set of values.
483+
Valid operators are In, NotIn, Exists and DoesNotExist.
484+
type: string
485+
values:
486+
description: |-
487+
values is an array of string values. If the operator is In or NotIn,
488+
the values array must be non-empty. If the operator is Exists or DoesNotExist,
489+
the values array must be empty. This array is replaced during a strategic
490+
merge patch.
491+
items:
492+
type: string
493+
type: array
494+
x-kubernetes-list-type: atomic
495+
required:
496+
- key
497+
- operator
498+
type: object
499+
type: array
500+
x-kubernetes-list-type: atomic
501+
matchLabels:
502+
additionalProperties:
503+
type: string
504+
description: |-
505+
matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
506+
map is equivalent to an element of matchExpressions, whose key field is "key", the
507+
operator is "In", and the values array contains only "value". The requirements are ANDed.
508+
type: object
509+
type: object
510+
x-kubernetes-map-type: atomic
364511
replicas:
365512
default: 1
366513
description: Replicas is the number of desired pods for the Homer

charts/homer-operator/templates/deployment.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,16 @@ spec:
4141
command:
4242
- /manager
4343
args:
44+
{{- if .Values.operator.leaderElection.enabled }}
4445
- --leader-elect
46+
{{- end }}
4547
{{- if .Values.operator.metrics.enabled }}
4648
- --metrics-bind-address={{ .Values.operator.metrics.bindAddress }}
4749
{{- if .Values.operator.metrics.secureMetrics }}
4850
- --metrics-secure
4951
{{- end }}
5052
{{- end }}
5153
- --health-probe-bind-address={{ .Values.operator.healthProbe.bindAddress }}
52-
{{- if .Values.operator.leaderElection.enabled }}
53-
- --leader-elect
54-
{{- end }}
5554
env:
5655
{{- include "homer-operator.env" . | nindent 8 }}
5756
{{- if .Values.envFrom }}

charts/homer-operator/values.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -165,15 +165,6 @@ affinity: {}
165165
# Priority class for the operator pod
166166
priorityClassName: ""
167167

168-
# Node selection constraints
169-
nodeSelector: {}
170-
171-
# Tolerations for the operator pod
172-
tolerations: []
173-
174-
# Affinity rules for the operator pod
175-
affinity: {}
176-
177168
# Pod disruption budget
178169
podDisruptionBudget:
179170
enabled: false

0 commit comments

Comments
 (0)