Skip to content

Conversation

@nlamirault
Copy link
Contributor

@nlamirault nlamirault commented Feb 11, 2025

Fix #427

  • Consolidated ClickHouse settings under an instance-specific grouping for improved clarity and manageability.
  • Choice to enable or not the Clickhouse Operator and a clickhouse Instance.

Summary by CodeRabbit

  • New Features

    • Optional ClickHouse Operator deployment with RBAC, service account, and secret.
    • Instance-scoped ConfigMaps for scripts and custom functions (e.g., histogramQuantile).
    • Logs exporter and related config moved under instance settings.
    • Conditional creation of custom storage class when instance is enabled.
  • Refactor

    • Major values restructure: ClickHouse settings grouped under clickhouseInstance; operator under clickhouseOperator.
    • All ClickHouse references (images, init containers, service accounts, probes, persistence, volumes, cold storage, imagePullSecrets, annotations) moved to instance-scoped paths.
    • Rendering gated by clickhouseInstance.enabled.

@nlamirault nlamirault requested a review from a team as a code owner February 11, 2025 07:54
@coderabbitai
Copy link

coderabbitai bot commented Feb 11, 2025

Walkthrough

Refactors ClickHouse Helm charts to nest instance settings under .Values.clickhouseInstance and gate ClickHouse resources behind clickhouseInstance.enabled; introduces a separate clickhouseOperator section with conditional operator templates; adds a ConfigMap for custom functions and updates helpers to use instance-scoped value paths.

Changes

