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

Include yorkie-mongodb to yorkie-cluster Helm Chart #1031

Merged

Conversation

hyun98
Copy link
Contributor

@hyun98 hyun98 commented Oct 9, 2024

What this PR does / why we need it:

The yorkie-mongodb chart was placed as a subchart of the yorkie-cluster chart.
Therefore, when yorkie-cluster is installed, yorkie-mongodb is also installed.

There was a problem where it was difficult to use the mongodb-sharded chart as a subchart because the namespace was not applied properly, and I fixed this. (related PR)

After confirming the modified PR merge and mongodb-sharded version upgrade, the mongodb-sharded version used by yorkie-mongodb was also upgraded. (7.2.2 -> 9.0.1)

When creating a deployment in yorkie-cluster, I used initContainer to detect that yorkie-mongodb was created successfully, and set yorkie-cluster pods to be created after that.

Which issue(s) this PR fixes:

Fixes #819

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

AS IS: `yorkie-cluster` must be installed after installing the `yorkie-mongodb` chart separately.

TO BE: If install `yorkie-cluster` with the sharded option set, `yorkie-mongodb` is naturally installed.

# How to set yorkie-mongodb sharded options when installing helm chart in yorkie cluster
helm install [RELEASE_NAME] yorkie-team/yorkie-cluster --set=yorkie-mongodb.sharded.enabled=true

Additional documentation:


Checklist:

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

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added a new dependency for yorkie-mongodb with version 0.4.13.
    • Introduced a new configuration section for yorkie-mongodb in the values file.
    • Added initContainers to ensure the database is ready before application startup.
    • Implemented Role-Based Access Control (RBAC) for database status reading.
    • Enhanced Helm chart installation instructions to create a MongoDB namespace.
  • Documentation

    • Updated installation instructions in the README files for yorkie-cluster and yorkie-mongodb.
    • Clarified comments in the README for yorkie-mongodb Helm chart.
  • Bug Fixes

    • Corrected indentation in the values.yaml file for proper YAML formatting.

@hyun98 hyun98 added the enhancement 🌟 New feature or request label Oct 9, 2024
Copy link

coderabbitai bot commented Oct 9, 2024

Walkthrough

The changes in this pull request primarily involve updates to the Helm chart for the yorkie-cluster, including the addition of yorkie-mongodb as a subchart dependency. Key modifications include restructuring the .gitignore file, enhancing the installation instructions in the README files, and adding Kubernetes configurations such as roles and init containers to manage MongoDB dependencies and ensure database readiness. Additional updates include version changes for dependencies and the introduction of new configuration parameters for better namespace management.

Changes

File Change Summary
.gitignore Added /build/charts/yorkie-cluster/charts/yorkie-mongodb/charts/ and removed -/build/charts/yorkie-mongodb/charts/.
build/charts/yorkie-cluster/Chart.yaml Added dependencies section for yorkie-mongodb version 0.4.13 with a conditional inclusion.
build/charts/yorkie-cluster/README.md Updated installation instructions to include kubectl create namespace mongodb and modified Helm command.
build/charts/yorkie-cluster/charts/yorkie-mongodb/Chart.yaml Updated mongodb-sharded dependency version from 7.2.2 to 9.0.1.
build/charts/yorkie-cluster/charts/yorkie-mongodb/README.md Clarified installation command comment from yorkie monitoring to yorkie mongodb.
build/charts/yorkie-cluster/charts/yorkie-mongodb/values.yaml Added namespaceOverride: mongodb under mongos configuration.
build/charts/yorkie-cluster/templates/yorkie/deployment.yaml Introduced initContainers block for waiting on MongoDB job completion before starting Yorkie.
build/charts/yorkie-cluster/templates/yorkie/role.yaml Added Role, RoleBinding, and ServiceAccount for managing MongoDB access based on sharding configuration.
build/charts/yorkie-cluster/values.yaml Added new yorkie-mongodb configuration section with various parameters.

Assessment against linked issues

Objective Addressed Explanation
Include yorkie-mongodb to yorkie-cluster Helm chart as subchart (#819)

Possibly related PRs


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 702ad00 and 125b896.

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

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

(syntax)

🔇 Additional comments (4)
build/charts/yorkie-cluster/templates/yorkie/role.yaml (4)

35-35: LGTM! Proper conditional closing.

The closing statement correctly matches the opening conditional and uses the -}} syntax to trim whitespace, which is good practice in Helm templates.


