Skip to content

Add PreferHTTPRoute and Gateway protocol detection support #2284

@lexfrei

Description

@lexfrei

Summary

Add support for PreferHTTPRoute field in ClientConfig to allow operator to communicate with Grafana instance via HTTPRoute instead of Service, similar to existing PreferIngress functionality.

Motivation

When using Gateway API HTTPRoutes, the operator currently communicates with Grafana through the Service. However, in some scenarios (similar to Ingress use cases), it would be beneficial to communicate through the HTTPRoute to:

  • Validate that the HTTPRoute is correctly configured
  • Test the full ingress path including Gateway rules and filters
  • Ensure end-to-end connectivity works as expected

Proposed Implementation

1. Add PreferHTTPRoute Field

type ClientConfig struct {
    // ... existing fields ...
    PreferHTTPRoute *bool `json:"preferHTTPRoute,omitempty"`
}

2. Gateway Protocol Detection

Implement Gateway lookup to determine correct protocol (HTTP/HTTPS):

  • Look up Gateway resource from HTTPRoute.Spec.ParentRefs
  • Find matching Listener by SectionName
  • Detect protocol from Listener.Protocol or Listener.TLS configuration
  • Fallback to hostname from HTTPRoute.Spec.Hostnames

3. AdminURL Construction

Build admin URL using detected protocol and hostname for operator-to-Grafana communication.

Complexity Considerations

This feature requires:

  • Additional RBAC permissions to read Gateway resources
  • Complex logic to match listeners and detect protocols
  • Proper error handling for missing/incomplete Gateway information
  • Comprehensive test coverage

Related

Questions for Discussion

  1. Is this functionality needed for HTTPRoute support, or is Service-based communication sufficient?
  2. Should we support fallback scenarios (e.g., Gateway not found)?
  3. What should be the behavior when multiple parentRefs are defined?
  4. Should we also support extracting hostname from Gateway status if not specified in HTTPRoute?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions