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

chore(clickhouse): support custom labels and pod labels #550

Merged
merged 2 commits into from
Nov 8, 2024

Conversation

prashant-shahi
Copy link
Member

@prashant-shahi prashant-shahi commented Nov 8, 2024

Chores

  • clickhouse: support custom labels and pod labels

Summary by CodeRabbit

  • New Features
    • Enhanced configurability for ClickHouse installations with new options for custom labels and annotations.
    • Added conditional configurations for Zookeeper nodes and additional volumes.
    • Introduced new fields for labels and pod labels in the ClickHouse and operator configurations.
  • Bug Fixes
    • Improved handling of external and internal Zookeeper configurations based on user-defined values.
  • Chores
    • Updated the ClickHouse Helm chart version from 24.1.8 to 24.1.9.

Copy link

coderabbitai bot commented Nov 8, 2024

Walkthrough

The changes in this pull request enhance the configuration files for ClickHouse installations by introducing conditional blocks for labels, annotations, and volume configurations in the clickhouse-instance.yaml and deployment.yaml files. The values.yaml file has been updated to include new fields for custom labels and annotations for both ClickHouse instances and the operator, improving the flexibility and management of these components in a Kubernetes environment.

Changes

File Path Change Summary
charts/clickhouse/templates/clickhouse-instance/... Added conditional blocks for labels and annotations; updated Zookeeper configuration handling; modified volumes section for additional volumes.
charts/clickhouse/templates/clickhouse-operator/... Introduced conditional inclusion of labels and annotations for the ClickHouse operator deployment.
charts/clickhouse/values.yaml Added new fields for labels and podLabels for both ClickHouse instances and the operator.
charts/clickhouse/Chart.yaml Updated version from 24.1.8 to 24.1.9.

Possibly related PRs

Suggested reviewers

  • srikanthccv
  • nityanandagohain

🐰 In the meadow, where data flows,
Labels and pods now dance in rows.
With Zookeeper's charm, they find their way,
Configurations bright, come out to play!
A hop, a skip, in Kubernetes land,
Custom fields sprout, just as we planned! 🌼

Warning

Tool Failures:

Tool Failure Count:


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b33ac78 and aa85ed4.

📒 Files selected for processing (1)
  • charts/clickhouse/Chart.yaml (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • charts/clickhouse/Chart.yaml

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)
charts/clickhouse/templates/clickhouse-operator/deployment.yaml (1)

8-10: Consider adding validation and documentation for labels.

While the implementation is solid, consider:

  1. Adding validation for label values to ensure they follow Kubernetes label syntax (alphanumeric, '-', '_', or '.' characters)
  2. Including examples in the values.yaml documentation for both clickhouseOperator.labels and clickhouseOperator.podLabels

Example documentation for values.yaml:

clickhouseOperator:
  # -- Additional labels for the ClickHouse operator deployment
  # @default -- {}
  labels: {}
    # app.kubernetes.io/part-of: monitoring
    # environment: prod

  # -- Additional labels for the ClickHouse operator pods
  # @default -- {}
  podLabels: {}
    # app.kubernetes.io/component: database
    # tier: storage

Also applies to: 33-35

🧰 Tools
🪛 yamllint

[warning] 8-8: wrong indentation: expected 2 but found 4

(indentation)


[warning] 9-9: wrong indentation: expected 2 but found 4

(indentation)


[warning] 10-10: wrong indentation: expected 2 but found 4

(indentation)

charts/clickhouse/templates/clickhouse-instance/clickhouse-instance.yaml (1)

137-139: LGTM! Consider documenting label restrictions.

The pod labels implementation looks good. However, it would be helpful to document Kubernetes label restrictions in the values.yaml file to guide users.

Add comments in values.yaml to specify:

  • Label key format: prefix/name (prefix optional)
  • Key length: ≤ 253 characters
  • Value length: ≤ 63 characters
  • Allowed characters: alphanumeric, -, _, .
charts/clickhouse/values.yaml (2)

181-184: Enhance documentation for label fields.

While the implementation is correct, consider improving the documentation by:

  1. Adding descriptions using the -- prefix to maintain consistency with other fields
  2. Including examples of common use cases
-# ClickHouse instance labels
-labels: {}
-# ClickHouse pod labels
-podLabels: {}
+# -- Labels to be added to the ClickHouse instance
+# Example:
+#   labels:
+#     environment: production
+#     team: data-platform
+labels: {}
+# -- Labels to be added to the ClickHouse pods
+# Example:
+#   podLabels:
+#     monitoring: enabled
+#     sidecar.istio.io/inject: "true"
+podLabels: {}

493-496: Enhance documentation for operator label fields.

Similar to the instance labels, consider improving the documentation for operator labels:

