Skip to content
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

Add nginx-ingress-controller option #1022

Merged
merged 1 commit into from
Sep 30, 2024
Merged

Add nginx-ingress-controller option #1022

merged 1 commit into from
Sep 30, 2024

Conversation

emplam27
Copy link
Contributor

@emplam27 emplam27 commented Sep 30, 2024

What this PR does / why we need it:

Previously, our AWS-based setup only supported ALB ingresses via the
alb-ingress-controller. This change enables the use of Nginx ingress
controller as an alternative, particularly beneficial for self-hosted
clusters. Users can now choose between ALB and Nginx when configuring
ingresses, providing more flexibility in ingress management.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


Additional documentation:


Checklist:

  • Added relevant tests or not required
  • Didn't break anything

Summary by CodeRabbit

  • New Features

    • Introduced conditional logic for Ingress resource configuration based on the enabled state of ingress controllers.
    • Added a new nginx configuration block in the ingress settings.
    • Updated rate limit configuration with a new name field.
  • Bug Fixes

    • Ensured backend service configuration remains intact when ingress hosts are enabled or not.

@emplam27 emplam27 self-assigned this Sep 30, 2024
Copy link

coderabbitai bot commented Sep 30, 2024

Walkthrough

The changes involve updates to the ingress.yaml and values.yaml files for the Yorkie cluster. The ingress.yaml file introduces conditional logic for naming and annotations based on ingress controller configurations, while the values.yaml file maintains most existing parameters but adds a new nginx configuration block and updates the ratelimit section. The ingress settings now support different load balancing algorithms and conditional annotations for AWS and NCP ALB configurations.

Changes

File Path Change Summary
build/charts/yorkie-cluster/templates/istio/ingress.yaml Introduced conditional logic for Ingress resource naming and annotations based on ingress controller state. Added NGINX-specific annotations and modified rules section for host handling.
build/charts/yorkie-cluster/values.yaml Updated ingressGateway to use maglev load balancing; added new nginx block in ingress section; updated ratelimit to include a name field. Most existing parameters remain unchanged.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant IngressController
    participant BackendService

    User->>IngressController: Request Ingress
    IngressController->>BackendService: Forward Request
    BackendService-->>IngressController: Response
    IngressController-->>User: Return Response
Loading

Poem

🐰 In the meadow where changes bloom,
New NGINX whispers, dispelling gloom.
With load balancers dancing in line,
Yorkie's cluster is now divine!
A sprinkle of config, a dash of delight,
Hopping along, everything feels right! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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

@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

🧹 Outside diff range and nitpick comments (4)
build/charts/yorkie-cluster/values.yaml (1)

63-65: LGTM! Consider adding more nginx-specific configuration options.

The addition of the nginx configuration block aligns well with the PR objective of introducing nginx-ingress-controller support. Setting it to enabled: false by default is a good practice.

Consider expanding the nginx block with additional configuration options that might be specific to nginx-ingress-controller. This could include settings like:

nginx:
  enabled: false
  annotations: {}
  config: {}
  # Add any other nginx-specific settings here

This would provide more flexibility for users who choose to enable the nginx ingress controller.

build/charts/yorkie-cluster/templates/istio/ingress.yaml (3)

34-38: LGTM! Consider adding a comment for clarity

The addition of NGINX-specific annotations is correct and aligns with the PR objective. The configuration looks good.

Consider adding a brief comment explaining the purpose of the rewrite-target annotation for better maintainability. For example:

annotations:
  # Rewrite all incoming requests to the root path
  nginx.ingress.kubernetes.io/rewrite-target: /
  kubernetes.io/ingress.class: "nginx"

44-47: LGTM! Consider adding a comment for clarity

The addition of conditional logic for handling ingress hosts is a good improvement, providing flexibility in different deployment scenarios.

Consider adding a brief comment explaining the purpose of this conditional block for better maintainability. For example:

{{ if .Values.ingress.hosts.enabled }}
- host: {{ .Values.ingress.hosts.apiHost }}
  http:
{{ else }}
# Default configuration when no specific host is set
- http:
{{ end }}

Line range hint 1-56: Overall, the changes look good and align with the PR objectives

