Skip to content

Conversation

leodinas-hao
Copy link

@leodinas-hao leodinas-hao commented Jul 16, 2025

Just a simple change to add support of nodePort, so that we can specify our own nodePort for a service of a service type: NodePort

Summary by CodeRabbit

  • New Features

    • Improved Kubernetes service configuration to better support the "NodePort" service type, allowing custom port and nodePort values.
  • Bug Fixes

    • Ensured correct port settings are applied based on the selected service type in deployment configurations.

Copy link
Contributor

coderabbitai bot commented Jul 16, 2025

Walkthrough

The Kubernetes service manifest template was updated to conditionally configure the service's port definitions based on the service type. When the type is "NodePort," specific port fields are set, including nodePort; otherwise, a default port configuration is used. Additionally, example Helm values files and the README were updated to explicitly specify a nodePort value. No changes were made to exported or public entities.

Changes

File(s) Change Summary
charts/n8n/templates/service.yaml Updated service port configuration to conditionally handle "NodePort" type with explicit port, targetPort, and nodePort fields
README.md, examples/values_small.yaml Added explicit nodePort value (30678) in example Helm values and documentation, specifying the NodePort number within valid range

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Helm Chart
    participant Kubernetes

    User->>Helm Chart: Deploys chart with values (service.type, nodePort)
    Helm Chart->>Kubernetes: Renders service.yaml with conditional port configuration
    Kubernetes-->>User: Creates Service with correct port and nodePort (if NodePort type)
Loading

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9845528 and 4a657f6.

📒 Files selected for processing (3)
  • README.md (1 hunks)
  • charts/n8n/templates/service.yaml (1 hunks)
  • examples/values_small.yaml (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • examples/values_small.yaml
  • README.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • charts/n8n/templates/service.yaml
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d0e7577 and 9845528.

📒 Files selected for processing (1)
  • charts/n8n/templates/service.yaml (1 hunks)

Comment on lines 15 to 24
{{ if .Values.main.service.type | eq "NodePort" -}}
- port: {{ default 80 .Values.main.service.port }}
targetPort: {{ default 80 .Values.main.service.port }}
nodePort: {{ default 30080 .Values.main.service.nodePort }}
{{- else }}
- port: {{ default 80 .Values.main.service.port }}
targetPort: http
protocol: TCP
name: http
{{- end }}
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

❓ Verification inconclusive

Simplify the conditional and align the NodePort stanza with Helm/K8s conventions

  1. The current conditional uses the pipeline form {{ if .Values.main.service.type | eq "NodePort" -}}.
    While technically valid, the canonical Helm style is {{- if eq .Values.main.service.type "NodePort" }} – it’s easier to read and avoids the cognitive “which side is piped?” question.

  2. The NodePort branch omits protocol and name, and hard-codes targetPort to the same numeric value as port.
    In the existing ClusterIP branch, targetPort is the named port http; changing semantics for the NodePort path is surprising and may break probes or NetworkPolicy rules that rely on the named target port.

  3. Adding name: http keeps the port list deterministic and avoids the Helm linter warning “(name) must be specified when more than one port is defined” if a second port is added later.

Proposed patch:

-    {{ if .Values.main.service.type | eq "NodePort" -}}
-    - port: {{ default 80 .Values.main.service.port }}
-      targetPort: {{ default 80 .Values.main.service.port }}
-      nodePort: {{ default 30080 .Values.main.service.nodePort }}
+    {{- if eq .Values.main.service.type "NodePort" }}
+    - name: http
+      port: {{ default 80 .Values.main.service.port }}
+      targetPort: http
+      protocol: TCP
+      nodePort: {{ default 30080 .Values.main.service.nodePort }}

This keeps the generated Service manifest consistent across service types and follows Helm best practices.


Simplify Helm conditional and unify NodePort Service stanza

  • Replace the piped conditional with the canonical Helm form for readability:
    {{- if eq .Values.main.service.type "NodePort" }}
  • In the NodePort branch, mirror the ClusterIP settings by:
    • Adding name: http
    • Using targetPort: http instead of a hard-coded number
    • Specifying protocol: TCP
  • Preserve the nodePort assignment as-is.

Proposed diff (charts/n8n/templates/service.yaml, around lines 15–24):

@@ -15,8 +15,11 @@ spec:
-    {{ if .Values.main.service.type | eq "NodePort" -}}
-    - port: {{ default 80 .Values.main.service.port }}
-      targetPort: {{ default 80 .Values.main.service.port }}
-      nodePort: {{ default 30080 .Values.main.service.nodePort }}
+    {{- if eq .Values.main.service.type "NodePort" }}
+    - name: http
+      port: {{ default 80 .Values.main.service.port }}
+      targetPort: http
+      protocol: TCP
+      nodePort: {{ default 30080 .Values.main.service.nodePort }}
     {{- else }}
     - port: {{ default 80 .Values.main.service.port }}
       targetPort: http
🤖 Prompt for AI Agents
In charts/n8n/templates/service.yaml around lines 15 to 24, simplify the Helm
conditional by replacing the piped form with the canonical form {{- if eq
.Values.main.service.type "NodePort" }} for better readability. In the NodePort
branch, unify the service stanza by adding name: http, changing targetPort to
http instead of a hard-coded port number, and specifying protocol: TCP, while
keeping the nodePort assignment unchanged.

@Vad1mo
Copy link
Member

Vad1mo commented Jul 16, 2025

Thanks, I suggest to also include this option into the readme

@leodinas-hao
Copy link
Author

Thanks for the suggestion, @Vad1mo
I will update PR to include the doc changes as well.

spec:
type: {{ default "ClusterIP_" .Values.main.service.type }}
ports:
{{ if .Values.main.service.type | eq "NodePort" -}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
{{ if .Values.main.service.type | eq "NodePort" -}}
{{- if eq .Values.main.service.type "NodePort" }}

Let's not use the pipe notation here

@leodinas-hao
Copy link
Author

Hi guys,
I've removed the pipe and added nodePort examples.
Thanks.

@leo-hao-fcx
Copy link

Hi guys,

I'm a bit confused with the linting error. It seems something wrong with github action configs.

Current runner version: '2.326.0'
Runner Image Provisioner
Operating System
Runner Image
GITHUB_TOKEN Permissions
Secret source: None
Prepare workflow directory
Prepare all required actions
Getting action download info
Error: Unable to resolve action `helm/[email protected]`, unable to find version `v3.13.0`

Can someone please help?

Thanks.

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.

4 participants