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 additional labels to the kubernetes resources #218

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

nlamirault
Copy link

@nlamirault nlamirault commented Jan 10, 2025

Summary by CodeRabbit

  • New Features

    • Added support for custom labels across GreptimeDB Helm charts.
    • Introduced additionalLabels configuration option in standalone, cluster, and operator charts.
    • Enhanced resource metadata with standardized Kubernetes labels.
  • Improvements

    • Implemented consistent labeling strategies across different chart templates.
    • Added component and part-of labels for better resource identification.
  • Chores

    • Updated helper templates to support dynamic label generation.
    • Refined label generation in various Kubernetes resource templates.
    • Updated version numbers in Chart.yaml and README.md files for all charts.

Signed-off-by: Nicolas Lamirault <[email protected]>
Signed-off-by: Nicolas Lamirault <[email protected]>
Signed-off-by: Nicolas Lamirault <[email protected]>
Signed-off-by: Nicolas Lamirault <[email protected]>
Copy link
Contributor

coderabbitai bot commented Jan 10, 2025

Walkthrough

The pull request introduces a comprehensive labeling enhancement across multiple Helm charts for GreptimeDB (cluster, operator, and standalone). The changes focus on adding a new additionalLabels configuration option and implementing a consistent method for generating and applying labels to Kubernetes resources. This allows users to dynamically add custom labels to resources while maintaining a standardized approach to labeling across different chart templates.

Changes

