-
Notifications
You must be signed in to change notification settings - Fork 28
Create new HTTPRoute template & update values file #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,77 @@ | ||||||||||||||||||||||||||||||||||
| {{- range $routeIdx, $route := .Values.httpRoutes }} | ||||||||||||||||||||||||||||||||||
| {{- if $route.enabled }} | ||||||||||||||||||||||||||||||||||
| {{- if or (not $route.gatewayParentRefs) (lt (len $route.gatewayParentRefs) 1) }} | ||||||||||||||||||||||||||||||||||
| {{- fail (printf "httpRoute[%d].gatewayParentRefs must be defined and contain at least one gateway reference." $routeIdx) }} | ||||||||||||||||||||||||||||||||||
| {{- end -}} | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| {{- if or (not $route.matches) (lt (len $route.matches) 1) }} | ||||||||||||||||||||||||||||||||||
| {{- fail (printf "httpRoute[%d].matches must be defined and contain at least one match element." $routeIdx) }} | ||||||||||||||||||||||||||||||||||
| {{- end -}} | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| apiVersion: gateway.networking.k8s.io/v1 | ||||||||||||||||||||||||||||||||||
| kind: HTTPRoute | ||||||||||||||||||||||||||||||||||
| metadata: | ||||||||||||||||||||||||||||||||||
| name: {{ tpl ($route.nameOverride | default (printf "%s-%s" $.Chart.Name (first $route.gatewayParentRefs).name)) $ }}-httproute | ||||||||||||||||||||||||||||||||||
| labels: | ||||||||||||||||||||||||||||||||||
| {{- include "kafka-ui.labels" $ | nindent 4 }} | ||||||||||||||||||||||||||||||||||
| {{- if $route.labels }} | ||||||||||||||||||||||||||||||||||
| {{- tpl (toYaml $route.labels) $ | nindent 4 }} | ||||||||||||||||||||||||||||||||||
| {{- end }} | ||||||||||||||||||||||||||||||||||
| {{- if $route.annotations }} | ||||||||||||||||||||||||||||||||||
| annotations: | ||||||||||||||||||||||||||||||||||
| {{- tpl (toYaml $route.annotations) $ | nindent 4 }} | ||||||||||||||||||||||||||||||||||
| {{- end }} | ||||||||||||||||||||||||||||||||||
| spec: | ||||||||||||||||||||||||||||||||||
| parentRefs: | ||||||||||||||||||||||||||||||||||
| {{- range $idx, $parentRef := $route.gatewayParentRefs }} | ||||||||||||||||||||||||||||||||||
| - group: gateway.networking.k8s.io | ||||||||||||||||||||||||||||||||||
| kind: Gateway | ||||||||||||||||||||||||||||||||||
| name: {{ tpl (required (printf "httpRoutes[%d].gatewayParentRefs[%d].name is required." $routeIdx $idx) $parentRef.name) $ }} | ||||||||||||||||||||||||||||||||||
| {{- if $parentRef.namespace }} | ||||||||||||||||||||||||||||||||||
| namespace: {{ tpl ($parentRef.namespace) $ }} | ||||||||||||||||||||||||||||||||||
| {{- end }} | ||||||||||||||||||||||||||||||||||
| {{- if $parentRef.sectionName }} | ||||||||||||||||||||||||||||||||||
| sectionName: {{ tpl ($parentRef.sectionName) $ }} | ||||||||||||||||||||||||||||||||||
| {{- end }} | ||||||||||||||||||||||||||||||||||
| {{- end }} | ||||||||||||||||||||||||||||||||||
| hostnames: | ||||||||||||||||||||||||||||||||||
| {{- tpl (toYaml $route.hostnames) $ | nindent 2 }} | ||||||||||||||||||||||||||||||||||
| rules: | ||||||||||||||||||||||||||||||||||
| - matches: | ||||||||||||||||||||||||||||||||||
| {{- tpl (toYaml $route.matches) $ | nindent 4 }} | ||||||||||||||||||||||||||||||||||
| {{- if $route.shouldRouteToService }} | ||||||||||||||||||||||||||||||||||
| backendRefs: | ||||||||||||||||||||||||||||||||||
| - group: '' | ||||||||||||||||||||||||||||||||||
| kind: Service | ||||||||||||||||||||||||||||||||||
| name: {{ include "kafka-ui.fullname" $ }} | ||||||||||||||||||||||||||||||||||
| port: {{ (tpl (default "80" ($.Values.service.port)) $) | int }} | ||||||||||||||||||||||||||||||||||
| weight: 1 | ||||||||||||||||||||||||||||||||||
| {{- end }} | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+42
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical: Template execution failure and indentation error on Two issues on line 47:
Since port values typically don't need Go template interpolation, 🐛 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
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||
| {{- if $route.filters }} | ||||||||||||||||||||||||||||||||||
| filters: | ||||||||||||||||||||||||||||||||||
| {{- if $route.shouldStripPath }} | ||||||||||||||||||||||||||||||||||
| - type: URLRewrite | ||||||||||||||||||||||||||||||||||
| urlRewrite: | ||||||||||||||||||||||||||||||||||
| path: | ||||||||||||||||||||||||||||||||||
| type: ReplacePrefixMatch | ||||||||||||||||||||||||||||||||||
| replacePrefixMatch: "/" | ||||||||||||||||||||||||||||||||||
| {{- end }} | ||||||||||||||||||||||||||||||||||
| {{- tpl (toYaml $route.filters) $ | nindent 4 }} | ||||||||||||||||||||||||||||||||||
| {{- else if $route.shouldStripPath }} | ||||||||||||||||||||||||||||||||||
| filters: | ||||||||||||||||||||||||||||||||||
| - type: URLRewrite | ||||||||||||||||||||||||||||||||||
| urlRewrite: | ||||||||||||||||||||||||||||||||||
| path: | ||||||||||||||||||||||||||||||||||
| type: ReplacePrefixMatch | ||||||||||||||||||||||||||||||||||
| replacePrefixMatch: "/" | ||||||||||||||||||||||||||||||||||
| {{- end }} | ||||||||||||||||||||||||||||||||||
| {{- if $route.timeouts }} | ||||||||||||||||||||||||||||||||||
| timeouts: | ||||||||||||||||||||||||||||||||||
| {{- tpl (toYaml $route.timeouts) $ | nindent 4 }} | ||||||||||||||||||||||||||||||||||
| {{- end }} | ||||||||||||||||||||||||||||||||||
| {{- /* Add a document separator if there is another item coming */ -}} | ||||||||||||||||||||||||||||||||||
| {{- if lt (add1 $routeIdx) (len $.Values.httpRoutes) -}} | ||||||||||||||||||||||||||||||||||
| --- | ||||||||||||||||||||||||||||||||||
| {{- end -}} | ||||||||||||||||||||||||||||||||||
| {{- end -}} | ||||||||||||||||||||||||||||||||||
| {{- end -}} | ||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle empty or undefined hostnames gracefully.
If
hostnamesis undefined or an empty array,toYamlwill producenullor[], which may cause invalid YAML. Consider making thehostnamesfield conditional or adding validation.💡 Proposed fix to make hostnames conditional
📝 Committable suggestion
🤖 Prompt for AI Agents