Cohort / File(s) Summary
Helpers refactor
charts/clickhouse/templates/_helper.tpl
Replaced root-scoped references with .Values.clickhouseInstance.* for service account creation/annotations, image registries/names, initContainers, imagePullSecrets, and coldStorage checks.
ClickHouse instance templates
charts/clickhouse/templates/clickhouse-instance/clickhouse-instance.yaml, .../configmap.yaml, .../exporter-configmap.yaml, .../scripts-configmap.yaml, .../serviceaccount.yaml, .../storage-class.yaml
Wrapped rendering with if .Values.clickhouseInstance.enabled; migrated most template value references to .Values.clickhouseInstance.*; added ConfigMap for custom functions; updated exporter/script configmaps and storage-class gating.
Operator templates (conditional)
charts/clickhouse/templates/clickhouse-operator/*.yaml
Added conditional rendering when .Values.clickhouseOperator.enabled for deployment, namespace, RBAC (Role/RoleBinding), secret, and serviceaccount resources including operator deployment and metrics exporter.
Values restructuring
charts/clickhouse/values.yaml
Consolidated ClickHouse configuration under clickhouseInstance and introduced clickhouseOperator; added nested sections for probes, persistence, logs, coldStorage, initContainers, templates, resources, and operator settings.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User values.yaml
  participant H as Helm Template Engine
  participant CI as clickhouse-instance templates
  participant CO as clickhouse-operator templates

  U->>H: Provide values
  alt clickhouseInstance.enabled == true
    H->>CI: Render ClickHouseInstallation + related resources
  else
    H--xCI: Skip ClickHouse instance resources
  end

  alt clickhouseOperator.enabled == true
    H->>CO: Render Operator (NS/RBAC/SA/Secret/Deploy)
  else
    H--xCO: Skip Operator resources
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Assessment against linked issues

Objective Addressed Explanation
Provide option to disable clickhouse-instance.yaml (#427)

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
Added full clickhouseOperator resources (deployment, RBAC, namespace, secret, SA) (charts/clickhouse/templates/clickhouse-operator/*.yaml) Operator deployment and RBAC are beyond the single-objective request to disable clickhouse-instance.yaml.
Large values schema refactor moving many root keys into clickhouseInstance and adding clickhouseOperator (charts/clickhouse/values.yaml, entire file) Extensive schema changes exceed the narrow goal of adding a single toggle and affect many public paths.
New custom functions ConfigMap for UDFs (charts/clickhouse/templates/clickhouse-instance/configmap.yaml) Introducing UDF ConfigMap adds functionality unrelated to disabling the instance manifest.
Helpers update to instance-scoped image/pullSecret/coldStorage references (charts/clickhouse/templates/_helper.tpl) Broad helper refactors change value lookup locations across templates rather than solely gating the instance file.

Suggested reviewers

  • grandwizard28

Poem

I twitch my whiskers at a flag so bright,
One flip and instances sleep at night.
Operators wait in their own green glen,
Configs nested snug like a little den.
Hop—deploys now heed the toggled light. 🐰✨

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit 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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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: 3

🔭 Outside diff range comments (1)
charts/clickhouse/templates/clickhouse-instance/scripts-configmap.yaml (1)

21-32: 🛠️ Refactor suggestion

Add timeout to prevent infinite loop.

The script runs in an infinite loop without a timeout, which could lead to resource exhaustion if ClickHouse never becomes ready.

Apply this diff to add a timeout:

+    # Maximum number of attempts (10 minutes with 10s delay)
+    MAX_ATTEMPTS=60
+    attempt=0
+
     while true; do
+        if [ $attempt -ge $MAX_ATTEMPTS ]; then
+            echo "Timeout waiting for Clickhouse to become ready"
+            exit 1
+        fi
+
         response=$(wget --spider -S "http://${HOST}:${PORT}/ping" 2>&1)
         exit_code=$?

         if [ $exit_code -eq 0 ]; then
             echo "Clickhouse is ready!"
             exit 0
         else
             echo "Clickhouse is not ready yet. Retrying in ${DELAY} seconds..."
+            attempt=$((attempt + 1))
             sleep $DELAY
         fi
     done
🧹 Nitpick comments (2)
charts/clickhouse/templates/clickhouse-instance/storage-class.yaml (1)

10-10: Consider making storage class names configurable.

The storage class names gce-resizable and gp2-resizable are hardcoded. Consider making them configurable through values to support different naming conventions across environments.

 metadata:
-  name: gce-resizable
+  name: {{ .Values.clickhouseInstance.storageClass.gcp.name | default "gce-resizable" }}
 metadata:
-  name: gp2-resizable
+  name: {{ .Values.clickhouseInstance.storageClass.aws.name | default "gp2-resizable" }}

Also applies to: 26-26

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

16-17: Make host and port configurable.

The script uses hardcoded values for host and port. Consider making these configurable through environment variables or template values for better flexibility.

Apply this diff to make the values configurable:

-    HOST="localhost"
-    PORT="8123"
+    HOST="${HOST:-localhost}"
+    PORT="${PORT:-8123}"
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7ba0f35 and 79342ca.

📒 Files selected for processing (8)
  • charts/clickhouse/templates/_helper.tpl (7 hunks)
  • charts/clickhouse/templates/clickhouse-instance/clickhouse-instance.yaml (13 hunks)
  • charts/clickhouse/templates/clickhouse-instance/configmap.yaml (2 hunks)
  • charts/clickhouse/templates/clickhouse-instance/exporter-configmap.yaml (2 hunks)
  • charts/clickhouse/templates/clickhouse-instance/scripts-configmap.yaml (3 hunks)
  • charts/clickhouse/templates/clickhouse-instance/serviceaccount.yaml (2 hunks)
  • charts/clickhouse/templates/clickhouse-instance/storage-class.yaml (2 hunks)
  • charts/clickhouse/values.yaml (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
charts/clickhouse/templates/clickhouse-instance/clickhouse-instance.yaml (1)
Learnt from: prashant-shahi
PR: SigNoz/charts#565
File: charts/clickhouse/values.yaml:261-264
Timestamp: 2024-12-16T16:15:01.460Z
Learning: In `charts/clickhouse/values.yaml`, the `customStartupProbe`, `customLivenessProbe`, and `customReadinessProbe` configurations are provided for advanced users to specify custom probe types such as HTTP, Exec, TCP, and gRPC.
🪛 YAMLlint (1.35.1)
charts/clickhouse/templates/clickhouse-instance/scripts-configmap.yaml

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

(syntax)

charts/clickhouse/templates/clickhouse-instance/exporter-configmap.yaml

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

(syntax)

charts/clickhouse/templates/clickhouse-instance/configmap.yaml

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

(syntax)

charts/clickhouse/templates/clickhouse-instance/serviceaccount.yaml

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

(syntax)

charts/clickhouse/templates/clickhouse-instance/clickhouse-instance.yaml

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

(syntax)


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

(indentation)


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

(indentation)

charts/clickhouse/templates/clickhouse-instance/storage-class.yaml

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

(syntax)

🪛 Gitleaks (8.21.2)
charts/clickhouse/values.yaml

158-158: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

🔇 Additional comments (8)
charts/clickhouse/templates/_helper.tpl (2)

60-64: LGTM! Improved configuration organization.

The refactoring to move service account and cold storage configurations under .Values.clickhouseInstance enhances clarity and maintainability by grouping related settings together.

Also applies to: 186-191


105-107: LGTM! Consistent image configuration structure.

The image configuration for init containers, UDF, ClickHouse, and logs has been consistently moved under .Values.clickhouseInstance, making the configuration more organized and explicit.

Also applies to: 119-121, 133-135, 147-149

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

1-2: LGTM! Enhanced conditional logic and configuration structure.

The changes improve the template by:

  1. Only creating the ConfigMap when the ClickHouse instance is enabled
  2. Maintaining consistent configuration structure under .Values.clickhouseInstance

Also applies to: 12-14

🧰 Tools
🪛 YAMLlint (1.35.1)

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

(syntax)

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

1-2: LGTM! Improved resource creation control.

The changes enhance the template by:

  1. Only creating the ServiceAccount when the ClickHouse instance is enabled
  2. Maintaining consistent configuration structure for cold storage and service account settings

Also applies to: 13-13

🧰 Tools
🪛 YAMLlint (1.35.1)

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

(syntax)

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

1-2: LGTM! Enhanced resource creation control.

The changes improve the template by only creating the StorageClass when the ClickHouse instance is enabled.

Also applies to: 34-34

🧰 Tools
🪛 YAMLlint (1.35.1)

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

(syntax)

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

29-29: Verify the executable path.

The command uses a relative path ./histogramQuantile which assumes the executable is in the current directory. Consider using an absolute path to ensure reliability.

Run this script to verify the executable path:

❌ Verification inconclusive

🏁 Script executed:

#!/bin/bash
# Description: Check if the histogramQuantile executable exists at the expected location

# Find all histogramQuantile files
fd histogramQuantile

# Check if the file is executable
find . -name histogramQuantile -type f -executable

Length of output: 75


Executable Not Found – Manual Verification Required

The search commands did not return any executable for “histogramQuantile” in the repository. This could indicate that the binary is either built during the container image build, generated at runtime, or placed in a non-standard location. Please verify manually (or via an alternate verification method) that the executable is located where expected during container runtime.

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

165-167: LGTM! Good security practices.

The security context is properly configured with non-root user and group IDs, along with appropriate file system permissions.

charts/clickhouse/values.yaml (1)

273-278: LGTM! Well-defined resource requests.

The resource requests are properly defined with reasonable defaults, and the limits are commented out to allow users to set them based on their needs.

- name: {{ . }}
{{- end }}
{{- range .Values.imagePullSecrets }}
{{- range .Values.clickhouseInstance.imagePullSecrets }}
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify image pull secrets configuration.

Ensure that existing deployments using global image pull secrets continue to work after moving instance-specific secrets under .Values.clickhouseInstance.


🏁 Script executed:

#!/bin/bash
# Search for any references to the old imagePullSecrets configuration
rg -l "imagePullSecrets" | grep -v "_helper.tpl"

Length of output: 1460


Global imagePullSecrets fallback missing might break legacy deployments

The current change in the _helper.tpl file directly loops over .Values.clickhouseInstance.imagePullSecrets without checking or falling back to any global configuration that might be defined (for example, in .Values.imagePullSecrets). This could cause deployments that have not migrated to the instance‐specific configuration to lose their image pull secrets settings. Please check whether you want to either move all global settings to the instance-specific field or add fallback logic in the template so that deployments using global settings continue working.

  • File to inspect: charts/clickhouse/templates/_helper.tpl (line 175)
  • Action needed: Either migrate global image pull secrets to .Values.clickhouseInstance.imagePullSecrets or modify the template (e.g., using a default function) to fall back to the global configuration if instance-specific values are not provided.

Comment on lines +84 to +85
<access_key_id>{{ .Values.clickhouseInstance.coldStorage.accessKey }}</access_key_id>
<secret_access_key>{{ .Values.clickhouseInstance.coldStorage.secretAccess }}</secret_access_key>
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Use Kubernetes secrets for sensitive credentials.

Storing access keys and secrets in plain text within the configuration is a security risk. Consider using Kubernetes secrets to manage these credentials.

  1. Create a secret for the cold storage credentials:
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "clickhouse.fullname" . }}-cold-storage
type: Opaque
data:
  access_key: {{ .Values.clickhouseInstance.coldStorage.accessKey | b64enc }}
  secret_key: {{ .Values.clickhouseInstance.coldStorage.secretAccess | b64enc }}
  1. Update the cold storage configuration to use the secret:
-                <access_key_id>{{ .Values.clickhouseInstance.coldStorage.accessKey }}</access_key_id>
-                <secret_access_key>{{ .Values.clickhouseInstance.coldStorage.secretAccess }}</secret_access_key>
+                <access_key_id>{{ .Values.clickhouseInstance.coldStorage.existingSecret.accessKey }}</access_key_id>
+                <secret_access_key>{{ .Values.clickhouseInstance.coldStorage.existingSecret.secretKey }}</secret_access_key>

# -- Clickhouse user
user: admin
# -- Clickhouse password
password: 27ff0399-0d3a-4bd8-919d-17c2181e6fb9
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Replace hardcoded password with a generated value.

Using a hardcoded password in the values file is a security risk. Consider generating a random password during installation or requiring the user to provide one.

Update the password field to use a generated value:

password: {{ randAlphaNum 32 | quote }}

Or add a validation to ensure the user provides a password:

password: # -- Required: Provide a secure password for the ClickHouse user
🧰 Tools
🪛 Gitleaks (8.21.2)

158-158: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

@therealpandey
Copy link
Collaborator

I understand that we are trying to disable Clickhouse itself from being deployed. Then what would be the use of this chart? Wouldn't it be simpler to have clickhouse.enabled = false in the SigNoz helm chart?

@nlamirault
Copy link
Contributor Author

It's to use this chars in 2 separate Argo-CD applications: One which deploy only the Clickhouse operator, and one which manage Clickhouse instance

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

♻️ Duplicate comments (1)
charts/clickhouse/values.yaml (1)

157-158: ⚠️ Potential issue

Replace hardcoded password with a generated value.

Using a hardcoded password in the values file is a security risk. Consider generating a random password during installation or requiring the user to provide one.

Update the password field to use a generated value:

-  password: 27ff0399-0d3a-4bd8-919d-17c2181e6fb9
+  password: # -- Required: Provide a secure password for the ClickHouse user
🧹 Nitpick comments (3)
charts/clickhouse/templates/clickhouse-operator/secret.yaml (1)

3-12: Consider adding annotations for secret rotation.

While the secret implementation is correct, consider enhancing it with annotations to support secret rotation strategies.

Add annotations to enable secret rotation:

metadata:
  name: {{ include "clickhouseOperator.fullname" . }}
  namespace: {{ .Release.Namespace }}
  labels: {{ include "clickhouseOperator.labels" . | nindent 4 }}
+ {{- if .Values.clickhouseOperator.secret.annotations }}
+  annotations:
+    {{- toYaml .Values.clickhouseOperator.secret.annotations | nindent 4 }}
+ {{- end }}

Let's verify if similar patterns are used in other secrets within the chart:

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Search for secret annotations in other templates
rg -l 'kind:\s*Secret' charts/clickhouse/templates/ | xargs rg 'annotations:'

Length of output: 77


Secret rotation annotations not currently implemented – consider adding them.

After re-running the search for "annotations:" in all Secret templates under the charts/clickhouse/templates/ directory (the initial search returned no output), it appears that none of the other secret definitions currently include annotations for secret rotation. Thus, the proposed addition of a conditional annotations block is a valid enhancement to support secret rotation strategies.

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

16-18: Add targetPort specification for metrics port.

The port configuration should include a targetPort to explicitly specify which port the service should forward to on the pods.

  ports:
    - port: {{ .port }}
      name: {{ include "clickhouseOperator.fullname" $ }}-metrics
+     targetPort: metrics
charts/clickhouse/templates/clickhouse-operator/role.yaml (1)

72-81: Enhance deployment permissions for operator self-management.

The deployment permissions are currently limited to get, patch, update, and delete. Consider adding 'create' permission to allow the operator to manage its own deployment completely.

    verbs:
      - get
      - patch
      - update
      - delete
+     - create
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 79342ca and 3e52197.

📒 Files selected for processing (8)
  • charts/clickhouse/templates/clickhouse-operator/deployment.yaml (2 hunks)
  • charts/clickhouse/templates/clickhouse-operator/namespace.yaml (1 hunks)
  • charts/clickhouse/templates/clickhouse-operator/role.yaml (2 hunks)
  • charts/clickhouse/templates/clickhouse-operator/rolebinding.yaml (2 hunks)
  • charts/clickhouse/templates/clickhouse-operator/secret.yaml (2 hunks)
  • charts/clickhouse/templates/clickhouse-operator/service.yaml (2 hunks)
  • charts/clickhouse/templates/clickhouse-operator/serviceaccount.yaml (2 hunks)
  • charts/clickhouse/values.yaml (2 hunks)
🧰 Additional context used
🪛 YAMLlint (1.35.1)
charts/clickhouse/templates/clickhouse-operator/namespace.yaml

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

(syntax)

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

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

(syntax)

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

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

(syntax)

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

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

(syntax)

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

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

(syntax)

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

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

(syntax)

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

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

(syntax)

🔇 Additional comments (6)
charts/clickhouse/templates/clickhouse-operator/secret.yaml (1)

1-2: LGTM! Conditional blocks enhance deployment flexibility.

The nested conditional blocks align well with the PR objectives by allowing separate deployment of the ClickHouse operator and its components through Argo-CD applications.

Also applies to: 13-14

🧰 Tools
🪛 YAMLlint (1.35.1)

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

(syntax)

charts/clickhouse/templates/clickhouse-operator/namespace.yaml (1)

1-8: LGTM! Well-structured conditional namespace creation.

The conditional logic ensures the namespace is only created when:

  1. The ClickHouse operator is enabled
  2. A custom namespace is specified that differs from the release namespace

This aligns well with the separation of operator and instance deployments.

🧰 Tools
🪛 YAMLlint (1.35.1)

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

(syntax)

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

1-16: LGTM! Well-structured ServiceAccount configuration.

The ServiceAccount is properly scoped to the operator with appropriate conditional creation logic, labels, annotations, and image pull secrets support.

🧰 Tools
🪛 YAMLlint (1.35.1)

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

(syntax)

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

1-22: LGTM! Well-structured RoleBinding configuration.

The RoleBinding correctly associates the Role with the ServiceAccount, maintaining proper namespace scoping and conditional creation logic.

🧰 Tools
🪛 YAMLlint (1.35.1)

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

(syntax)

charts/clickhouse/templates/clickhouse-operator/deployment.yaml (1)

1-121: LGTM! The deployment configuration is well-structured and aligns with the PR objectives.

The deployment template correctly implements the separation of concerns by:

  1. Using conditional deployment based on .Values.clickhouseOperator.enabled
  2. Properly configuring volumes and mounts for operator configuration
  3. Including both operator and metrics-exporter containers with appropriate settings

This implementation supports the PR's goal of managing the ClickHouse operator independently through Argo-CD.

🧰 Tools
🪛 YAMLlint (1.35.1)

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

(syntax)


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

(indentation)


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

(indentation)

charts/clickhouse/values.yaml (1)

133-493: LGTM! The consolidation of ClickHouse settings is well-structured.

The reorganization of settings under clickhouseInstance improves clarity and supports the PR's goal of managing the ClickHouse instance independently through Argo-CD. The configuration includes comprehensive settings for:

  1. Basic instance configuration (name, namespace, etc.)
  2. Service and networking
  3. Storage and persistence
  4. Security and resource limits
  5. Monitoring and logging

Comment on lines +453 to +455
accessKey: <access_key_id>
# -- Secret Access Key for S3 or GCS
secretAccess: <secret_access_key>
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Secure cold storage credentials.

Storing AWS/GCS access keys in plain text within the values file is a security risk. Consider using Kubernetes secrets or cloud provider's native IAM roles.

For AWS, you can use IAM roles (already supported as shown in the role section below). For GCS, consider using Workload Identity.

Update the fields to use references to Kubernetes secrets:

-    accessKey: <access_key_id>
-    secretAccess: <secret_access_key>
+    existingSecret: "" # -- Name of existing secret containing cold storage credentials
+    accessKeyKey: "access-key" # -- Key in the secret containing the access key
+    secretAccessKey: "secret-access" # -- Key in the secret containing the secret access key

Committable suggestion skipped: line range outside the PR's diff.

@therealpandey
Copy link
Collaborator

We're having a discussion on this internally. It'll take some time for the discussion to wrap up. Let me get back to you! Appreciate the effort here :)

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

♻️ Duplicate comments (2)
charts/clickhouse/values.yaml (2)

147-158: ⚠️ Potential issue

Database and Credential Configuration.

The cluster settings and database names (for metrics, traces, and logs) are explicitly set. However, the hardcoded ClickHouse password at line 158 poses a security risk. Recommendation: Replace this with a generated secret or require the user to provide one, as highlighted in previous reviews.

🧰 Tools
🪛 Gitleaks (8.21.2)

158-158: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


453-456: ⚠️ Potential issue

Cold Storage Credentials.

The access and secret keys for cold storage are hardcoded, which can expose sensitive information. Recommendation: Use Kubernetes secrets or another secure mechanism to manage these credentials.

🧹 Nitpick comments (2)
charts/clickhouse/values.yaml (2)

266-279: Resource Request Configuration.

CPU and memory requests are defined, though resource limits remain commented out. For production workloads, consider uncommenting and fine‑tuning the limits to prevent resource contention.


344-370: Init Containers Configuration.

The init container for installing the histogramQuantile UDF and the secondary init container waiting for ClickHouse readiness are well scripted. Consider adding more robust error handling (e.g., failure detection for the wget command) to prevent the container from stalling on failure.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3e52197 and 078b12c.

📒 Files selected for processing (1)
  • charts/clickhouse/values.yaml (2 hunks)
🧰 Additional context used
🪛 Gitleaks (8.21.2)
charts/clickhouse/values.yaml

158-158: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test-chart
🔇 Additional comments (29)
charts/clickhouse/values.yaml (29)

133-136: Encapsulate ClickHouse Instance Configurations.

The new clickhouseInstance block provides a clearer, instance-specific grouping of settings, improving clarity and maintainability. Ensure that all templates and scripts referencing the old global settings are updated accordingly.


137-145: Instance Identification Settings.

The configuration for the instance name, namespace, and override values is clearly defined. Double-check that these values align with your naming conventions and deployment practices.


160-163: Cluster Scaling Parameters.

The replicasCount and shardsCount parameters are set to 1. Verify these defaults meet your anticipated workload and scalability requirements.


165-177: ClickHouse Image Configuration.

Image settings—including registry, repository, tag, and pull policy—are clearly provided. Confirm that the selected version (24.1.2-alpine) is compatible with your environment.


178-198: Resource Meta and Service Account Configuration.

Settings for image pull secrets, labels, and the service account are established under the instance. Leaving the service account name empty allows for auto-generation, which is acceptable.


199-209: ClickHouse Service Setup.

The service configuration (annotations, type, and ports) is straightforward. Ensure that using a ClusterIP service meets your external access and networking requirements.


210-218: TLS and External Zookeeper Configuration.

Disabling TLS (secure: false) and certificate verification (verify: false) may be acceptable for internal deployments, but review these settings against your security policies. Also, since externalZookeeper is left empty, confirm that the necessary configuration will be applied when integrating with an external Zookeeper.


220-230: Pod Scheduling and Priority Settings.

Pod-specific settings such as priorityClassName, nodeSelector, tolerations, affinity, and topologySpreadConstraints are defined with default/empty values. Tailor these as needed for your cluster’s scheduling constraints.


231-243: Probe Configuration.

The startup, liveness, and readiness probes are configured with standard intervals and thresholds. Verify that these timeouts and delays suit your application's actual startup and health response characteristics.


262-265: Custom Probes.

The custom probe configurations are provided as empty objects. This setup offers flexibility for future customization; ensure you populate these if custom health checks become necessary.


280-287: Security Context Settings.

The security context establishes the user, group, and file system group IDs, which is a good practice to maintain container security. No changes needed here.


288-303: Allowed Network IPs.

The list of allowed network IPs is comprehensive for common private ranges. Adjust this list if additional access boundaries are required.


304-327: Persistence Configuration.

Persistence settings—including the enable flag, existing claim, storage class, access modes, and volume size—are clearly outlined. Confirm that setting storageClass to null correctly triggers the default provisioner in your cluster.


328-337: User Profiles Configuration.

The profiles section is ready for any overrides you might need, while default user profiles remain unmodified. This approach offers flexibility without impacting default behavior.


338-343: Default Profiles.

The default profiles for experimental window functions and nondeterministic mutations are enabled. Maintain these settings unless you have a specific reason to override these defaults, as noted in the documentation.


386-393: Cluster Layout Settings.

The layout configuration sets both shardsCount and replicasCount to 1. Validate these settings against your scalability and high-availability requirements.


394-405: Custom ClickHouse Settings.

The settings block is available for overriding particular ClickHouse options, such as enabling the built-in Prometheus HTTP endpoint by uncommenting the provided lines. This flexibility is useful for fine-tuning.


406-412: Default Settings.

Default paths for schema, user scripts, and custom functions are set and should typically not be overridden to ensure operational consistency.


413-420: Pod Annotations.

Pod-level annotations are kept empty by default, allowing for later customization (e.g., enabling scraping for Prometheus). Uncomment and adjust these when needed.


421-432: Pod Distribution.

The pod distribution settings are left as an empty array, giving you the option to explicitly define topology spread constraints if necessary.


433-437: Additional Volumes Configuration.

Both additionalVolumes and additionalVolumeMounts are empty, which is acceptable if no extra storage is needed. Update these if additional volumes become part of your deployment.


438-451: Cold Storage Endpoint Configuration.

Cold storage is configured for S3 with a placeholder endpoint. Make sure to update the endpoint with your actual bucket details and region.


457-464: AWS Role Configuration.

The AWS IAM role settings are provided, with annotations indicating the role ARN (masked here). Confirm that the final values are securely managed and not exposed in plaintext.


465-482: ClickHouse Configuration Files.

The files section is a placeholder for any custom configuration files you may want to supply to ClickHouse. Populate this mapping when custom configurations are needed.


487-491: Volume Claim Templates.

The custom volume claim templates are defined but left empty, which is acceptable if additional PVC customization is not required.


492-494: Extra Containers.

No extra containers have been specified. Extend this section if additional sidecar containers are necessary for your deployment.


495-554: Logs and Telemetry Configuration.

The logs configuration is detailed, covering system logs, opentelemetry collector settings, and exporter configurations. Ensure that the use of environment variables (e.g., ${env:K8S_HOST_IP}) is supported in your environment.


560-564: Custom Storage Class Installation.

The installCustomStorageClass flag is set to false by default. Enable this flag if you require dynamic provisioning with volume expansion capabilities on supported clouds such as AWS or GCP.


572-574: ClickHouse Operator Enablement.

The clickhouseOperator section now clearly separates operator settings from the instance settings. With enabled: true, it supports deployment as a separate Argo‑CD application, aligning with the PR objectives. Verify that all dependencies and templates are adjusted accordingly.

@nlamirault
Copy link
Contributor Author

any news @grandwizard28 ?

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

♻️ Duplicate comments (1)
charts/clickhouse/templates/clickhouse-instance/clickhouse-instance.yaml (1)

84-85: Use Kubernetes Secrets for cold storage credentials
Embedding accessKey and secretAccess in plain values is insecure. Please switch to mounting these from a Kubernetes Secret.

Also applies to: 93-94

🧹 Nitpick comments (1)
charts/clickhouse/templates/clickhouse-instance/clickhouse-instance.yaml (1)

349-349: Remove trailing whitespace
Line 349 contains trailing spaces. Cleaning this up will satisfy the linter and avoid noisy diffs.

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 349-349: trailing spaces

(trailing-spaces)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 078b12c and aac5fbb.

📒 Files selected for processing (1)
  • charts/clickhouse/templates/clickhouse-instance/clickhouse-instance.yaml (13 hunks)
🧰 Additional context used
🧠 Learnings (1)
charts/clickhouse/templates/clickhouse-instance/clickhouse-instance.yaml (1)
Learnt from: prashant-shahi
PR: SigNoz/charts#565
File: charts/clickhouse/values.yaml:261-264
Timestamp: 2024-12-16T16:15:01.460Z
Learning: In `charts/clickhouse/values.yaml`, the `customStartupProbe`, `customLivenessProbe`, and `customReadinessProbe` configurations are provided for advanced users to specify custom probe types such as HTTP, Exec, TCP, and gRPC.
🪛 YAMLlint (1.37.1)
charts/clickhouse/templates/clickhouse-instance/clickhouse-instance.yaml

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

(syntax)


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

(indentation)


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

(indentation)


[error] 349-349: trailing spaces

(trailing-spaces)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test-chart
🔇 Additional comments (9)
charts/clickhouse/templates/clickhouse-instance/clickhouse-instance.yaml (9)

1-1: Conditional rendering scope added
Wrapping the ClickHouseInstallation manifest under if .Values.clickhouseInstance.enabled ensures instance resources are only created when explicitly enabled, supporting the operator/instance separation use case.

🧰 Tools
🪛 YAMLlint (1.37.1)

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

(syntax)


9-11: The YAMLlint indentation warnings here are false positives in the Helm context; the nested labels block correctly uses 4 spaces under metadata.

🧰 Tools
🪛 YAMLlint (1.37.1)

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

(indentation)


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

(indentation)


12-15: Approve annotations block
Conditionally rendering .Values.clickhouseInstance.annotations lets users add arbitrary annotations per instance cleanly.


19-22: Approve default volume claim template logic
The guard on persistence.enabled and !persistence.existingClaim to render dataVolumeClaimTemplate only when needed is correct.


27-34: Approve user configuration mapping
Scoping user credentials and network settings under .Values.clickhouseInstance.user isolates per-instance configs as intended.


36-36: Approve profiles merge
Merging profiles with defaultProfiles maintains sensible defaults while allowing overrides.


39-43: Approve cluster layout configuration
Parameterizing cluster name and layout under the new clickhouseInstance key preserves grouping consistency.


46-46: Approve settings merge
The pattern of merging settings with defaultSettings mirrors the profiles approach and keeps defaults intact.


61-61: Approve cold storage enable guard
The if .Values.clickhouseInstance.coldStorage.enabled check correctly skips the entire cold storage sub-block when disabled.

Comment on lines +88 to +92
{{- else if eq .Values.clickhouseInstance.coldStorage.type "gcs" }}
<gcs>
<support_batch_delete>false</support_batch_delete>
<type>s3</type>
<endpoint>{{ .Values.coldStorage.endpoint }}</endpoint>
<access_key_id>{{ .Values.coldStorage.accessKey }}</access_key_id>
<secret_access_key>{{ .Values.coldStorage.secretAccess }}</secret_access_key>
<endpoint>{{ .Values.clickhouseInstance.coldStorage.endpoint }}</endpoint>
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 GCS storage <type> tag
The GCS branch erroneously emits <type>s3</type>. It must be <type>gcs</type> to match the storage type.

-              <gcs>
-                <support_batch_delete>false</support_batch_delete>
-                <type>s3</type>
+              <gcs>
+                <support_batch_delete>false</support_batch_delete>
+                <type>gcs</type>
📝 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
{{- else if eq .Values.clickhouseInstance.coldStorage.type "gcs" }}
<gcs>
<support_batch_delete>false</support_batch_delete>
<type>s3</type>
<endpoint>{{ .Values.coldStorage.endpoint }}</endpoint>
<access_key_id>{{ .Values.coldStorage.accessKey }}</access_key_id>
<secret_access_key>{{ .Values.coldStorage.secretAccess }}</secret_access_key>
<endpoint>{{ .Values.clickhouseInstance.coldStorage.endpoint }}</endpoint>
{{- else if eq .Values.clickhouseInstance.coldStorage.type "gcs" }}
<gcs>
<support_batch_delete>false</support_batch_delete>
<type>gcs</type>
<endpoint>{{ .Values.clickhouseInstance.coldStorage.endpoint }}</endpoint>
🤖 Prompt for AI Agents
In charts/clickhouse/templates/clickhouse-instance/clickhouse-instance.yaml
around lines 88 to 92, the GCS storage configuration incorrectly sets the <type>
tag to "s3". Change the <type> tag value from "s3" to "gcs" to correctly reflect
the Google Cloud Storage type.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
charts/clickhouse/values.yaml (1)

627-633: Don’t ship a default operator DB user password.

Require a Secret or generate one at install; empty by default to force override.

   secret:
     # -- Specifies whether a secret should be created
     create: true
     # -- User name for Clickhouse Operator
     username: clickhouse_operator
     # -- User password for Clickhouse Operator
-    password: clickhouse_operator_password
+    password: "" # REQUIRED: set via values or provide `existingSecret`
+    # existingSecret: "" # Optional: Secret name with keys: username, password
♻️ Duplicate comments (2)
charts/clickhouse/values.yaml (2)

157-160: Remove hardcoded ClickHouse password.

Do not ship a default static password. Require user input or an existing Secret.

Apply:

-  user: admin
-  password: 27ff0399-0d3a-4bd8-919d-17c2181e6fb9
+  user: admin
+  password: "" # REQUIRED: provide via values or Secret
+  # existingSecret: "" # Optional: name of a Secret with keys: username, password

439-466: Move cold storage credentials to a Secret.

Avoid plaintext creds in values; support existing Secret and key names.

-    accessKey: <access_key_id>
-    secretAccess: <secret_access_key>
+    existingSecret: ""        # Name of Secret with object store creds
+    accessKeyKey: access-key  # Key holding access key
+    secretAccessKey: secret-access # Key holding secret key

Also ensure templates keep backward compat (deprecate old fields with warnings).

🧹 Nitpick comments (5)
charts/clickhouse/values.yaml (5)

201-206: Fix service type comment for accuracy.

ClusterIP is the default here; include all valid types in the comment.

-    # -- Service Type: LoadBalancer (allows external access) or NodePort (more secure, no extra cost)
+    # -- Service type: ClusterIP (default), LoadBalancer, or NodePort

268-277: Resource defaults are very light; confirm they’re realistic.

100m CPU/200Mi RAM may be too low for CH even in dev. Consider higher sane defaults or document clearly.


314-321: Honor global storageClass by default.

Align with ZK and reuse the global anchor so users get consistent defaults.

-    storageClass: null
+    storageClass: *GLOBAL_SC

561-564: Document cloud/storage-class interplay.

When installCustomStorageClass is true, call out required RBAC and CSI support in README/UPGRADE notes.


573-575: Defaulting operator.enabled=true: call out upgrade impact.

Splitting operator vs instance can change what gets installed in existing clusters. Add clear release notes and example split installs (operator-only vs instance-only).

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between aac5fbb and 1f0e5b9.

📒 Files selected for processing (1)
  • charts/clickhouse/values.yaml (2 hunks)
🧰 Additional context used
🪛 Gitleaks (8.27.2)
charts/clickhouse/values.yaml

159-159: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: test-chart
🔇 Additional comments (1)
charts/clickhouse/values.yaml (1)

496-555: K8S_HOST_IP injection confirmed
Env var is already set via valueFrom.fieldRef(status.podIP) in the clickhouse-instance template; no changes required.

Comment on lines +134 to 147
clickhouseInstance:
# -- Whether to install clickhouse. If false, `clickhouse.host` must be set
enabled: true

# -- Name of the clickhouse component
name: clickhouse

# -- Which namespace to install clickhouse and `clickhouse-operator` to (defaults to namespace chart is installed to)
namespace: ""
# -- Name override for clickhouse
nameOverride: ""
# -- Fullname override for clickhouse
fullnameOverride: ""

Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

❓ Verification inconclusive

Clarify enable/disable semantics and verify templating guards.

Ensure all ClickHouse instance resources are gated behind .Values.clickhouseInstance.enabled and operator resources behind .Values.clickhouseOperator.enabled. Also document migration from old keys to the new nested structure to avoid breaking upgrades.

Run to confirm conditional guards in templates:


🏁 Script executed:

#!/bin/bash
# Expect: all clickhouse-instance templates guarded by `if .Values.clickhouseInstance.enabled`
rg -n --glob 'charts/**/templates/**' -C2 -e '\{\{\s*if\s+\.Values\.clickhouseInstance\.enabled'
# Expect: all clickhouse-operator templates guarded by `if .Values.clickhouseOperator.enabled`
rg -n --glob 'charts/**/templates/**' -C2 -e '\{\{\s*if\s+\.Values\.clickhouseOperator\.enabled'

Length of output: 197


Add conditional guards for ClickHouse instance and operator templates, and document migration

  • No occurrences of .Values.clickhouseInstance.enabled or .Values.clickhouseOperator.enabled found in charts/clickhouse/templates; wrap all instance resources in
    {{- if .Values.clickhouseInstance.enabled }}
      …resources…
    {{- end }}
    and operator resources in
    {{- if .Values.clickhouseOperator.enabled }}
      …resources…
    {{- end }}
  • In charts/clickhouse/values.yaml, add a brief upgrade note mapping legacy top-level keys (e.g. enabled, name) to the new nested clickhouseInstance/clickhouseOperator structure to avoid breaking changes during upgrade.
🤖 Prompt for AI Agents
In charts/clickhouse/values.yaml around lines 134-147 and in all files under
charts/clickhouse/templates, add conditional guards and a migration note: wrap
every resource manifest that belongs to the ClickHouse instance with {{- if
.Values.clickhouseInstance.enabled }} ... {{- end }} and wrap operator manifests
with {{- if .Values.clickhouseOperator.enabled }} ... {{- end }} (ensure correct
Helm indentation and that any helper templates used by both are guarded or
tolerate being absent), and update charts/clickhouse/values.yaml to include a
brief upgrade note/comment mapping legacy top-level keys (e.g. enabled, name) to
the new nested clickhouseInstance/clickhouseOperator keys so upgrades don’t
break (document which old keys map to which new nested fields).

Comment on lines +297 to 304
allowedNetworkIps:
- "10.0.0.0/8"
- "100.64.0.0/10"
- "172.16.0.0/12"
- "192.0.0.0/24"
- "198.18.0.0/15"
- "192.168.0.0/16"

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Correct reserved IPv4 block (likely typo).

192.0.0.0/24 isn’t the common “TEST-NET” block; you probably intended 192.0.2.0/24.

-    - "192.0.0.0/24"
+    - "192.0.2.0/24"

Optionally also include other doc-only ranges 198.51.100.0/24 and 203.0.113.0/24.

📝 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
allowedNetworkIps:
- "10.0.0.0/8"
- "100.64.0.0/10"
- "172.16.0.0/12"
- "192.0.0.0/24"
- "198.18.0.0/15"
- "192.168.0.0/16"
allowedNetworkIps:
- "10.0.0.0/8"
- "100.64.0.0/10"
- "172.16.0.0/12"
- "192.0.2.0/24"
- "198.18.0.0/15"
- "192.168.0.0/16"
🤖 Prompt for AI Agents
In charts/clickhouse/values.yaml around lines 297 to 304, the allowedNetworkIps
list contains 192.0.0.0/24 which is likely a typo; replace 192.0.0.0/24 with the
intended documentation/test-net block 192.0.2.0/24, and optionally add the other
documentation-only ranges 198.51.100.0/24 and 203.0.113.0/24 to the list if you
want full coverage of reserved doc-only IPv4 blocks.

Comment on lines +351 to +371
image:
registry: docker.io
repository: alpine
tag: 3.18.2
pullPolicy: IfNotPresent
command:
- sh
- -c
- |
set -e
version="v0.0.1"
node_os=$(uname -s | tr '[:upper:]' '[:lower:]')
node_arch=$(uname -m | sed s/aarch64/arm64/ | sed s/x86_64/amd64/)
echo "Fetching histogram-binary for ${node_os}/${node_arch}"
cd /tmp
wget -O histogram-quantile.tar.gz "https://github.com/SigNoz/signoz/releases/download/histogram-quantile%2F${version}/histogram-quantile_${node_os}_${node_arch}.tar.gz"
tar -xzf histogram-quantile.tar.gz
chmod +x histogram-quantile
mv histogram-quantile /var/lib/clickhouse/user_scripts/histogramQuantile
echo "histogram-quantile installed successfully"
init:
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Avoid runtime curl/wget in init; pin and verify artifact.

Downloading binaries at install time is a supply-chain and airgap risk. Prefer baking the UDF into an image; minimally, verify checksum.

Example tweak (checksum verification step):

           cd /tmp
-          wget -O histogram-quantile.tar.gz "https://github.com/SigNoz/signoz/releases/download/histogram-quantile%2F${version}/histogram-quantile_${node_os}_${node_arch}.tar.gz"
+          wget -O histogram-quantile.tar.gz "https://github.com/SigNoz/signoz/releases/download/histogram-quantile%2F${version}/histogram-quantile_${node_os}_${node_arch}.tar.gz"
+          # TODO: set EXPECTED_SHA256 via values and validate
+          echo "${EXPECTED_SHA256}  histogram-quantile.tar.gz" | sha256sum -c -

If you want, I can propose an image-based approach with no network at runtime.

📝 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
image:
registry: docker.io
repository: alpine
tag: 3.18.2
pullPolicy: IfNotPresent
command:
- sh
- -c
- |
set -e
version="v0.0.1"
node_os=$(uname -s | tr '[:upper:]' '[:lower:]')
node_arch=$(uname -m | sed s/aarch64/arm64/ | sed s/x86_64/amd64/)
echo "Fetching histogram-binary for ${node_os}/${node_arch}"
cd /tmp
wget -O histogram-quantile.tar.gz "https://github.com/SigNoz/signoz/releases/download/histogram-quantile%2F${version}/histogram-quantile_${node_os}_${node_arch}.tar.gz"
tar -xzf histogram-quantile.tar.gz
chmod +x histogram-quantile
mv histogram-quantile /var/lib/clickhouse/user_scripts/histogramQuantile
echo "histogram-quantile installed successfully"
init:
image:
registry: docker.io
repository: alpine
tag: 3.18.2
pullPolicy: IfNotPresent
command:
- sh
- -c
- |
set -e
version="v0.0.1"
node_os=$(uname -s | tr '[:upper:]' '[:lower:]')
node_arch=$(uname -m | sed s/aarch64/arm64/ | sed s/x86_64/amd64/)
echo "Fetching histogram-binary for ${node_os}/${node_arch}"
cd /tmp
wget -O histogram-quantile.tar.gz "https://github.com/SigNoz/signoz/releases/download/histogram-quantile%2F${version}/histogram-quantile_${node_os}_${node_arch}.tar.gz"
# TODO: set EXPECTED_SHA256 via values and validate
echo "${EXPECTED_SHA256} histogram-quantile.tar.gz" | sha256sum -c -
tar -xzf histogram-quantile.tar.gz
chmod +x histogram-quantile
mv histogram-quantile /var/lib/clickhouse/user_scripts/histogramQuantile
echo "histogram-quantile installed successfully"
init:
🤖 Prompt for AI Agents
In charts/clickhouse/values.yaml around lines 351-371 the init container
downloads the histogram-quantile binary at runtime via wget which is a
supply-chain and airgap risk; replace this by either baking the pinned
histogram-quantile binary into the container image (preferred) and updating the
image.repository/tag to a new image that already contains
/var/lib/clickhouse/user_scripts/histogramQuantile, or if you must download at
init, pin the exact artifact URL and add checksum verification (fetch a
known-good checksum file or hardcode the expected sha256, verify the downloaded
tar.gz before extraction and exit non-zero on mismatch) and fail fast on any
network or verification error.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
charts/clickhouse/templates/clickhouse-instance/clickhouse-instance.yaml (1)

350-352: Scope extraContainers under clickhouseInstance (keep backward-compat via coalesce)

Current path .Values.extraContainers is inconsistent with the new scoping and may break values.

-            {{- if .Values.extraContainers }}
-              {{- toYaml .Values.extraContainers | nindent 12 }}
-            {{- end }}
+            {{- $extra := coalesce .Values.clickhouseInstance.extraContainers .Values.extraContainers }}
+            {{- if $extra }}
+              {{- toYaml $extra | nindent 12 }}
+            {{- end }}
♻️ Duplicate comments (4)
charts/clickhouse/templates/clickhouse-instance/clickhouse-instance.yaml (4)

120-122: External Zookeeper path now correctly scoped — good catch


396-409: volumeClaimTemplates path typo fixed and correctly scoped — nice


84-86: Avoid embedding access keys in plain text; prefer Kubernetes Secrets / workload identity

Credentials are templated directly into the CR. Use Secrets (and/or ADC/workload identity for GCP) as previously suggested.

I can provide a Secret-based variant for both S3 and GCS if desired.

Also applies to: 93-95


89-95: GCS block sets s3 — must be gcs

This misconfig breaks GCS disks.

               <gcs>
                 <support_batch_delete>false</support_batch_delete>
-                <type>s3</type>
+                <type>gcs</type>
                 <endpoint>{{ .Values.clickhouseInstance.coldStorage.endpoint }}</endpoint>
                 <access_key_id>{{ .Values.clickhouseInstance.coldStorage.accessKey }}</access_key_id>
                 <secret_access_key>{{ .Values.clickhouseInstance.coldStorage.secretAccess }}</secret_access_key>
🧹 Nitpick comments (3)
charts/clickhouse/templates/clickhouse-instance/clickhouse-instance.yaml (3)

75-76: Provide a safe default for keep_free_space_bytes

Prevents "" rendering when not set.

-                <keep_free_space_bytes>{{ .Values.clickhouseInstance.coldStorage.defaultKeepFreeSpaceBytes }}</keep_free_space_bytes>
+                <keep_free_space_bytes>{{ default "10737418240" .Values.clickhouseInstance.coldStorage.defaultKeepFreeSpaceBytes }}</keep_free_space_bytes>

200-201: Default imagePullPolicy to IfNotPresent to avoid nil lookups

If unset, Helm will fail with a nil error.

-              imagePullPolicy: {{ .Values.clickhouseInstance.initContainers.udf.image.pullPolicy }}
+              imagePullPolicy: {{ default "IfNotPresent" .Values.clickhouseInstance.initContainers.udf.image.pullPolicy }}
-              imagePullPolicy: {{ .Values.clickhouseInstance.initContainers.init.image.pullPolicy }}
+              imagePullPolicy: {{ default "IfNotPresent" .Values.clickhouseInstance.initContainers.init.image.pullPolicy }}
-              imagePullPolicy: {{ .Values.clickhouseInstance.image.pullPolicy }}
+              imagePullPolicy: {{ default "IfNotPresent" .Values.clickhouseInstance.image.pullPolicy }}

Also applies to: 210-211, 220-220


1-1: Yamllint false positives on templating directives

The reported yamllint errors stem from Go templating at the top of the file. Consider a yamllint rule override for Helm templates (or use helm-lint) to avoid noise.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 1f0e5b9 and 73dbaac.

📒 Files selected for processing (1)
  • charts/clickhouse/templates/clickhouse-instance/clickhouse-instance.yaml (14 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2024-12-16T16:15:01.460Z
Learnt from: prashant-shahi
PR: SigNoz/charts#565
File: charts/clickhouse/values.yaml:261-264
Timestamp: 2024-12-16T16:15:01.460Z
Learning: In `charts/clickhouse/values.yaml`, the `customStartupProbe`, `customLivenessProbe`, and `customReadinessProbe` configurations are provided for advanced users to specify custom probe types such as HTTP, Exec, TCP, and gRPC.

Applied to files:

  • charts/clickhouse/templates/clickhouse-instance/clickhouse-instance.yaml
🪛 YAMLlint (1.37.1)
charts/clickhouse/templates/clickhouse-instance/clickhouse-instance.yaml

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

(syntax)


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

(indentation)


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

(indentation)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: test-chart
🔇 Additional comments (1)
charts/clickhouse/templates/clickhouse-instance/clickhouse-instance.yaml (1)

233-274: Probes look consistent with custom probe overrides — LGTM


profiles:
{{- merge dict .Values.profiles .Values.defaultProfiles | toYaml | nindent 6 }}
{{- merge dict .Values.clickhouseInstance.profiles .Values.clickhouseInstance.defaultProfiles | toYaml | nindent 6 }}
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 merge precedence: user values currently get overridden by defaults

In Sprig, later maps win. The current order makes defaults override user-provided profiles/settings.

Apply:

-      {{- merge dict .Values.clickhouseInstance.profiles .Values.clickhouseInstance.defaultProfiles | toYaml | nindent 6 }}
+      {{- merge (dict) .Values.clickhouseInstance.defaultProfiles .Values.clickhouseInstance.profiles | toYaml | nindent 6 }}
-      {{- merge dict .Values.clickhouseInstance.settings .Values.clickhouseInstance.defaultSettings | toYaml | nindent 6 }}
+      {{- merge (dict) .Values.clickhouseInstance.defaultSettings .Values.clickhouseInstance.settings | toYaml | nindent 6 }}

Also applies to: 46-46

🤖 Prompt for AI Agents
In charts/clickhouse/templates/clickhouse-instance/clickhouse-instance.yaml
around line 36 (and also at line 46), the merge dict call passes user profiles
before defaults so defaults currently win; swap the merge arguments so defaults
are merged first and user-provided .Values.clickhouseInstance.profiles come last
(e.g. merge dict .Values.clickhouseInstance.defaultProfiles
.Values.clickhouseInstance.profiles) to ensure user values override defaults.

@nlamirault
Copy link
Contributor Author

there is a new one for the Operator part: #730

@nlamirault
Copy link
Contributor Author

@nlamirault nlamirault closed this Sep 1, 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.

Provide option to disable clickhouse-instance.yaml

2 participants