12-26: 🛠️ Refactor suggestion

Consider updating names for clarity while maintaining correct configuration.

The RoleBinding is correctly configured, linking the Role to the ServiceAccount and using dynamic namespaces for flexibility. However, to improve clarity, consider the following name changes:

  1. For the RoleBinding (line 17):
name: db-provision-job-status-reader
  1. For the ServiceAccount reference (line 21):
name: yorkie-db-provision-job-status-reader

These changes align with previous suggestions and make the purpose of these resources more explicit.


28-34: 🛠️ Refactor suggestion

Update ServiceAccount name for consistency and clarity.

The ServiceAccount is correctly configured with a dynamic namespace. To improve clarity and maintain consistency with the earlier suggestions, consider changing the ServiceAccount name:

name: yorkie-db-provision-job-status-reader

This change will make the purpose of the ServiceAccount clearer and maintain consistency across the RBAC resources.


1-10: LGTM! Role definition looks good.

The Role is well-defined with appropriate permissions and follows the principle of least privilege. The conditional statement ensures that the RBAC resources are only created when needed.

Regarding the yamllint error:

The reported syntax error is likely a false positive due to the Helm templating syntax. To verify, run the following command:

If the command executes without errors, the template is valid, and you can safely ignore the yamllint warning.

🧰 Tools
🪛 yamllint

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

(syntax)


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

🧹 Outside diff range and nitpick comments (9)
build/charts/yorkie-cluster/templates/yorkie/role.yaml (3)

2-10: LGTM: Well-defined Role with appropriate permissions

The Role "db-status-reader" is well-defined with appropriate read-only permissions for jobs in the batch API group. This aligns with the principle of least privilege and is likely used to check the status of database-related jobs.

Consider adding a comment to explain the purpose of this Role, for example:

kind: Role
metadata:
  namespace: {{ index .Values "yorkie-mongodb" "namespace" }}
  name: db-status-reader
  # This role allows reading the status of database-related jobs

14-26: LGTM: Correct RoleBinding configuration

The RoleBinding "read-db-status" correctly associates the "db-status-reader" Role with the "yorkie-db-service-account" ServiceAccount. The use of different namespaces for the RoleBinding and ServiceAccount aligns with the PR objectives, allowing the Yorkie cluster to access MongoDB status across namespaces.

Consider adding a comment to explain the cross-namespace binding, for example:

kind: RoleBinding
metadata:
  name: read-db-status
  namespace: {{ index .Values "yorkie-mongodb" "namespace" }}
  # This RoleBinding allows the Yorkie cluster to access MongoDB status across namespaces

30-34: LGTM: ServiceAccount correctly defined

The ServiceAccount "yorkie-db-service-account" is correctly defined and scoped to the Yorkie cluster namespace. This setup is consistent with the RoleBinding configuration and will allow the Yorkie cluster to access MongoDB status.

Consider adding a comment to explain the purpose of this ServiceAccount, for example:

kind: ServiceAccount
metadata:
  name: yorkie-db-service-account
  namespace: {{ .Values.yorkie.namespace }}
  # This ServiceAccount is used by the Yorkie cluster to access MongoDB status
build/charts/yorkie-cluster/values.yaml (2)

74-81: LGTM! Consider adding more configuration options and documentation.

The new yorkie-mongodb configuration section aligns well with the PR objectives. It provides essential settings for integrating MongoDB as a subchart. However, consider the following suggestions to enhance flexibility and usability:

  1. Add comments explaining each configuration option, especially the sharded.enabled flag.
  2. Consider adding more configuration options that users might need to customize, such as authentication settings, resource limits, or storage configurations.
  3. Include a reference to the yorkie-mongodb chart documentation for more advanced settings.

Here's an example of how you could enhance the configuration:

# Configuration for yorkie-mongodb
yorkie-mongodb:
  # Name of the MongoDB deployment
  name: mongodb
  # Namespace where MongoDB will be deployed
  namespace: mongodb
  # Port on which MongoDB will listen
  port: 27017
  # Kubernetes cluster domain
  clusterDomain: cluster.local
  # Sharded cluster configuration
  sharded:
    # Enable sharded cluster setup
    enabled: false
  # Add more configuration options as needed, e.g.:
  # auth:
  #   enabled: false
  #   rootPassword: ""
  # resources:
  #   limits:
  #     cpu: 1
  #     memory: 1Gi
  # For more advanced settings, refer to the yorkie-mongodb chart documentation:
  # https://github.com/yorkie-team/yorkie/tree/main/build/charts/yorkie-mongodb
