Skip to content

Create new HTTPRoute template & update values file#62

Open
attributeerror wants to merge 2 commits intokafbat:mainfrom
attributeerror:add-support-for-gateway-api
Open

Create new HTTPRoute template & update values file#62
attributeerror wants to merge 2 commits intokafbat:mainfrom
attributeerror:add-support-for-gateway-api

Conversation

@attributeerror
Copy link
Copy Markdown

@attributeerror attributeerror commented Feb 5, 2026

Add support for deploying HTTPRoute resources, as well as Ingress. This allows teams making use of the Gateway API to expose kafka-ui via this chart.

Summary by CodeRabbit

New Features

  • Added support for configuring Kubernetes Gateway API HTTPRoute resources, enabling flexible HTTP routing with hostname matching, path rewriting, custom filters, and timeout management for Kafka UI deployments.

@attributeerror attributeerror requested a review from a team as a code owner February 5, 2026 15:09
@attributeerror attributeerror force-pushed the add-support-for-gateway-api branch from 6c3e054 to 03df0e0 Compare February 6, 2026 08:50
@codrutpanea
Copy link
Copy Markdown

we're moving from ingress-nginx to gateway-api and would be great to have this supported by the chart

@korjek
Copy link
Copy Markdown

korjek commented Feb 26, 2026

We are also interested in getting httproute support!

@dtherhtun
Copy link
Copy Markdown

We need this gateway-api☝️

@Assylbek2002

This comment has been minimized.

@Haarolean
Copy link
Copy Markdown
Member

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 26, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 26, 2026

📝 Walkthrough

Walkthrough

Added a new Helm template for Kubernetes Gateway API HTTPRoute resources and corresponding configuration values. The template iterates over httpRoutes, validates required fields (gatewayParentRefs and matches), and generates HTTPRoute manifests with conditional features including path rewrites, service routing, and timeouts.

Changes

Cohort / File(s) Summary
HTTPRoute Helm Template
charts/kafka-ui/templates/http-route.yaml
New template that generates Kubernetes HTTPRoute resources from values, including validation of gatewayParentRefs and matches, dynamic metadata naming, parent refs binding, hostname configuration, path matching rules, optional path rewriting filters, and conditional routing to the Kafka-UI service with configurable timeouts.
HTTPRoute Configuration Values
charts/kafka-ui/values.yaml
Added new httpRoutes configuration array enabling multiple Gateway API HTTPRoute definitions with controls for enablement, hostnames, annotations/labels, gateway parent references (name/namespace/sectionName), path stripping, service routing, path match patterns, custom filters, and timeout settings.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 Hopping through gateways, routes now flow clear,
HTTPRoute configs bring order near,
Kafka-UI dances with K8s design,
Path rewrites shimmer, timeouts align—
Gateway API magic, one template divine!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly describes the two main changes: creating a new HTTPRoute template and updating the values file.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
charts/kafka-ui/templates/http-route.yaml (2)

13-14: Consider name length limits.

Kubernetes resource names are limited to 63 characters. If $.Chart.Name combined with the gateway name and -httproute suffix exceeds this limit, the deployment will fail. Consider using trunc 63 | trimSuffix "-" similar to the kafka-ui.fullname helper.