-  # ClickHouse operator deployment labels
-  labels: {}
-  # ClickHouse operator pod labels
-  podLabels: {}
+  # -- Labels to be added to the ClickHouse operator deployment
+  # Example:
+  #   labels:
+  #     app.kubernetes.io/component: operator
+  #     app.kubernetes.io/part-of: clickhouse
+  labels: {}
+  # -- Labels to be added to the ClickHouse operator pods
+  # Example:
+  #   podLabels:
+  #     monitoring: enabled
+  #     sidecar.istio.io/inject: "true"
+  podLabels: {}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 3aa9412 and b33ac78.

📒 Files selected for processing (3)
  • charts/clickhouse/templates/clickhouse-instance/clickhouse-instance.yaml (2 hunks)
  • charts/clickhouse/templates/clickhouse-operator/deployment.yaml (2 hunks)
  • charts/clickhouse/values.yaml (2 hunks)
🧰 Additional context used
🪛 yamllint
charts/clickhouse/templates/clickhouse-instance/clickhouse-instance.yaml

[warning] 8-8: wrong indentation: expected 2 but found 4

(indentation)


[warning] 9-9: wrong indentation: expected 2 but found 4

(indentation)


[warning] 10-10: wrong indentation: expected 2 but found 4

(indentation)

charts/clickhouse/templates/clickhouse-operator/deployment.yaml

[warning] 8-8: wrong indentation: expected 2 but found 4

(indentation)


[warning] 9-9: wrong indentation: expected 2 but found 4

(indentation)


[warning] 10-10: wrong indentation: expected 2 but found 4

(indentation)

🔇 Additional comments (5)
charts/clickhouse/templates/clickhouse-operator/deployment.yaml (2)

8-10: LGTM! Well-structured implementation of custom labels.

The conditional block for custom labels is properly implemented using Helm templating. The toYaml function with nindent 4 ensures correct YAML formatting when rendered.

🧰 Tools
🪛 yamllint

[warning] 8-8: wrong indentation: expected 2 but found 4

(indentation)


[warning] 9-9: wrong indentation: expected 2 but found 4

(indentation)


[warning] 10-10: wrong indentation: expected 2 but found 4

(indentation)


33-35: LGTM! Correctly implemented pod-level labels.

The pod labels implementation follows the same consistent pattern and is properly scoped to the pod template level, allowing for granular label management.

charts/clickhouse/templates/clickhouse-instance/clickhouse-instance.yaml (2)

Line range hint 91-103: LGTM! Well-structured Zookeeper configuration.

The implementation properly handles both external and internal Zookeeper configurations with clean conditional logic.

🧰 Tools
🪛 yamllint

[warning] 8-8: wrong indentation: expected 2 but found 4

(indentation)


[warning] 9-9: wrong indentation: expected 2 but found 4

(indentation)


[warning] 10-10: wrong indentation: expected 2 but found 4

(indentation)


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

(syntax)


Line range hint 1-266: Verify label support across related resources.

The implementation looks good overall. Let's verify if similar label support is needed in related resources.

✅ Verification successful

Based on the shell script results, I can now provide a final verification response:

Label support is consistently implemented across resources

The verification shows that label support is properly implemented across all Kubernetes resources in the chart:

  • All resources use appropriate label templates (clickhouse.labels or clickhouseOperator.labels)
  • Custom label support exists where needed (e.g., pod labels, service labels)
  • Label inheritance and selector labels are correctly configured in deployments and services
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if other resources in the chart might need similar label support
echo "Checking for other Kubernetes resources that might need label support..."
fd -e yaml -e tpl . charts/clickhouse/templates -x rg -l 'kind:|Kind:'

# Check for existing label implementations
echo -e "\nChecking existing label implementations..."
fd -e yaml -e tpl . charts/clickhouse/templates -x rg -C2 'labels:|Labels:'

Length of output: 5474

🧰 Tools
🪛 yamllint

[warning] 8-8: wrong indentation: expected 2 but found 4

(indentation)


[warning] 9-9: wrong indentation: expected 2 but found 4

(indentation)


[warning] 10-10: wrong indentation: expected 2 but found 4

(indentation)


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

(syntax)

charts/clickhouse/values.yaml (1)

181-184: Implementation looks good!

The changes successfully add support for custom labels and pod labels for both ClickHouse instance and operator. The implementation:

  • Follows Kubernetes conventions
  • Maintains consistency between instance and operator configurations
  • Uses appropriate default values
  • Is placed logically within the configuration structure

Also applies to: 493-496

@prashant-shahi prashant-shahi merged commit dedcb74 into main Nov 8, 2024
3 checks passed
@prashant-shahi prashant-shahi deleted the chore/ch-custom-labels branch November 8, 2024 15:20
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.

2 participants