File/Path Change Summary
charts/*/values.yaml Added additionalLabels: {} configuration option in cluster, operator, and standalone charts
charts/*/templates/_helpers.tpl Enhanced label generation templates with additional standard Kubernetes labels and support for custom labels
charts/*/templates/*.yaml Added labels section to various Kubernetes resource templates using new label generation functions

Possibly related PRs

  • refactor: add labels and annotations for pvc #219: The changes in this PR involve adding labels and annotations fields to the datanode.storage configuration in the GreptimeDBCluster YAML, which is directly related to the new labels functionality introduced in the main PR for the greptimedb-cluster Helm chart.

Suggested reviewers

  • daviderli614
  • evenyag
  • MichaelScofield

Poem

🐰 Labels, labels everywhere,
Hopping through Kubernetes with flair!
From cluster to standalone, we'll tag
Every resource without a drag
CodeRabbit's charts now shine so bright! 🏷️


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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
Contributor

@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

🧹 Nitpick comments (2)
charts/greptimedb-operator/templates/_helpers.tpl (1)

54-59: LGTM! Good alignment with Kubernetes recommended labels.

The added labels (app.kubernetes.io/component and app.kubernetes.io/part-of) follow Kubernetes best practices for metadata management. The implementation of additionalLabels provides good flexibility for custom labels.

Consider adding validation for additionalLabels to ensure they don't override the standard Kubernetes labels. Example:

 {{- with .Values.additionalLabels }}
+{{- range $key, $value := . }}
+{{- if not (hasPrefix "app.kubernetes.io/" $key) }}
 {{ toYaml . }}
+{{- end }}
+{{- end }}
 {{- end }}
charts/greptimedb-operator/templates/serviceaccount.yaml (1)

Line range hint 1-1: Consider adding documentation for label usage and validation.

The labeling system is well-implemented across all charts. To enhance maintainability and user experience, consider:

  1. Adding documentation in the chart's README about:
    • Available label customization options
    • Best practices for using additionalLabels
    • Examples of common label configurations
  2. Adding validation for additionalLabels in values.yaml schema (if using JSON Schema validation)
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 03ebef0 and 5caa129.

📒 Files selected for processing (24)
  • charts/greptimedb-cluster/templates/_helpers.tpl (1 hunks)
  • charts/greptimedb-cluster/templates/cluster.yaml (1 hunks)
  • charts/greptimedb-cluster/templates/debug-depoyment.yaml (1 hunks)
  • charts/greptimedb-cluster/templates/grafana-dashboards-configmap.yaml (1 hunks)
  • charts/greptimedb-cluster/templates/secret.yaml (1 hunks)
  • charts/greptimedb-cluster/templates/serviceaccount-datanode.yaml (1 hunks)
  • charts/greptimedb-cluster/templates/serviceaccount-flownode.yaml (1 hunks)
  • charts/greptimedb-cluster/templates/serviceaccount-frontend.yaml (1 hunks)
  • charts/greptimedb-cluster/templates/serviceaccount-meta.yaml (1 hunks)
  • charts/greptimedb-cluster/templates/users-auth-secret.yaml (1 hunks)
  • charts/greptimedb-cluster/values.yaml (1 hunks)
  • charts/greptimedb-operator/templates/_helpers.tpl (1 hunks)
  • charts/greptimedb-operator/templates/clusterrole.yaml (1 hunks)
  • charts/greptimedb-operator/templates/clusterrolebinding.yaml (1 hunks)
  • charts/greptimedb-operator/templates/role.yaml (1 hunks)
  • charts/greptimedb-operator/templates/rolebinding.yaml (1 hunks)
  • charts/greptimedb-operator/templates/service.yaml (1 hunks)
  • charts/greptimedb-operator/templates/serviceaccount.yaml (1 hunks)
  • charts/greptimedb-operator/values.yaml (1 hunks)
  • charts/greptimedb-standalone/templates/_helpers.tpl (1 hunks)
  • charts/greptimedb-standalone/templates/podmonitor.yaml (1 hunks)
  • charts/greptimedb-standalone/templates/secret.yaml (1 hunks)
  • charts/greptimedb-standalone/templates/users-auth-secret.yaml (1 hunks)
  • charts/greptimedb-standalone/values.yaml (1 hunks)
🧰 Additional context used
🪛 yamllint (1.35.1)
charts/greptimedb-cluster/templates/cluster.yaml

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

(syntax)

charts/greptimedb-standalone/templates/podmonitor.yaml

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

(indentation)


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

(indentation)

🔇 Additional comments (23)
charts/greptimedb-cluster/templates/_helpers.tpl (1)

54-59: LGTM! Consistent implementation with operator template.

The labels implementation maintains consistency with the operator chart while correctly scoping the values to the cluster component. Good job on maintaining a standardized approach across charts.

charts/greptimedb-standalone/templates/_helpers.tpl (1)

42-47: LGTM! Maintains consistency across all chart templates.

The labeling implementation correctly follows the established pattern while using appropriate standalone-specific values. The integration with existing helpers is clean and well-maintained.

charts/greptimedb-operator/templates/serviceaccount.yaml (1)

7-8: LGTM! Clean implementation of labels in ServiceAccount.

The labels are correctly implemented in the ServiceAccount metadata, with proper indentation and template inclusion.

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

7-8: LGTM! Verify template existence.

The label implementation follows Helm best practices and maintains proper indentation.

Let's verify the existence and content of the labels template:

✅ Verification successful

Template verification successful

The greptimedb-cluster.labels template and its dependencies are properly implemented, following Kubernetes labeling best practices and Helm conventions.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the existence and content of the labels template
rg -U "greptimedb-cluster\.labels" charts/greptimedb-cluster/templates/_helpers.tpl

Length of output: 128


Script:

#!/bin/bash
# Get full template definition with context
rg -U "greptimedb-cluster\.labels" charts/greptimedb-cluster/templates/_helpers.tpl -A 10

Length of output: 530


Script:

#!/bin/bash
# Check nested template definitions
rg -U "greptimedb-cluster\.(chart|selectorLabels)" charts/greptimedb-cluster/templates/_helpers.tpl -A 5

Length of output: 754

charts/greptimedb-cluster/templates/users-auth-secret.yaml (1)

7-8: LGTM! Consistent with labeling pattern.

The label implementation is consistent with other resources and maintains proper conditional logic.

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

7-8: LGTM! Maintains consistency.

The implementation maintains consistency with other ServiceAccount resources.

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

7-8: LGTM! Consistent implementation.

The label implementation maintains consistency with other ServiceAccount resources.

charts/greptimedb-standalone/templates/users-auth-secret.yaml (1)

7-8: LGTM! Verify standalone template.

The implementation maintains consistency with the cluster chart pattern while appropriately using standalone-specific templates.

Let's verify the standalone labels template:

✅ Verification successful

Labels template verification successful

The greptimedb-standalone.labels template is properly implemented with all required Kubernetes metadata labels, selector labels, and follows best practices for Helm charts.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the existence and content of the standalone labels template
rg -U "greptimedb-standalone\.labels" charts/greptimedb-standalone/templates/_helpers.tpl

Length of output: 137


Script:

#!/bin/bash
# Get full template content with context
rg -U "greptimedb-standalone\.labels" charts/greptimedb-standalone/templates/_helpers.tpl -A 10

Length of output: 551


Script:

#!/bin/bash
# Get selector labels template content
rg -U "greptimedb-standalone\.selectorLabels" charts/greptimedb-standalone/templates/_helpers.tpl -A 5

Length of output: 541

charts/greptimedb-cluster/templates/grafana-dashboards-configmap.yaml (1)

9-10: LGTM! Labels properly implemented for ConfigMap

The implementation follows Helm best practices with proper template inclusion and indentation.

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

7-8: LGTM! Labels properly implemented for ServiceAccount

The implementation correctly adds labels while maintaining existing conditional logic and annotations.

charts/greptimedb-operator/templates/service.yaml (1)

7-8: Verify consistency between labels and selector

While the label implementation looks good, ensure that the labels generated by the template are consistent with the selector labels used in the spec section, particularly the app.kubernetes.io/name label.

✅ Verification successful

Labels and selector are properly aligned

The labels implementation is consistent with the selector. The app.kubernetes.io/name label used in the selector is included in the main labels through the selectorLabels template, and both use the same template function to generate the value.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check consistency between labels template and selector
echo "Checking label consistency in service.yaml..."
rg "greptimedb-operator\.labels" charts/greptimedb-operator/templates/_helpers.tpl -A 5
echo "Compare with selector labels:"
rg "selector:" charts/greptimedb-operator/templates/service.yaml -A 2

Length of output: 675


Script:

#!/bin/bash
# Check selectorLabels template definition
echo "Checking selectorLabels template:"
rg "greptimedb-operator\.selectorLabels" charts/greptimedb-operator/templates/_helpers.tpl -A 2

Length of output: 484

charts/greptimedb-operator/templates/clusterrolebinding.yaml (1)

6-7: LGTM! Labels properly implemented for ClusterRoleBinding

The implementation follows Helm best practices and maintains consistency with other RBAC resources.

charts/greptimedb-operator/templates/rolebinding.yaml (1)

7-8: LGTM! Labels properly implemented for RoleBinding

The implementation follows Helm best practices and maintains consistency with other RBAC resources.

charts/greptimedb-operator/templates/role.yaml (1)

7-8: LGTM! Labels properly added to Role metadata

The addition of labels using the common template function ensures consistent labeling across operator resources.

charts/greptimedb-standalone/templates/podmonitor.yaml (1)

8-11: LGTM! Good approach to label merging

The implementation correctly combines both standard labels and monitoring-specific labels, maintaining flexibility while ensuring consistency.

🧰 Tools
🪛 yamllint (1.35.1)

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

(indentation)


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

(indentation)

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

9-9: LGTM! Labels properly added while preserving deployment selectors

The implementation correctly adds common labels while maintaining the necessary app label for pod selection.

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

8-9: LGTM! Labels properly added to Secret metadata

The addition of labels follows the consistent pattern while maintaining the security-sensitive aspects of the Secret resource.

charts/greptimedb-standalone/templates/secret.yaml (1)

8-9: LGTM! Labels properly added to Secret metadata

The implementation maintains consistency with other resources while properly handling the Secret's sensitive nature.

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

15-16: LGTM! Well-structured addition of additionalLabels configuration.

The addition follows Helm chart best practices with proper documentation and initialization.

charts/greptimedb-operator/templates/clusterrole.yaml (1)

6-7: LGTM! Proper implementation of Kubernetes metadata labels.

The addition of labels using the template helper ensures consistent labeling across resources.

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

19-20: LGTM! Consistent implementation of additionalLabels configuration.

The addition maintains consistency with other chart components and follows the same documentation pattern.

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

6-7: LGTM! Proper implementation of Kubernetes metadata labels.

The addition of labels at the top level ensures proper propagation to all resources and maintains consistency with Kubernetes labeling practices.

🧰 Tools
🪛 yamllint (1.35.1)

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

(syntax)

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

11-12: LGTM! Consistent implementation of additionalLabels configuration.

The addition maintains consistency with other chart components and follows the established pattern for configuration and documentation.

@nlamirault nlamirault changed the title Refactoring labels feat: Refactoring labels Jan 11, 2025
@daviderli614
Copy link
Member

daviderli614 commented Jan 13, 2025

Hi @nlamirault
We can bump the following chart version:

Next, update the chart docs using the command make docs.

Copy link
Contributor

@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

🧹 Nitpick comments (1)
charts/greptimedb-standalone/README.md (1)

53-53: Enhance additionalLabels documentation with Kubernetes best practices.

While the description is clear, it would be helpful to add references to Kubernetes label best practices and provide examples. Consider expanding the description to:

additional labels to add to all resources (see https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/)
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5caa129 and e4fc85f.

📒 Files selected for processing (9)
  • charts/greptimedb-cluster/Chart.yaml (1 hunks)
  • charts/greptimedb-cluster/README.md (2 hunks)
  • charts/greptimedb-cluster/templates/cluster.yaml (1 hunks)
  • charts/greptimedb-cluster/values.yaml (1 hunks)
  • charts/greptimedb-operator/Chart.yaml (1 hunks)
  • charts/greptimedb-operator/README.md (2 hunks)
  • charts/greptimedb-operator/values.yaml (1 hunks)
  • charts/greptimedb-standalone/Chart.yaml (1 hunks)
  • charts/greptimedb-standalone/README.md (2 hunks)
✅ Files skipped from review due to trivial changes (3)
  • charts/greptimedb-operator/Chart.yaml
  • charts/greptimedb-standalone/Chart.yaml
  • charts/greptimedb-cluster/Chart.yaml
🚧 Files skipped from review as they are similar to previous changes (2)
  • charts/greptimedb-operator/values.yaml
  • charts/greptimedb-cluster/values.yaml
🧰 Additional context used
🪛 yamllint (1.35.1)
charts/greptimedb-cluster/templates/cluster.yaml

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

(syntax)

🔇 Additional comments (6)
charts/greptimedb-standalone/README.md (1)

5-5: LGTM! Version bump aligns with PR comments.

The version update to 0.1.40 matches the version bump requested in the PR comments while maintaining the same AppVersion.

charts/greptimedb-operator/README.md (1)

103-103: LGTM! New configuration for additional labels

The addition of additionalLabels configuration aligns with Kubernetes labeling best practices and the PR objectives.

charts/greptimedb-cluster/README.md (2)

5-5: Version update looks good

The version bump to 0.2.45 aligns with the PR comments.


83-83: LGTM! Consistent labeling configuration

The addition of additionalLabels configuration is consistent with the operator chart and follows Kubernetes best practices.

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

6-7: LGTM! Follows Kubernetes labeling best practices.

The addition of labels using a centralized template helper ensures consistent labeling across resources, which aligns with Kubernetes best practices for resource management and organization.

🧰 Tools
🪛 yamllint (1.35.1)

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

(syntax)


6-7: Verify the template helper implementation.

Let's verify that the greptimedb-cluster.labels template helper is properly implemented and includes all recommended Kubernetes labels.

✅ Verification successful

Template helper implementation is correct and follows best practices

The greptimedb-cluster.labels helper includes all recommended Kubernetes labels and is properly implemented with:

  • Complete set of app.kubernetes.io/* labels
  • Support for version and name overrides
  • Extensibility via additionalLabels
  • Consistent usage across all resources
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of the labels template helper
# Expected: Find the template helper definition and verify its contents

# Search for the template helper definition
rg -A 10 "greptimedb-cluster.labels" "charts/greptimedb-cluster/templates/_helpers.tpl"

# Search for any other usage of the template helper to ensure consistency
rg "greptimedb-cluster.labels" "charts/greptimedb-cluster/templates/"

Length of output: 1772


Script:

#!/bin/bash
# Verify the selector labels helper implementation
rg -A 5 "greptimedb-cluster.selectorLabels" "charts/greptimedb-cluster/templates/_helpers.tpl"

# Also check if there's a name helper that might be used in selectors
rg -A 5 "greptimedb-cluster.name" "charts/greptimedb-cluster/templates/_helpers.tpl"

Length of output: 899

🧰 Tools
🪛 yamllint (1.35.1)

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

(syntax)

charts/greptimedb-operator/README.md Show resolved Hide resolved
@daviderli614
Copy link
Member

daviderli614 commented Jan 14, 2025

@nlamirault
https://github.com/GreptimeTeam/helm-charts/actions/runs/12748878647/job/35565583946

Please run make docs again. The operator chart appVersion is 0.1.4-alpha.3 not match the document version 0.1.4-alpha.2.

@daviderli614 daviderli614 changed the title feat: Refactoring labels feat: Add additional labels to the kubernetes resources Jan 14, 2025
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