The modifications to the ingress.yaml file successfully introduce support for the NGINX ingress controller while maintaining compatibility with existing AWS ALB and NCP ALB configurations. The conditional logic for naming and annotations provides the necessary flexibility for different deployment scenarios.

A few minor suggestions were made to improve code clarity and fix indentation issues. These changes will enhance the maintainability of the file.

If you'd like assistance implementing any of the suggested improvements or have any questions about the review, please let me know. I'm here to help!

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 7b8e974 and 88267cf.

📒 Files selected for processing (2)
  • build/charts/yorkie-cluster/templates/istio/ingress.yaml (2 hunks)
  • build/charts/yorkie-cluster/values.yaml (1 hunks)
🧰 Additional context used
🪛 yamllint
build/charts/yorkie-cluster/templates/istio/ingress.yaml

[error] 5-5: syntax error: expected , but found ''

(syntax)

🔇 Additional comments (2)
build/charts/yorkie-cluster/values.yaml (2)

Line range hint 1-74: Overall, the changes align well with the PR objectives.

The addition of the nginx configuration block in the ingress section successfully introduces support for the nginx-ingress-controller, which was the main goal of this PR. The changes maintain the existing structure of the file while adding the necessary flexibility for users to choose between different ingress controllers.

A few points to consider:

  1. The nginx configuration could be expanded to include more specific options when enabled.
  2. The purpose of the new name field in the ratelimit section needs clarification.

These changes enhance the ingress configuration options available in the Yorkie cluster, providing more flexibility as intended. Good job on maintaining backwards compatibility by keeping the existing configurations intact.


Line range hint 69-69: Please clarify the purpose of the new name field in the ratelimit section.

The addition of name: ratelimit in the ratelimit section is noted. While this provides a way to identify the ratelimit configuration, it's not immediately clear how this name will be used or why it was added.

Could you please explain the intended use of this new name field? Is it required for the nginx-ingress-controller configuration, or does it serve another purpose?

To help understand the context, let's check if this name field is used elsewhere in the chart:

✅ Verification successful

Verified: name: ratelimit is correctly implemented.

The name: ratelimit field is consistently referenced across multiple templates, ensuring uniform configuration for the ratelimit component.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usage of 'ratelimit' as a name or reference
rg --type yaml 'name:\s*ratelimit' build/charts/yorkie-cluster
rg --type yaml 'ratelimit\.name' build/charts/yorkie-cluster

Length of output: 1620

Comment on lines +4 to +8
{{ if .Values.ingress.nginx.enabled }}
name: ingress-nginx
{{ else }}
name: {{ .Values.yorkie.name }}
{{ end }}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix indentation for consistent YAML structure

The conditional block for naming has inconsistent indentation, which could lead to YAML parsing errors. Please adjust the indentation to ensure all lines are properly aligned.

Apply this diff to fix the indentation:

 {{ if .Values.ingress.nginx.enabled }}
-  name: ingress-nginx
-  {{ else }}
+name: ingress-nginx
+{{ else }}
 name: {{ .Values.yorkie.name }}
-  {{ end }}
+{{ 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
{{ if .Values.ingress.nginx.enabled }}
name: ingress-nginx
{{ else }}
name: {{ .Values.yorkie.name }}
{{ end }}
{{ if .Values.ingress.nginx.enabled }}
name: ingress-nginx
{{ else }}
name: {{ .Values.yorkie.name }}
{{ end }}
🧰 Tools
🪛 yamllint

[error] 5-5: syntax error: expected , but found ''

(syntax)

Copy link
Member

@hackerwins hackerwins left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution.

@hackerwins hackerwins changed the title Add nginx-ingress-controller config Add nginx-ingress-controller option Sep 30, 2024
@hackerwins hackerwins merged commit 2a29c7d into main Sep 30, 2024
1 check passed
@hackerwins hackerwins deleted the emplam27/ingress branch September 30, 2024 10:38
Copy link
Member

@krapie krapie left a comment

Choose a reason for hiding this comment

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

We might need to consider about the naming conventions of K8s objects we use.

@@ -1,7 +1,11 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
{{ if .Values.ingress.nginx.enabled }}
name: ingress-nginx
Copy link
Member

Choose a reason for hiding this comment

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

Looks like ingress name is just ingress-nginx while we uses {{ .Values.yorkie.name }} for previous settings.

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.

3 participants