🧰 Tools
🪛 yamllint

[error] 81-81: no new line character at the end of file

(new-line-at-end-of-file)


81-81: Add a newline at the end of the file.

To adhere to best practices and prevent potential issues with some tools, please add a newline character at the end of the file.

Apply this change to the last line of the file:

   sharded:
     enabled: false
+
🧰 Tools
🪛 yamllint

[error] 81-81: no new line character at the end of file

(new-line-at-end-of-file)

build/charts/yorkie-cluster/README.md (1)

Line range hint 1-85: Overall, excellent improvements to the installation instructions.

The changes made to this README file successfully address the PR objectives and the concerns raised in issue #819. The installation process for the yorkie-cluster has been simplified, and the integration of yorkie-mongodb as a subchart is now clearly reflected in the instructions.

To further enhance the documentation:

Consider adding a brief explanation of what the yorkie-mongodb.sharded.enabled=true option does, perhaps in a comment or a note below the installation command. This would help users understand the implications of enabling sharding during installation.

build/charts/yorkie-cluster/templates/yorkie/deployment.yaml (1)

89-89: Add a newline character at the end of the file.

To adhere to best practices and resolve the linter warning, please add a newline character at the end of the file.

Apply this change:

 {{ toYaml .Values.yorkie.resources | nindent 12 }}
+
🧰 Tools
🪛 yamllint

[error] 89-89: no new line character at the end of file

(new-line-at-end-of-file)

build/charts/yorkie-cluster/charts/yorkie-mongodb/values.yaml (2)

176-176: Approved: Explicit namespace override for mongos service.

The addition of namespaceOverride: mongodb for the mongos service is a good practice. It ensures that the mongos pods are deployed in the correct namespace, addressing the namespace-related issues mentioned in the PR objectives.

For consistency, consider adding similar namespaceOverride fields to the configsvr and shardsvr sections if they should also be deployed in the mongodb namespace. If the current setup is intentional, it might be helpful to add a comment explaining why only mongos has this override.


Line range hint 1-238: Overall configuration looks good, with room for future enhancements.

The configuration for the MongoDB sharded cluster is comprehensive and well-structured. The addition of the namespaceOverride for the mongos service addresses the namespace-related issues mentioned in the PR objectives.

Some suggestions for future improvements:

  1. Consider enabling and configuring the commented-out probe sections (liveness, readiness, and startup probes) for better health monitoring of the MongoDB components.
  2. Review the resource configurations (currently empty for some components) to ensure optimal performance in production environments.
  3. Evaluate if the metrics configuration (currently enabled but with podMonitor disabled) meets your monitoring requirements.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between fcf6fbf and 84482a1.

