Skip to content

[kubernetes] Add option for exposing ingress-nginx via LoadBalancer - #1114

Merged
Andrei Kvapil (kvaps) merged 1 commit into
mainfrom
kubernetes-nginx
Jul 2, 2025
Merged

Andrei Kvapil (kvaps) merged 1 commit into
mainfrom
kubernetes-nginx

Conversation

@kvaps

@kvaps Andrei Kvapil (kvaps) commented Jun 25, 2025 •

Copy link
Copy Markdown
Member

Signed-off-by: Andrei Kvapil [email protected]

Summary by CodeRabbit

  • New Features
    • Added a new configuration option to choose the method for exposing the Ingress-NGINX controller: "Proxied" or "LoadBalancer".
  • Documentation
    • Updated documentation to describe the new exposeMethod option and clarified the conditions under which domain names are used.
  • Bug Fixes
    • Improved conditional logic to ensure Ingress resources are only created when the appropriate expose method is selected.
  • Chores
    • Incremented the chart version to 0.25.0.

@coderabbitai

coderabbitai Bot commented Jun 25, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

This change introduces a new exposeMethod configuration option for the Ingress-NGINX addon in the Kubernetes app. Conditional logic and documentation are updated to support two exposure methods: "Proxied" and "LoadBalancer". Chart versioning, schema, and version mapping are incremented accordingly.

Changes

File(s) Change Summary
.../Chart.yaml, .../versions_map Incremented chart version and updated version mapping for the Kubernetes package.
.../Makefile Added command to enforce exposeMethod enum values in the schema.
.../README.md Documented the new exposeMethod option and clarified hosts usage.
.../values.schema.json, .../values.yaml Added exposeMethod property under ingressNginx with enum and updated hosts description.
.../templates/helmreleases/ingress-nginx.yaml Made hostNetwork and service.enabled settings conditional on exposeMethod being "Proxied".
.../templates/ingress.yaml Rendered resources only if exposeMethod is "Proxied" and hosts is set.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant HelmChart
    participant values.yaml
    participant ingress-nginx Controller

    User->>HelmChart: Deploy with values.yaml
    HelmChart->>values.yaml: Read addons.ingressNginx.exposeMethod
    alt exposeMethod == "Proxied"
        HelmChart->>ingress-nginx Controller: Set hostNetwork: true, service.enabled: false
        HelmChart->>HelmChart: Render ingress resources if hosts present
    else exposeMethod == "LoadBalancer"
        HelmChart->>ingress-nginx Controller: Do not set hostNetwork/service.enabled
        HelmChart->>HelmChart: Do not render ingress resources
    end
Loading

Possibly related PRs

Suggested labels

enhancement, size:M, lgtm

Suggested reviewers

  • lllamnyp

Poem

A rabbit hopped through YAML fields,
Tweaking charts so value yields,
Now NGINX can show its face,
Proxied or LoadBalancer in place.
With docs and schema all aligned,
This fluffy update is well-defined!
🐇✨


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 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 (4)
packages/apps/kubernetes/templates/helmreleases/ingress-nginx.yaml (1)

6-10: Consider explicit Service defaults for LoadBalancer mode

service.enabled: false is now gated behind exposeMethod == "Proxied".
When the user switches to "LoadBalancer" we rely on the upstream chart’s defaults to create a Service of the desired type. That is fine, but it makes the behaviour implicit and can surprise operators.

A tiny explicit override keeps intent clear:

{{- if eq .Values.addons.ingressNginx.exposeMethod "Proxied" }}
   hostNetwork: true
   service:
     enabled: false
+{{- else if eq .Values.addons.ingressNginx.exposeMethod "LoadBalancer" }}
+  service:
+    type: LoadBalancer
{{- end }}

No functional break today, but worth considering for clarity.

packages/apps/kubernetes/templates/ingress.yaml (1)

3-4: Guard clause is fine – watch for nil .hosts

Using .Values.addons.ingressNginx.hosts directly works when the key exists, but if the user removes it entirely the template may error.
A safer check:

{{- if and (eq .Values.addons.ingressNginx.exposeMethod "Proxied") (hasKey .Values.addons.ingressNginx "hosts") }}

Not blocking, but prevents an edge-case crash.

packages/apps/kubernetes/values.yaml (1)

64-72: Confirm template logic & tighten wording

exposeMethod/hosts look correct here, but please double-check that every Helm template compares the value case-sensitively against the same "Proxied"/"LoadBalancer" strings; otherwise the default could silently break.
Minor nit: “Taken into account” reads wordy—“considered only when” is shorter.

packages/apps/kubernetes/README.md (1)

101-103: Rephrase hosts description for clarity

Same wordiness as in values.yaml. Consider:

-| `addons.ingressNginx.hosts`                   | List of domain names that the parent cluster should route to this tenant cluster. Taken into account only when `exposeMethod` is set to `Proxied`.                                | `[]`      |
+| `addons.ingressNginx.hosts`                   | List of domain names the parent cluster should route to this tenant cluster; considered only when `exposeMethod` is `Proxied`.                                                     | `[]`      |
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4369b03 and c6ee006.

