Skip to content

Conversation

@sk-portkey
Copy link
Contributor

No description provided.

@sk-portkey sk-portkey requested a review from Copilot January 30, 2026 16:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the ClickHouse configuration to support using external secrets for authentication credentials instead of embedding them in ConfigMaps. When an external secret is configured, the user configuration is dynamically generated at runtime via an init container.

Changes:

  • Added init container to generate ClickHouse user configuration from external secrets
  • Conditionally mount user configuration based on whether external secrets are used
  • Updated ConfigMap to exclude user configuration when external secrets are enabled

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
charts/portkey-app/templates/clickhouse/stateful-set.yaml Added init container for dynamic user config generation and conditional volume mounts based on external secret usage
charts/portkey-app/templates/clickhouse/config-map.yaml Wrapped users.xml generation in conditional to exclude it when external secrets are used

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +182 to +189
{{- if .Values.clickhouse.customConfig.enabled }}
- name: clickhouse-conf
configMap:
name: {{ include "portkey.fullname" . }}-{{ .Values.clickhouse.name }}
items:
- key: config.xml
path: config.xml
{{- end }}
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

This block duplicates the clickhouse-conf volume definition that appears later in the else branch (lines 191-200). When existingSecretName is set and customConfig is enabled, both volume definitions will be present, causing a conflict with duplicate volume names.

Copilot uses AI. Check for mistakes.
Comment on lines +51 to +60
cat > /etc/clickhouse-server/users.d/users.xml << EOF
<clickhouse>
<users>
<${CLICKHOUSE_USER}>
<access_management>1</access_management>
<named_collection_control>1</named_collection_control>
<show_named_collections>1</show_named_collections>
<show_named_collections_secrets>1</show_named_collections_secrets>
<profile>default</profile>
</${CLICKHOUSE_USER}>
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

Using variable substitution in XML without escaping could allow XML injection if the username contains XML special characters like <, >, or &. Consider validating or escaping the username value.

Suggested change
cat > /etc/clickhouse-server/users.d/users.xml << EOF
<clickhouse>
<users>
<${CLICKHOUSE_USER}>
<access_management>1</access_management>
<named_collection_control>1</named_collection_control>
<show_named_collections>1</show_named_collections>
<show_named_collections_secrets>1</show_named_collections_secrets>
<profile>default</profile>
</${CLICKHOUSE_USER}>
SAFE_CLICKHOUSE_USER=$(printf '%s' "$CLICKHOUSE_USER" | sed 's/[^A-Za-z0-9_.-]/_/g')
cat > /etc/clickhouse-server/users.d/users.xml << EOF
<clickhouse>
<users>
<${SAFE_CLICKHOUSE_USER}>
<access_management>1</access_management>
<named_collection_control>1</named_collection_control>
<show_named_collections>1</show_named_collections>
<show_named_collections_secrets>1</show_named_collections_secrets>
<profile>default</profile>
</${SAFE_CLICKHOUSE_USER}>

Copilot uses AI. Check for mistakes.
{{- if .Values.clickhouse.external.existingSecretName }}
initContainers:
- name: generate-users-config
image: busybox:1.36
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

The busybox image version is pinned to a tag rather than a digest, which doesn't guarantee immutability and could pose a supply chain security risk. Consider using a digest-based reference for the init container image.

Suggested change
image: busybox:1.36
image: busybox@sha256:6d4d57701fb9b31c8ed6dfa81857232ece2b2043614d248f90f42344f9b11a0d

Copilot uses AI. Check for mistakes.
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