⛔ Files ignored due to path filters (3)
  • build/charts/yorkie-cluster/Chart.lock is excluded by !**/*.lock
  • build/charts/yorkie-cluster/charts/yorkie-mongodb/Chart.lock is excluded by !**/*.lock
  • build/charts/yorkie-mongodb/Chart.lock is excluded by !**/*.lock
📒 Files selected for processing (9)
  • .gitignore (1 hunks)
  • build/charts/yorkie-cluster/Chart.yaml (1 hunks)
  • build/charts/yorkie-cluster/README.md (1 hunks)
  • build/charts/yorkie-cluster/charts/yorkie-mongodb/Chart.yaml (1 hunks)
  • build/charts/yorkie-cluster/charts/yorkie-mongodb/README.md (1 hunks)
  • build/charts/yorkie-cluster/charts/yorkie-mongodb/values.yaml (1 hunks)
  • build/charts/yorkie-cluster/templates/yorkie/deployment.yaml (2 hunks)
  • build/charts/yorkie-cluster/templates/yorkie/role.yaml (1 hunks)
  • build/charts/yorkie-cluster/values.yaml (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • build/charts/yorkie-cluster/charts/yorkie-mongodb/README.md
🧰 Additional context used
🪛 yamllint
build/charts/yorkie-cluster/templates/yorkie/deployment.yaml

[error] 89-89: no new line character at the end of file

(new-line-at-end-of-file)

build/charts/yorkie-cluster/templates/yorkie/role.yaml

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

(syntax)

build/charts/yorkie-cluster/values.yaml

[error] 81-81: no new line character at the end of file

(new-line-at-end-of-file)

🔇 Additional comments (9)
build/charts/yorkie-cluster/charts/yorkie-mongodb/Chart.yaml (1)

18-18: Verify compatibility with the updated mongodb-sharded version.

The mongodb-sharded dependency has been updated from version 7.2.2 to 9.0.1, which is a significant version jump. This change aligns with the PR objectives.

To ensure compatibility and proper functioning:

  1. Verify that this version update is intentional and aligns with the project's requirements.
  2. Check the changelog of mongodb-sharded between versions 7.2.2 and 9.0.1 for any breaking changes or new features that might affect the yorkie-mongodb chart.
  3. Ensure that all other components in the yorkie-cluster are compatible with this new version.
  4. Update any relevant documentation or README files to reflect this version change.

Please review the results of these checks and make any necessary adjustments to ensure smooth integration of the new mongodb-sharded version.

build/charts/yorkie-cluster/Chart.yaml (2)

Line range hint 1-22: LGTM! Changes align with PR objectives.

The addition of the yorkie-mongodb dependency in the Chart.yaml file successfully addresses the main objective of this PR. The dependency is correctly specified with an appropriate condition for enabling the sharded setup. The chart and app versions are consistent, and the overall formatting of the file is correct.


18-21: LGTM! Consider verifying the yorkie-mongodb version.

The addition of the yorkie-mongodb dependency aligns well with the PR objectives. The condition for enabling it based on the sharded setup is appropriate. However, it's worth double-checking if 0.4.13 is the latest stable version of yorkie-mongodb.

To verify the latest version of yorkie-mongodb, you can run:

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

1-1: LGTM: Conditional creation of RBAC resources

The conditional statement ensures that the RBAC resources are only created when sharding is enabled for yorkie-mongodb. This is a good practice to avoid creating unnecessary resources and aligns well with the PR objectives.

Also applies to: 35-35

🧰 Tools
🪛 yamllint

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

(syntax)


1-1: Ignore yamllint error: False positive due to Helm template directive

The yamllint error reported for line 1 appears to be a false positive. The {{- if ... }} syntax is valid for Helm templates but may not be recognized by yamllint. This error can be safely ignored as it doesn't affect the functionality of the Helm chart.

🧰 Tools
🪛 yamllint

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

(syntax)


1-35: Overall assessment: Well-structured RBAC configuration for Yorkie cluster

This file provides a well-structured and appropriate RBAC configuration for the Yorkie cluster to access MongoDB status. Key points:

  1. Conditional creation of resources based on MongoDB sharding configuration.
  2. Proper Role definition with least privilege principle.
  3. Correct RoleBinding setup allowing cross-namespace access.
  4. Appropriate ServiceAccount definition.

The implementation aligns well with the PR objectives and demonstrates good use of Kubernetes RBAC and Helm templating. The minor suggestions for adding comments will further improve the maintainability of the chart.

🧰 Tools
🪛 yamllint

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

(syntax)

.gitignore (1)

74-74: LGTM: Gitignore updated to reflect new chart structure

This change correctly updates the .gitignore file to ignore the yorkie-mongodb charts within the yorkie-cluster directory. This aligns with the PR objective of including yorkie-mongodb as a subchart of yorkie-cluster, reflecting the new directory structure for the integrated charts.

build/charts/yorkie-cluster/README.md (1)

29-34: Excellent addition of the MongoDB namespace creation step.

The inclusion of the kubectl create namespace yorkie command is a crucial improvement. It ensures that the necessary namespace exists before the chart installation, which is essential for the integration of yorkie-mongodb as a subchart. This change directly addresses the objective of simplifying the installation process as mentioned in issue #819.

build/charts/yorkie-cluster/templates/yorkie/deployment.yaml (1)

89-89: LGTM: Proper use of Helm templating for resource configuration.

The use of {{ toYaml .Values.yorkie.resources | nindent 12 }} is a correct and flexible way to include resource configurations from the values file. This approach allows for easy customization of resource limits and requests.

🧰 Tools
🪛 yamllint

[error] 89-89: no new line character at the end of file

(new-line-at-end-of-file)

Comment on lines 36 to 37
helm install [RELEASE_NAME] yorkie-team/yorkie-cluster --set=yorkie-mongodb.sharded.enable
d=true
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Great addition of the sharding option, but there's a small typo.

The inclusion of the yorkie-mongodb.sharded.enabled=true option in the Helm install command is an excellent improvement. It allows users to easily enable sharding during installation, which aligns with the PR objectives.

However, there's a typo in the command that needs to be fixed:

Please correct the typo by applying this change:

-helm install [RELEASE_NAME] yorkie-team/yorkie-cluster --set=yorkie-mongodb.sharded.enable
-d=true
+helm install [RELEASE_NAME] yorkie-team/yorkie-cluster --set=yorkie-mongodb.sharded.enabled=true

This will ensure that users can copy-paste the command without encountering errors.

📝 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
helm install [RELEASE_NAME] yorkie-team/yorkie-cluster --set=yorkie-mongodb.sharded.enable
d=true
helm install [RELEASE_NAME] yorkie-team/yorkie-cluster --set=yorkie-mongodb.sharded.enabled=true

Comment on lines 35 to 66
{{ if index .Values "yorkie-mongodb" "sharded" "enabled"}}
initContainers:
- name: wait-db
image: bitnami/kubectl:latest
command:
- /bin/sh
- -c
- |
echo "Wait db start"
while true; do
job_status=$(kubectl get job -n $NAMESPACE $JOB_NAME -o jsonpath='{.status.conditions[?(@.type=="Complete")].status}')
if [ "$job_status" = "True" ]; then
echo "Job completed"
break
fi
echo "Waiting for job to complete..."
sleep 5
done
env:
- name: NAMESPACE
value: "{{ index .Values "yorkie-mongodb" "namespace" }}"
- name: JOB_NAME
value: "{{ index .Values "yorkie-mongodb" "name" }}-setup-job"
volumeMounts:
- name: kubeconfig
mountPath: /root/.kube
subPath: config
volumes:
- name: kubeconfig
emptyDir: { }
serviceAccountName: yorkie-db-service-account
{{ end }}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve initContainer configuration for better reliability and security.

The addition of an initContainer to wait for the MongoDB setup job is a good practice. However, there are a few points to consider:

  1. Instead of using bitnami/kubectl:latest, specify a fixed version to ensure consistency across deployments.
  2. Consider adding a timeout mechanism to the while loop to prevent infinite waiting if the job fails.
  3. The use of a dedicated service account (yorkie-db-service-account) is good for security. Ensure this service account has the minimum required permissions.

Here's a suggested improvement for the command:

command:
  - /bin/sh
  - -c
  - |
    echo "Waiting for db to start"
    timeout=300
    start_time=$(date +%s)
    while true; do
      job_status=$(kubectl get job -n $NAMESPACE $JOB_NAME -o jsonpath='{.status.conditions[?(@.type=="Complete")].status}')
      if [ "$job_status" = "True" ]; then
        echo "Job completed successfully"
        exit 0
      fi
      current_time=$(date +%s)
      elapsed_time=$((current_time - start_time))
      if [ $elapsed_time -ge $timeout ]; then
        echo "Timeout waiting for job to complete"
        exit 1
      fi
      echo "Waiting for job to complete... (${elapsed_time}s elapsed)"
      sleep 5
    done

This modification adds a 5-minute timeout and provides more informative logging.

@krapie krapie self-requested a review October 9, 2024 13:18
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.

Thank you for your contribution!
I'm very happy to see you have also made contribution to bitnami to finish this PR!

I have one thing to suggest, which is to provide options for the users to select whether to install with standalone mongodb, or sharded mongodb? The reason for this is to allow users to provision lightweight resources through standalone mongodb.

We had standalone mongodb in the past, and you can refer it to this PR #769.

Also, I have left some comments regarding wording and syntax specifications.

build/charts/yorkie-cluster/README.md Outdated Show resolved Hide resolved
build/charts/yorkie-cluster/templates/yorkie/role.yaml Outdated Show resolved Hide resolved
build/charts/yorkie-cluster/values.yaml Outdated Show resolved Hide resolved
build/charts/yorkie-cluster/values.yaml Outdated Show resolved Hide resolved
kind: Role
metadata:
namespace: {{ index .Values "yorkie-mongodb" "namespace" }}
name: db-status-reader
Copy link
Member

Choose a reason for hiding this comment

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

How about changing the name more specifically like:

  • db-status-reader to db-job-status-reader
  • read-db-status to db-provision-job-status-reader
  • yorkie-db-service-account to yorkie-db-provision-job-status-reader

to clarify the purpose of the resources?

- refactor typo and wording
- set sharded=true to default option
- remove yorkie-mongodb dependency condition for standalone mode
@hyun98 hyun98 requested a review from krapie October 19, 2024 07:11
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: 2

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

1-10: LGTM with a minor suggestion for improved readability.

The Role definition looks good. The permissions are appropriate for reading job statuses, and the name has been updated as per the previous review comment.

Consider adding quotes around the enabled value in the conditional statement for better readability:

{{- if index .Values "yorkie-mongodb" "sharded" "enabled" }}

This change doesn't affect functionality but improves consistency with other Helm templates.

🧰 Tools
🪛 yamllint

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

(syntax)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 208fa91 and 3b47fba.

⛔ Files ignored due to path filters (1)
  • build/charts/yorkie-cluster/Chart.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • build/charts/yorkie-cluster/Chart.yaml (1 hunks)
  • build/charts/yorkie-cluster/README.md (1 hunks)
  • build/charts/yorkie-cluster/templates/yorkie/deployment.yaml (1 hunks)
  • build/charts/yorkie-cluster/templates/yorkie/role.yaml (1 hunks)
  • build/charts/yorkie-cluster/values.yaml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • build/charts/yorkie-cluster/Chart.yaml
  • build/charts/yorkie-cluster/README.md
  • build/charts/yorkie-cluster/templates/yorkie/deployment.yaml
  • build/charts/yorkie-cluster/values.yaml
🧰 Additional context used
🪛 yamllint
build/charts/yorkie-cluster/templates/yorkie/role.yaml

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

(syntax)

🔇 Additional comments (1)
build/charts/yorkie-cluster/templates/yorkie/role.yaml (1)

1-35: Improve readability with newlines and ignore false positive.

The overall structure of the file is correct, but we can improve its readability.

  1. Add newlines between the different resource definitions:
    • After line 11 (end of Role definition)
    • After line 27 (end of RoleBinding definition)

This change will improve the readability of the file.

  1. Regarding the yamllint error:
    [error] 1-1: syntax error: expected the node content, but found '-'
    
    This is a false positive due to the Helm template syntax (specifically the {{- at the beginning of the file). We can safely ignore this error as it doesn't affect the functionality of the template.
🧰 Tools
🪛 yamllint

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

(syntax)

Comment on lines 14 to 26
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: read-db-status
namespace: {{ index .Values "yorkie-mongodb" "namespace" }}
subjects:
- kind: ServiceAccount
name: yorkie-db-service-account
namespace: {{ .Values.yorkie.namespace }}
roleRef:
kind: Role
name: db-provisioning-job-status-reader
apiGroup: rbac.authorization.k8s.io
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider updating the RoleBinding and ServiceAccount names for clarity.

The RoleBinding configuration looks correct, but we can improve the naming to better reflect its purpose.

Consider the following name changes:

  1. For the RoleBinding (line 17):
name: db-provision-job-status-reader
  1. For the ServiceAccount (line 21):
name: yorkie-db-provision-job-status-reader

These changes align with the previous review suggestions and make the purpose of these resources more explicit.

Comment on lines 30 to 34
apiVersion: v1
kind: ServiceAccount
metadata:
name: yorkie-db-service-account
namespace: {{ .Values.yorkie.namespace }}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Update ServiceAccount name for consistency.

The ServiceAccount definition is correct, but let's ensure consistency with the naming convention suggested earlier.

Change the ServiceAccount name to match the suggestion in the RoleBinding:

name: yorkie-db-provision-job-status-reader

This change will make the purpose of the ServiceAccount clearer and maintain consistency across the RBAC resources.

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.

Thank you for your contribution! 👍🏼

@krapie krapie merged commit 9ea02a2 into yorkie-team:main Oct 19, 2024
1 check passed
krapie pushed a commit that referenced this pull request Oct 19, 2024
This commit includes yorkie-mongodb to yorkie-cluster Helm chart
as subchart to fully provide Yorkie cluster feature including
DB layer when installing yorkie-cluster Helm chart.
hackerwins pushed a commit that referenced this pull request Oct 19, 2024
Include yorkie-mongodb to yorkie-cluster Helm chart as subchart to fully
provide Yorkie cluster feature including DB layer when installing
yorkie-cluster Helm chart.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 🌟 New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Include yorkie-mongodb to yorkie-cluster Helm Chart
2 participants