Skip to content

fix: Add ingress for grafana report#121

Open
duchieu2k wants to merge 1 commit into
mainfrom
fix/report-ingress
Open

fix: Add ingress for grafana report#121
duchieu2k wants to merge 1 commit into
mainfrom
fix/report-ingress

Conversation

@duchieu2k
Copy link
Copy Markdown
Contributor

No description provided.

@duchieu2k duchieu2k requested a review from a team April 14, 2026 03:32
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 14, 2026

Summary by CodeRabbit

  • Chores
    • Added Kubernetes infrastructure configuration to support Grafana integration when enabled.

Walkthrough

A new Helm template file is added that conditionally renders three NGINX Ingress resources for Grafana integration. These ingresses validate query parameters, manipulate cookies, inject request headers, and route traffic to backend and frontend services with SSL enforcement and regex-based path matching.

Changes

Cohort / File(s) Summary
Grafana NGINX Ingress Configuration
kubernetes/report-ui/templates/refelx-grafana-ingress.yaml
Introduces three conditional Ingress resources: one for redirecting with query parameter validation and cookie setting; two for proxying Grafana-related backend and frontend endpoints with header injection and session validation. Includes NGINX configuration-snippet for parameter validation, orgId comparison against Grafana referer, and conditional 401 responses.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive No description was provided by the author, making it impossible to assess relevance to the changeset. Add a pull request description explaining the purpose, changes, and any testing performed for the new Grafana ingress resources.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding an ingress resource for Grafana report routing, which directly matches the new template file added.
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.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@kubernetes/report-ui/templates/refelx-grafana-ingress.yaml`:
- Line 1: The file name contains a typo: rename the template file from
refelx-grafana-ingress.yaml to reflex-grafana-ingress.yaml to match the project
naming convention; update any references to this template elsewhere in the
chart/manifest (e.g., Chart templates, values, or include references) so they
point to reflex-grafana-ingress.yaml and ensure the template internals (the
$basehref variable) remain unchanged.
- Around line 133-134: The ingress path entry using the regex path "path: \"{{
$basehref }}/report/grafana/(.*)\"" currently sets "pathType: Prefix" which is
incorrect for regex paths; update that path's "pathType" to
"ImplementationSpecific" (matching the other backend ingress entry that uses
use-regex: \"true\") so the regex capture group is handled correctly and
consistent behavior is maintained with the existing backend ingress
configuration.
- Around line 61-74: The ingress rule using the regex path "{{ $basehref
}}/grafana-redirect-report-nmaa(/|$)(.*)" is missing the nginx annotation to
enable regex and uses the wrong pathType; update the
grafana-redirect-report-ingress resource by adding the annotation
nginx.ingress.kubernetes.io/use-regex: "true" alongside the existing annotations
and change pathType from Prefix to ImplementationSpecific for the path entry so
NGINX will evaluate the regex correctly.
🪄 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: ASSERTIVE

Plan: Pro

Run ID: 31754222-d796-4380-acb7-749c26b5a31f

📥 Commits

Reviewing files that changed from the base of the PR and between 683e484 and e8cd5cc.

📒 Files selected for processing (1)
  • kubernetes/report-ui/templates/refelx-grafana-ingress.yaml

@@ -0,0 +1,136 @@
{{- $basehref := .Values.backend.config.basehref | default "" -}}
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

Filename typo: refelx should be reflex.

The file is named refelx-grafana-ingress.yaml but based on the naming convention of other files in this directory (reflex-backend-svc.yaml, reflex-frontend-svc.yaml), it should be reflex-grafana-ingress.yaml.

🧰 Tools
🪛 YAMLlint (1.38.0)

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)

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

In `@kubernetes/report-ui/templates/refelx-grafana-ingress.yaml` at line 1, The
file name contains a typo: rename the template file from
refelx-grafana-ingress.yaml to reflex-grafana-ingress.yaml to match the project
naming convention; update any references to this template elsewhere in the
chart/manifest (e.g., Chart templates, values, or include references) so they
point to reflex-grafana-ingress.yaml and ensure the template internals (the
$basehref variable) remain unchanged.

Comment on lines +61 to +74
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
name: grafana-redirect-report-ingress
spec:
ingressClassName: {{ .Release.Name }}
rules:
- http:
paths:
- backend:
service:
name: {{ .Chart.Name }}-frontend
port:
number: {{ .Values.frontend.service.port }}
path: "{{ $basehref }}/grafana-redirect-report-nmaa(/|$)(.*)"
pathType: Prefix
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 | 🟠 Major

Missing use-regex annotation and incorrect pathType for regex path.

The path "{{ $basehref }}/grafana-redirect-report-nmaa(/|$)(.*)" contains regex patterns, but:

  1. The nginx.ingress.kubernetes.io/use-regex: "true" annotation is missing (compare to lines 91 and 121)
  2. pathType: Prefix should be pathType: ImplementationSpecific when using regex (compare to line 104)

Without these changes, NGINX won't interpret the regex and the path matching will fail.

🐛 Proposed fix
     nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
+    nginx.ingress.kubernetes.io/use-regex: "true"
   name: grafana-redirect-report-ingress
 spec:
   ingressClassName: {{ .Release.Name }}
   rules:
   - http:
       paths:
       - backend:
           service:
             name: {{ .Chart.Name }}-frontend
             port:
               number: {{ .Values.frontend.service.port }}
         path: "{{ $basehref }}/grafana-redirect-report-nmaa(/|$)(.*)"
-        pathType: Prefix
+        pathType: ImplementationSpecific
🧰 Tools
🪛 YAMLlint (1.38.0)

[error] 64-64: too many spaces inside braces

(braces)


[error] 64-64: too many spaces inside braces

(braces)


[error] 70-70: too many spaces inside braces

(braces)


[error] 70-70: too many spaces inside braces

(braces)


[error] 72-72: too many spaces inside braces

(braces)


[error] 72-72: too many spaces inside braces

(braces)

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

In `@kubernetes/report-ui/templates/refelx-grafana-ingress.yaml` around lines 61 -
74, The ingress rule using the regex path "{{ $basehref
}}/grafana-redirect-report-nmaa(/|$)(.*)" is missing the nginx annotation to
enable regex and uses the wrong pathType; update the
grafana-redirect-report-ingress resource by adding the annotation
nginx.ingress.kubernetes.io/use-regex: "true" alongside the existing annotations
and change pathType from Prefix to ImplementationSpecific for the path entry so
NGINX will evaluate the regex correctly.

Comment on lines +133 to +134
path: "{{ $basehref }}/report/grafana/(.*)"
pathType: Prefix
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

Incorrect pathType for regex path.

The path contains a regex capture group (.*) and the ingress has use-regex: "true", but pathType: Prefix should be pathType: ImplementationSpecific for consistency with the backend ingress at line 104.

🔧 Proposed fix
         path: "{{ $basehref }}/report/grafana/(.*)"
-        pathType: Prefix
+        pathType: ImplementationSpecific
📝 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
path: "{{ $basehref }}/report/grafana/(.*)"
pathType: Prefix
path: "{{ $basehref }}/report/grafana/(.*)"
pathType: ImplementationSpecific
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@kubernetes/report-ui/templates/refelx-grafana-ingress.yaml` around lines 133
- 134, The ingress path entry using the regex path "path: \"{{ $basehref
}}/report/grafana/(.*)\"" currently sets "pathType: Prefix" which is incorrect
for regex paths; update that path's "pathType" to "ImplementationSpecific"
(matching the other backend ingress entry that uses use-regex: \"true\") so the
regex capture group is handled correctly and consistent behavior is maintained
with the existing backend ingress configuration.

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.

1 participant