📒 Files selected for processing (8)
  • packages/apps/kubernetes/Chart.yaml (1 hunks)
  • packages/apps/kubernetes/Makefile (1 hunks)
  • packages/apps/kubernetes/README.md (1 hunks)
  • packages/apps/kubernetes/templates/helmreleases/ingress-nginx.yaml (1 hunks)
  • packages/apps/kubernetes/templates/ingress.yaml (1 hunks)
  • packages/apps/kubernetes/values.schema.json (1 hunks)
  • packages/apps/kubernetes/values.yaml (1 hunks)
  • packages/apps/versions_map (1 hunks)
🧰 Additional context used
🪛 LanguageTool
packages/apps/kubernetes/README.md

[style] ~102-~102: ‘Taken into account’ might be wordy. Consider a shorter alternative.
Context: ...er should route to this tenant cluster. Taken into account only when exposeMethod is set to `Pro...

(EN_WORDINESS_PREMIUM_TAKEN_INTO_ACCOUNT)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build
🔇 Additional comments (3)
packages/apps/kubernetes/Chart.yaml (1)

18-20: Version bump looks good – double-check release notes & dependencies

Going from 0.24.2 → 0.25.0 is a minor-level bump, so remember to add a short entry to CHANGELOG/RELEASE_NOTES and verify that any chart dependencies also satisfy their version constraints.

packages/apps/versions_map (1)

52-55: Mapping update LGTM

The pin of 0.24.2 to commit 4369b031 and addition of 0.25.0 HEAD are consistent with the chart bump.

packages/apps/kubernetes/values.schema.json (1)

181-189: Enum looks good—ensure matching case in templates

JSON-Schema enumeration is case-sensitive. Verify that template conditionals use exactly Proxied / LoadBalancer; any mismatch will bypass the intended logic.

Comment on lines 7 to 10
generate:
readme-generator -v values.yaml -s values.schema.json -r README.md
yq -o json -i '.properties.addons.properties.ingressNginx.properties.exposeMethod.enum = ["Proxied","LoadBalancer"]' values.schema.json
yq -o json -i '.properties.controlPlane.properties.apiServer.properties.resourcesPreset.enum = ["none","nano","micro","small","medium","large","xlarge","2xlarge"]' values.schema.json

@coderabbitai coderabbitai Bot Jun 25, 2025 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

exposeMethod enum written after README generation – order likely wrong

readme-generator consumes values.schema.json, but the enum for exposeMethod is inserted only after the README is generated.
Result: the rendered docs won’t list the new allowed values.

-generate:
-	readme-generator -v values.yaml -s values.schema.json -r README.md
-	yq -o json -i '.properties.addons.properties.ingressNginx.properties.exposeMethod.enum = ["Proxied","LoadBalancer"]' values.schema.json
+generate:
+	yq -o json -i '.properties.addons.properties.ingressNginx.properties.exposeMethod.enum = ["Proxied","LoadBalancer"]' values.schema.json
+	readme-generator -v values.yaml -s values.schema.json -r README.md

Switching the two lines ensures documentation and schema stay in sync.

📝 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
generate:
readme-generator -v values.yaml -s values.schema.json -r README.md
yq -o json -i '.properties.addons.properties.ingressNginx.properties.exposeMethod.enum = ["Proxied","LoadBalancer"]' values.schema.json
yq -o json -i '.properties.controlPlane.properties.apiServer.properties.resourcesPreset.enum = ["none","nano","micro","small","medium","large","xlarge","2xlarge"]' values.schema.json
generate:
yq -o json -i '.properties.addons.properties.ingressNginx.properties.exposeMethod.enum = ["Proxied","LoadBalancer"]' values.schema.json
readme-generator -v values.yaml -s values.schema.json -r README.md
yq -o json -i '.properties.controlPlane.properties.apiServer.properties.resourcesPreset.enum = ["none","nano","micro","small","medium","large","xlarge","2xlarge"]' values.schema.json
🧰 Tools
🪛 checkmake (0.2.2)

[warning] 7-7: Target body for "generate" exceeds allowed length of 5 (6).

(maxbodylength)

🤖 Prompt for AI Agents
In packages/apps/kubernetes/Makefile around lines 7 to 10, the enum values for
exposeMethod are updated in values.schema.json only after the README is
generated, causing the documentation to miss these new values. To fix this,
reorder the commands so that the yq commands updating the schema run before the
readme-generator command, ensuring the README is generated from the updated
schema.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

it's okay baby

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Andrei Kvapil (@kvaps) Got it! I'll respect your decision on keeping the current order. Thanks for the feedback.

Comment thread packages/apps/kubernetes/values.schema.json
@kvaps
Andrei Kvapil (kvaps) merged commit 512277f into main Jul 2, 2025
@kvaps
Andrei Kvapil (kvaps) deleted the kubernetes-nginx branch July 2, 2025 08:52
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