Skip to content

Commit 113e40b

Browse files
committed
make tls service ports compatible with #111
1 parent 98d0e7a commit 113e40b

3 files changed

Lines changed: 15 additions & 15 deletions

File tree

charts/clickhouse/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,9 @@ EOSQL
206206
| clickhouse.shardsCount | int | `1` | number of shards. |
207207
| clickhouse.users | list | `[]` | Configure additional ClickHouse users and per-user settings. |
208208
| clickhouse.tls | object | | TLS certificate configuration for HTTPS/TLS connections. See [examples/values-tls.yaml](examples/values-tls.yaml) for a concrete example. |
209-
| clickhouse.tls.enabled | bool | `false` | Enable TLS. When true, adds `https_port` and `tcp_port_secure` to ClickHouse settings and exposes secure ports on Service resources. Requires `clickhouse.extraPorts` to declare the corresponding container ports on the pod template. |
210-
| clickhouse.tls.httpsPort | int | `8443` | HTTPS port for secure HTTP connections. |
211-
| clickhouse.tls.secureTcpPort | int | `9440` | Secure native TCP port for encrypted client connections. |
209+
| clickhouse.tls.enabled | bool | `false` | Enable TLS. When true, adds `https_port` and `tcp_port_secure` to ClickHouse settings and exposes secure ports on Service resources. |
210+
| clickhouse.tls.httpsPort | int | `8443` | HTTPS port for secure HTTP connections. Will automatically be added to Service resources with the name `https` iff that name isn't already used in `clickhouse.extraPorts`. |
211+
| clickhouse.tls.secureTcpPort | int | `9440` | Secure native TCP port for encrypted client connections. Will automatically be added to Service resources with the name `tcp-secure` iff that name isn't already used in `clickhouse.extraPorts`. |
212212
| clickhouse.tls.certificateFile | object | | Server X509 certificate file. Requires `configFileName` and exactly one of `inlineFileContent` or `secretReference`. |
213213
| clickhouse.tls.certificateFile.configFileName | string | | Part of the destination filepath within the ClickHouse pod. Inline content is placed under `config.d/`; secret reference is placed under `secrets.d/`. See [here](https://github.com/Altinity/clickhouse-operator/blob/release-0.25.6/docs/security_hardening.md?plain=1#L428-L429) for the exact filepath format. |
214214
| clickhouse.tls.certificateFile.inlineFileContent | string | | Certificate content embedded directly in the CHI spec. Mutually exclusive with `secretReference`. |

charts/clickhouse/examples/values-tls.yaml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,4 @@
11
clickhouse:
2-
# If you enable TLS _without_ enabling secret-based cluster communication
3-
# (i.e. `clusterSecret.enabled: false`), then you need to expose the secure ports
4-
# on the pod containers via the `extraPorts:` config. Otherwise, the load balancer
5-
# won't be able to route traffic to them. This is not necessary if you also enable
6-
# secret-based cluster communication (i.e. `clusterSecret.enabled: true`).
7-
# See: https://github.com/Altinity/clickhouse-operator/blob/release-0.25.6/docs/security_hardening.md?plain=1#L516
8-
extraPorts:
9-
- name: https
10-
containerPort: &httpsPort 8443
11-
- name: tcp-secure
12-
containerPort: &tcpSecurePort 9440
13-
142
tls:
153
enabled: true
164
# httpsPort: *httpsPort # HTTPS port (default: 8443)

charts/clickhouse/templates/chi.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
{{- $service_name := tpl (include "clickhouse.serviceTemplateName" . ) . -}}
2+
{{- $extraPortNames := list }}
3+
{{- range .Values.clickhouse.extraPorts }}
4+
{{- $extraPortNames = append $extraPortNames .name }}
5+
{{- end }}
26
{{- $tlsEnabled := and .Values.clickhouse.tls .Values.clickhouse.tls.enabled -}}
37
{{- $httpsPort := (((.Values.clickhouse).tls).httpsPort) | default 8443 -}}
48
{{- $secureTcpPort := (((.Values.clickhouse).tls).secureTcpPort) | default 9440 -}}
@@ -66,12 +70,16 @@ spec:
6670
{{- end }}
6771
{{- end }}
6872
{{- if $tlsEnabled }}
73+
{{- if not (has "https" $extraPortNames) }}
6974
- name: https
7075
port: {{ $httpsPort }}
7176
targetPort: {{ $httpsPort }}
77+
{{- end }}
78+
{{- if not (has "tcp-secure" $extraPortNames) }}
7279
- name: tcp-secure
7380
port: {{ $secureTcpPort }}
7481
targetPort: {{ $secureTcpPort }}
82+
{{- end }}
7583
{{- end }}
7684
selector:
7785
{{- include "clickhouse.selectorLabels" . | nindent 12 }}
@@ -108,12 +116,16 @@ spec:
108116
{{- end }}
109117
{{- end }}
110118
{{- if $tlsEnabled }}
119+
{{- if not (has "https" $extraPortNames) }}
111120
- name: https
112121
port: {{ $httpsPort }}
113122
targetPort: {{ $httpsPort }}
123+
{{- end }}
124+
{{- if not (has "tcp-secure" $extraPortNames) }}
114125
- name: tcp-secure
115126
port: {{ $secureTcpPort }}
116127
targetPort: {{ $secureTcpPort }}
128+
{{- end }}
117129
{{- end }}
118130
selector:
119131
{{- include "clickhouse.selectorLabels" . | nindent 12 }}

0 commit comments

Comments
 (0)