feat: allow exposing additional ports on ClickHouse service and pods#197
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a new additionalPorts field on ClickHouseClusterSpec so that users can expose extra TCP ports (e.g., MySQL/Postgres/gRPC protocols) on the operator-managed Pod and headless Service. Manifest plumbing, CRD generation, deepcopy, validation, documentation, an example, and an e2e test are all updated accordingly.
Changes:
- Add
AdditionalPorttype/field onClickHouseClusterSpecwith CRD constraints (listMapKey=name, DNS-label name, port range 1–65535) and update CRD/docs/values/deepcopy. - Wire the new field into the headless Service and Pod container port lists in
templates.go. - Add webhook validation for duplicate ports and accompanying webhook unit tests plus an e2e test exercising the MySQL protocol.
Reviewed changes
Copilot reviewed 9 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| api/v1alpha1/clickhousecluster_types.go | Adds AdditionalPort type and AdditionalPorts field with validation markers. |
| api/v1alpha1/zz_generated.deepcopy.go | Generated deepcopy for the new type/field. |
| config/crd/bases/clickhouse.com_clickhouseclusters.yaml | Regenerated CRD with the new property and list-map keys. |
| dist/chart/templates/crd/clickhouseclusters.clickhouse.com.yaml | Same CRD regeneration for the chart copy. |
| dist/chart-cluster/values.yaml | Documents the new additionalPorts value. |
| docs/reference/api-reference.mdx | Adds reference documentation for AdditionalPort. |
| examples/custom_protocols.yaml | New example showing how to expose additional protocols. |
| go.mod / go.sum | Adds github.com/go-sql-driver/mysql dependency (used by the e2e test). |
| internal/controller/clickhouse/templates.go | Appends user-declared ports to Service and Container port lists. |
| internal/webhook/v1alpha1/clickhousecluster_webhook.go | Rejects duplicate port numbers across AdditionalPorts. |
| internal/webhook/v1alpha1/clickhousecluster_webhook_test.go | Tests acceptance, duplicate-name (CRD-enforced), and duplicate-port cases. |
| test/e2e/clickhouse_e2e_test.go | New e2e: opens MySQL port via AdditionalPorts and connects via MySQL driver. |
Files not reviewed (1)
- api/v1alpha1/zz_generated.deepcopy.go: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This was referenced May 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
ClickHouse has various server protocols, and we need a way to enable them.
What
Add a new spec field
additionalPortsto specify additional ports that should be added to Service's and Pods's spec.