Skip to content

Commit ac0dc9f

Browse files
authored
Merge pull request #24 from coroot/external_clickhouse_tls
add TLS settings for external clickhouse
2 parents 9ad6c67 + 1437c9d commit ac0dc9f

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

api/v1/coroot_types.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,12 @@ type ExternalClickhouseSpec struct {
177177
Database string `json:"database,omitempty"`
178178
// Password for accessing the external ClickHouse (plain-text, not recommended).
179179
Password string `json:"password,omitempty"`
180-
// Secret containing password for accessing the external ClickHouse.
180+
// Secret containing a password for accessing the external ClickHouse.
181181
PasswordSecret *corev1.SecretKeySelector `json:"passwordSecret,omitempty"`
182+
// Whether to enable TLS for the connection to ClickHouse.
183+
TLSEnabled bool `json:"tlsEnabled,omitempty"`
184+
// Whether to skip verification of the ClickHouse server's TLS certificate.
185+
TLSSkipVerify bool `json:"tlsSkipVerify,omitempty"`
182186
}
183187

184188
type PostgresSpec struct {
@@ -192,7 +196,7 @@ type PostgresSpec struct {
192196
Database string `json:"database,omitempty"`
193197
// Password for accessing postgres (plain-text, not recommended).
194198
Password string `json:"password,omitempty"`
195-
// Secret containing password for accessing postgres.
199+
// Secret containing a password for accessing postgres.
196200
PasswordSecret *corev1.SecretKeySelector `json:"passwordSecret,omitempty"`
197201
// Extra parameters, e.g., sslmode and connect_timeout.
198202
Params map[string]string `json:"params,omitempty"`
@@ -234,7 +238,7 @@ type TLSSpec struct {
234238
// Secret containing TLS certificate.
235239
// +kubebuilder:validation:Required
236240
CertSecret *corev1.SecretKeySelector `json:"certSecret,omitempty"`
237-
// Secret containing TLS private key.
241+
// Secret containing a TLS private key.
238242
// +kubebuilder:validation:Required
239243
KeySecret *corev1.SecretKeySelector `json:"keySecret,omitempty"`
240244
}

config/crd/coroot.com_coroots.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4908,7 +4908,7 @@ spec:
49084908
not recommended).
49094909
type: string
49104910
passwordSecret:
4911-
description: Secret containing password for accessing the external
4911+
description: Secret containing a password for accessing the external
49124912
ClickHouse.
49134913
properties:
49144914
key:
@@ -4932,6 +4932,13 @@ spec:
49324932
- key
49334933
type: object
49344934
x-kubernetes-map-type: atomic
4935+
tlsEnabled:
4936+
description: Whether to enable TLS for the connection to ClickHouse.
4937+
type: boolean
4938+
tlsSkipVerify:
4939+
description: Whether to skip verification of the ClickHouse server's
4940+
TLS certificate.
4941+
type: boolean
49354942
user:
49364943
description: Username for accessing the external ClickHouse.
49374944
type: string

controller/coroot.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,12 @@ func (r *CorootReconciler) corootStatefulSet(cr *corootv1.Coroot, configEnvs Con
528528
corev1.EnvVar{Name: "GLOBAL_CLICKHOUSE_INITIAL_DATABASE", Value: ec.Database},
529529
)
530530
env = append(env, envVarFromSecret("GLOBAL_CLICKHOUSE_PASSWORD", ec.PasswordSecret, ec.Password))
531+
if ec.TLSEnabled {
532+
env = append(env, corev1.EnvVar{Name: "GLOBAL_CLICKHOUSE_TLS_ENABLED", Value: "true"})
533+
if ec.TLSSkipVerify {
534+
env = append(env, corev1.EnvVar{Name: "GLOBAL_CLICKHOUSE_TLS_SKIP_VERIFY", Value: "true"})
535+
}
536+
}
531537
} else {
532538
env = append(env,
533539
corev1.EnvVar{

0 commit comments

Comments
 (0)