💡 Proposed fix to handle name length
-  name: {{ tpl ($route.nameOverride | default (printf "%s-%s" $.Chart.Name (first $route.gatewayParentRefs).name)) $ }}-httproute
+  name: {{ tpl ($route.nameOverride | default (printf "%s-%s" $.Chart.Name (first $route.gatewayParentRefs).name)) $ | trunc 54 | trimSuffix "-" }}-httproute
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@charts/kafka-ui/templates/http-route.yaml` around lines 13 - 14, The metadata
name construction for the HTTPRoute can exceed Kubernetes' 63-character limit;
update the template that builds the name (the line using tpl with
($route.nameOverride | default (printf "%s-%s" $.Chart.Name (first
$route.gatewayParentRefs).name)) and the "-httproute" suffix) to truncate the
final name to 63 characters and remove a trailing dash (use Helm template
functions like trunc 63 | trimSuffix "-" similar to the kafka-ui.fullname
helper) so the generated resource name never violates the length constraint.

72-77: Minor edge case with document separators.

When enabled routes are followed by disabled routes, a trailing --- separator may be generated. This is technically valid YAML, but if you want to be precise, the separator logic could account for whether subsequent routes are enabled. This is a minor cosmetic issue.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@charts/kafka-ui/templates/http-route.yaml` around lines 72 - 77, The current
document-separator logic uses lt (add1 $routeIdx) (len $.Values.httpRoutes) and
may emit a trailing '---' when remaining routes are all disabled; update the
condition around the '---' to check whether there exists any subsequent route
with .enabled true instead of just comparing indices: from the block that
references $routeIdx and $.Values.httpRoutes, iterate (or use a helper) over the
slice of routes after $routeIdx to detect any enabled route and only render the
'---' if one is found, leaving the rest of the template unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@charts/kafka-ui/templates/http-route.yaml`:
- Around line 37-38: The hostnames block currently always renders and may
produce invalid YAML when $route.hostnames is empty or undefined; update the
template to conditionally render the hostnames section only when
$route.hostnames is set and non-empty (e.g., wrap the existing line using an if
test like "if $route.hostnames" or "if and $route.hostnames (gt (len
$route.hostnames) 0)" and keep the existing "{{- tpl (toYaml $route.hostnames) $
| nindent 2 }}" inside that block) so that hostnames is omitted entirely when
there are no values.
- Around line 42-49: Replace the tab-indented, tpl-wrapped port line with a
space-indented, non-tpl expression that treats port as an integer; specifically,
in the http-route.yaml backendRefs block (the section guarded by {{- if
$route.shouldRouteToService }} and referencing include "kafka-ui.fullname" and
$.Values.service.port) remove the tpl call and the tab, then render the port as
an integer, e.g. use a spaces-indented line like: port: {{ $.Values.service.port
| default 80 | int }} so the template no longer calls tpl on an int and the YAML
indentation uses spaces.

---

Nitpick comments:
In `@charts/kafka-ui/templates/http-route.yaml`:
- Around line 13-14: The metadata name construction for the HTTPRoute can exceed
Kubernetes' 63-character limit; update the template that builds the name (the
line using tpl with ($route.nameOverride | default (printf "%s-%s" $.Chart.Name
(first $route.gatewayParentRefs).name)) and the "-httproute" suffix) to truncate
the final name to 63 characters and remove a trailing dash (use Helm template
functions like trunc 63 | trimSuffix "-" similar to the kafka-ui.fullname
helper) so the generated resource name never violates the length constraint.
- Around line 72-77: The current document-separator logic uses lt (add1
$routeIdx) (len $.Values.httpRoutes) and may emit a trailing '---' when
remaining routes are all disabled; update the condition around the '---' to
check whether there exists any subsequent route with .enabled true instead of
just comparing indices: from the block that references $routeIdx and
$.Values.httpRoutes, iterate (or use a helper) over the slice of routes after
$routeIdx to detect any enabled route and only render the '---' if one is found,
leaving the rest of the template unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 18e23c98-a89b-4e37-8b45-a78d1c1ab112

📥 Commits

Reviewing files that changed from the base of the PR and between 9883533 and 05b5c93.

📒 Files selected for processing (2)
  • charts/kafka-ui/templates/http-route.yaml
  • charts/kafka-ui/values.yaml

Comment on lines +37 to +38
hostnames:
{{- tpl (toYaml $route.hostnames) $ | nindent 2 }}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Handle empty or undefined hostnames gracefully.

If hostnames is undefined or an empty array, toYaml will produce null or [], which may cause invalid YAML. Consider making the hostnames field conditional or adding validation.

💡 Proposed fix to make hostnames conditional
+  {{- if $route.hostnames }}
   hostnames:
   {{- tpl (toYaml $route.hostnames) $ | nindent 2 }}
+  {{- end }}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
hostnames:
{{- tpl (toYaml $route.hostnames) $ | nindent 2 }}
{{- if $route.hostnames }}
hostnames:
{{- tpl (toYaml $route.hostnames) $ | nindent 2 }}
{{- end }}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@charts/kafka-ui/templates/http-route.yaml` around lines 37 - 38, The
hostnames block currently always renders and may produce invalid YAML when
$route.hostnames is empty or undefined; update the template to conditionally
render the hostnames section only when $route.hostnames is set and non-empty
(e.g., wrap the existing line using an if test like "if $route.hostnames" or "if
and $route.hostnames (gt (len $route.hostnames) 0)" and keep the existing "{{-
tpl (toYaml $route.hostnames) $ | nindent 2 }}" inside that block) so that
hostnames is omitted entirely when there are no values.

Comment on lines +42 to +49
{{- if $route.shouldRouteToService }}
backendRefs:
- group: ''
kind: Service
name: {{ include "kafka-ui.fullname" $ }}
port: {{ (tpl (default "80" ($.Values.service.port)) $) | int }}
weight: 1
{{- end }}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Critical: Template execution failure and indentation error on port line.

Two issues on line 47:

  1. Tab character: Line 47 uses a tab for indentation instead of spaces, which will cause YAML parsing errors in the rendered output.

  2. tpl on integer: $.Values.service.port is an integer (default 80). The tpl function expects a string, so this will fail with "expected string; found int" when the template executes.

Since port values typically don't need Go template interpolation, tpl is unnecessary here.

🐛 Proposed fix
     backendRefs:
     - group: ''
       kind: Service
       name: {{ include "kafka-ui.fullname" $ }}
-	  port: {{ (tpl (default "80" ($.Values.service.port)) $) | int }}
+      port: {{ $.Values.service.port | default 80 | int }}
       weight: 1
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{{- if $route.shouldRouteToService }}
backendRefs:
- group: ''
kind: Service
name: {{ include "kafka-ui.fullname" $ }}
port: {{ (tpl (default "80" ($.Values.service.port)) $) | int }}
weight: 1
{{- end }}
{{- if $route.shouldRouteToService }}
backendRefs:
- group: ''
kind: Service
name: {{ include "kafka-ui.fullname" $ }}
port: {{ $.Values.service.port | default 80 | int }}
weight: 1
{{- end }}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@charts/kafka-ui/templates/http-route.yaml` around lines 42 - 49, Replace the
tab-indented, tpl-wrapped port line with a space-indented, non-tpl expression
that treats port as an integer; specifically, in the http-route.yaml backendRefs
block (the section guarded by {{- if $route.shouldRouteToService }} and
referencing include "kafka-ui.fullname" and $.Values.service.port) remove the
tpl call and the tab, then render the port as an integer, e.g. use a
spaces-indented line like: port: {{ $.Values.service.port | default 80 | int }}
so the template no longer calls tpl on an int and the YAML indentation uses
spaces.

hostmaster added a commit to hostmaster/helm-charts that referenced this pull request Mar 26, 2026
Ports kafbat#62 with all CodeRabbit review fixes applied:
- Truncate resource name to 63-char limit (trunc 54 + "-httproute" suffix)
- Conditionally render hostnames block only when non-empty
- Fix tab indentation and remove tpl wrapping on service port (render as int)
- Fix trailing --- separator to only emit when a subsequent enabled route exists

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Haarolean
Copy link
Copy Markdown
Member

i see this has a lot of upvotes, happy to merge if someone can take a look at coderabbit notes in a separate PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants