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

feat: Add Support for Using Existing Secrets in greptimedb-cluster Helm Chart for Secure Credential Management #150

Merged
merged 7 commits into from
Aug 5, 2024

Conversation

Stephan3555
Copy link
Contributor

@Stephan3555 Stephan3555 commented Aug 2, 2024

This PR introduces a new feature that allows the use of a third-party tool for securely storing credentials outside of the Helm chart.

Currently, the greptimedb-cluster Helm chart does not support this capability, as the 'objectStorage.credentials.secretName' setting only changes the name of the automatically created secret.

With my changes, a new setting, 'objectStorage.credentials.existingSecretName', is added to the values YAML file. By specifying a value for this new setting, the default secret will not be created. Instead, the reference will point to the existing secret specified, allowing for more flexible and secure credential management.

Summary by CodeRabbit

  • New Features

    • Introduced a new configuration option allowing users to specify an existing secret name for object storage, enhancing flexibility in credential management.
    • Added conditional logic to the YAML templates to support the use of existing secret names, preventing the creation of duplicate secrets.
    • Updated the Helm chart version to indicate new features or improvements in the GreptimeDB cluster deployment.
  • Documentation

    • Updated versioning information in the README to reflect the latest Helm chart version.

Copy link

coderabbitai bot commented Aug 2, 2024

Walkthrough

The recent changes enhance the configuration of object storage in the greptimedb-cluster Helm chart by introducing support for an existingSecretName. This allows users to specify a pre-existing secret for object storage credentials, streamlining credential management and preventing the creation of duplicate secrets. Updates to the YAML templates ensure that user-defined secrets take priority, improving usability and adaptability across various deployment scenarios.

Changes

File Change Summary
charts/.../templates/cluster.yaml, charts/.../templates/secret.yaml Enhanced handling of existingSecretName for object storage credentials; added conditional logic to use provided secret or default value, preventing duplicate secrets.
charts/.../values.yaml Added optional configuration option, existingSecretName, for specifying an existing Kubernetes secret for object storage access.
charts/.../Chart.yaml, charts/.../README.md Updated chart version from 0.2.3 to 0.2.5 and app version from 0.9.0 to 0.9.1, indicating new features or improvements.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Template
    participant SecretManager

    User->>Template: Deploy configuration
    Template->>Template: Check existingSecretName
    alt existingSecretName provided
        Template->>SecretManager: Use existing secret
    else no existingSecretName
        Template->>SecretManager: Create new secret
    end
Loading

Poem

🐇 In a land where secrets dwell,
A new option rings a bell!
With existing names in sight,
Credential management feels just right.
Reuse with ease, oh what delight!
For every rabbit's hop, a perfect flight! 🐇✨


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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

Outside diff range, codebase verification and nitpick comments (2)
charts/greptimedb-cluster/templates/secret.yaml (1)

16-16: Unclosed conditional blocks detected in Helm templates.

Please ensure that all conditional blocks are properly closed to avoid rendering issues in the Helm templates. The following files contain unclosed conditional blocks:

  • charts/greptimedb-standalone/templates/serviceaccount.yaml
  • charts/greptimedb-standalone/templates/statefulset.yaml
  • charts/greptimedb-cluster/templates/serviceaccount-meta.yaml
  • charts/greptimedb-cluster/templates/serviceaccount-datanode.yaml
  • charts/greptimedb-cluster/templates/serviceaccount-frontend.yaml
  • charts/greptimedb-standalone/templates/secret.yaml
  • charts/greptimedb-cluster/templates/cluster.yaml
  • charts/greptimedb-cluster/templates/serviceaccount-flownode.yaml
  • charts/greptimedb-operator/templates/serviceaccount.yaml
  • charts/greptimedb-cluster/templates/secret.yaml
  • charts/greptimedb-operator/templates/rolebinding.yaml
  • charts/greptimedb-operator/templates/deployment.yaml
  • charts/greptimedb-operator/templates/role.yaml
  • charts/greptimedb-operator/templates/clusterrolebinding.yaml
  • charts/greptimedb-standalone/templates/podmonitor.yaml
  • charts/greptimedb-operator/templates/clusterrole.yaml
  • charts/greptimedb-standalone/templates/configmap.yaml

Please review and close all conditional blocks appropriately.

Analysis chain

Ensure the closing of all conditional blocks.

Ensure that all conditional blocks are properly closed to avoid any rendering issues in the Helm template.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all conditional blocks are properly closed.

# Test: Search for unclosed conditional blocks. Expect: No unclosed blocks.
rg --type yaml '{{- if' -A 20 | rg -v '{{- end }}'

Length of output: 220


Script:

#!/bin/bash
# Description: Verify that all conditional blocks are properly closed.

# Test: Search for unclosed conditional blocks. Expect: No unclosed blocks.
rg --type yaml '\{\{- if' -A 20 | rg -v '\{\{- end \}'

Length of output: 52849

charts/greptimedb-cluster/templates/cluster.yaml (1)

294-294: Ensure the closing of all conditional blocks.

The verification script indicates that there are multiple instances of {{- if ... without corresponding {{- end }} within a 100-line context. This suggests potential unclosed conditional blocks in the Helm templates.

  • charts/greptimedb-standalone/templates/serviceaccount.yaml
  • charts/greptimedb-standalone/templates/statefulset.yaml
  • charts/greptimedb-standalone/templates/secret.yaml
  • charts/greptimedb-standalone/templates/configmap.yaml
  • charts/greptimedb-standalone/templates/podmonitor.yaml
  • charts/greptimedb-operator/templates/serviceaccount.yaml
  • charts/greptimedb-operator/templates/deployment.yaml
  • charts/greptimedb-operator/templates/role.yaml
  • charts/greptimedb-operator/templates/clusterrolebinding.yaml
  • charts/greptimedb-operator/templates/rolebinding.yaml
  • charts/greptimedb-operator/templates/clusterrole.yaml
  • charts/greptimedb-cluster/templates/secret.yaml
  • charts/greptimedb-cluster/templates/serviceaccount-meta.yaml
  • charts/greptimedb-cluster/templates/serviceaccount-frontend.yaml
  • charts/greptimedb-cluster/templates/cluster.yaml
  • charts/greptimedb-cluster/templates/serviceaccount-flownode.yaml
  • charts/greptimedb-cluster/templates/serviceaccount-datanode.yaml

Please review these files to ensure that all conditional blocks are properly closed to avoid any rendering issues in the Helm templates.

Analysis chain

Ensure the closing of all conditional blocks.

Ensure that all conditional blocks are properly closed to avoid any rendering issues in the Helm template.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all conditional blocks are properly closed.

# Test: Search for unclosed conditional blocks. Expect: No unclosed blocks.
rg --type yaml '{{- if' -A 20 | rg -v '{{- end }}'

Length of output: 220


Script:

#!/bin/bash
# Description: Verify that all conditional blocks are properly closed.

# Test: Search for unclosed conditional blocks. Expect: No unclosed blocks.
rg --type yaml '\{\{- if' -A 50 | rg -v '\{\{- end \}\}'

Length of output: 57902


Script:

#!/bin/bash
# Description: Verify that all conditional blocks are properly closed.

# Test: Search for unclosed conditional blocks. Expect: No unclosed blocks.
rg --type yaml '\{\{- if' -A 100 | rg -v '\{\{- end \}\}'

Length of output: 61307

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between bb8ee9c and d4db508.

Files selected for processing (3)
  • charts/greptimedb-cluster/templates/cluster.yaml (1 hunks)
  • charts/greptimedb-cluster/templates/secret.yaml (2 hunks)
  • charts/greptimedb-cluster/values.yaml (1 hunks)
Additional comments not posted (3)
charts/greptimedb-cluster/templates/secret.yaml (1)

3-4: Ensure proper handling of existingSecretName.

The conditional logic correctly checks for the presence of existingSecretName and skips the creation of a new secret if it is defined. This enhances flexibility and security by allowing the use of existing secrets.

charts/greptimedb-cluster/values.yaml (1)

406-406: Addition of existingSecretName configuration option.

The new configuration option existingSecretName is correctly added as a commented-out line within the objectStorage section. This ensures that it is optional and does not affect existing functionality.

charts/greptimedb-cluster/templates/cluster.yaml (1)

288-290: Ensure proper handling of existingSecretName.

The conditional logic correctly checks for the presence of existingSecretName and uses it as the secretName if it is defined. This enhances flexibility and security by allowing the use of existing secrets.

@Stephan3555 Stephan3555 changed the title Add Support for Using Existing Secrets in greptimedb-cluster Helm Chart for Secure Credential Management feat: Add Support for Using Existing Secrets in greptimedb-cluster Helm Chart for Secure Credential Management Aug 2, 2024
@daviderli614
Copy link
Member

@Stephan3555 Thank for your contribution. This configuration needs to be added to OSS storage as well.

Step

  1. Add OSS storage existSecretName configuration.

  2. Modify the chart version number, is 0.2.4.

  3. Execute make docs to update the documentation.

  4. Push your updated code.

@Stephan3555
Copy link
Contributor Author

Thanks for the review, will take care of it

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d4db508 and 0d26111.

Files selected for processing (1)
  • charts/greptimedb-cluster/templates/cluster.yaml (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • charts/greptimedb-cluster/templates/cluster.yaml

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0d26111 and 4f5c412.

Files selected for processing (1)
  • charts/greptimedb-cluster/Chart.yaml (1 hunks)
Files skipped from review due to trivial changes (1)
  • charts/greptimedb-cluster/Chart.yaml

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4f5c412 and e9de414.

Files selected for processing (2)
  • charts/greptimedb-cluster/README.md (1 hunks)
  • charts/greptimedb-cluster/values.yaml (1 hunks)
Files skipped from review due to trivial changes (1)
  • charts/greptimedb-cluster/README.md
Files skipped from review as they are similar to previous changes (1)
  • charts/greptimedb-cluster/values.yaml

@daviderli614
Copy link
Member

I made some changes to the code.

@zyy17 zyy17 self-requested a review August 5, 2024 07:11
@zyy17
Copy link
Collaborator

zyy17 commented Aug 5, 2024

@Stephan3555 There's an oversight in this PR that I need to explain. I found @daviderli614 helping you modify some code to fix CI errors, which is not recommended for open-source cooperation. Subsequently, I inadvertently approved these changes without fully considering the implications. We sincerely apologize for this mistake. We highly value every contributor's work and believe collaboration and discussion lead to the best outcomes.

I have already approved most of the modifications of you and @daviderli614.

You can double-check the PR and merge it. I hope this will not cause you any inconvenience, and thank you for your contribution.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e9de414 and a8b1351.

Files selected for processing (1)
  • charts/greptimedb-cluster/templates/secret.yaml (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • charts/greptimedb-cluster/templates/secret.yaml

@Stephan3555
Copy link
Contributor Author

I simplified the logic in the secrets.yaml base on your suggestions @zyy17 . May i have another review plz?

@zyy17
Copy link
Collaborator

zyy17 commented Aug 5, 2024

I simplified the logic in the secrets.yaml base on your suggestions @zyy17 . May i have another review plz?

LGTM. When the CI is finished, we can merge the PR.

@zyy17 zyy17 merged commit b7574f9 into GreptimeTeam:main Aug 5, 2024
3 checks passed
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