Skip to content

Commit 8943cc1

Browse files
authored
Merge pull request #27 from coroot/clickhouse_changes
extend CRD with `StoreMetricsInClickhouse`
2 parents a994991 + 06457c4 commit 8943cc1

File tree

5 files changed

+15
-5
lines changed

5 files changed

+15
-5
lines changed

api/v1/coroot_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ type CorootSpec struct {
269269
GRPC GRPCSpec `json:"grpc,omitempty"`
270270
// TLS settings (enables TLS for gRPC if defined).
271271
TLS *TLSSpec `json:"tls,omitempty"`
272+
// Store metrics in ClickHouse. If enabled, Prometheus will not be installed.
273+
StoreMetricsInClickhouse bool `json:"storeMetricsInClickhouse,omitempty"`
272274
// Environment variables for Coroot.
273275
Env []corev1.EnvVar `json:"env,omitempty"`
274276

config/crd/coroot.com_coroots.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8126,6 +8126,10 @@ spec:
81268126
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
81278127
x-kubernetes-int-or-string: true
81288128
type: object
8129+
storeMetricsInClickhouse:
8130+
description: Store metrics in ClickHouse. If enabled, Prometheus will
8131+
not be installed.
8132+
type: boolean
81298133
tls:
81308134
description: TLS settings (enables TLS for gRPC if defined).
81318135
properties:

controller/controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func (r *CorootReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr
145145
}
146146
r.CreateOrUpdateIngress(ctx, cr, r.corootIngress(cr), cr.Spec.Ingress == nil)
147147

148-
if cr.Spec.ExternalPrometheus == nil {
148+
if cr.Spec.ExternalPrometheus == nil && !cr.Spec.StoreMetricsInClickhouse {
149149
r.CreateOrUpdateServiceAccount(ctx, cr, "prometheus", sccNonroot)
150150
r.CreateOrUpdatePVC(ctx, cr, r.prometheusPVC(cr), cr.Spec.Prometheus.Storage.ReclaimPolicy)
151151
r.CreateOrUpdateDeployment(ctx, cr, r.prometheusDeployment(cr))

controller/coroot.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -516,9 +516,13 @@ func (r *CorootReconciler) corootStatefulSet(cr *corootv1.Coroot, configEnvs Con
516516
env = append(env, corev1.EnvVar{Name: "GLOBAL_PROMETHEUS_REMOTE_WRITE_URL", Value: ep.RemoteWriteUrl})
517517
}
518518
} else {
519-
env = append(env,
520-
corev1.EnvVar{Name: "GLOBAL_PROMETHEUS_URL", Value: fmt.Sprintf("http://%s-prometheus.%s:9090", cr.Name, cr.Namespace)},
521-
)
519+
if cr.Spec.StoreMetricsInClickhouse {
520+
env = append(env, corev1.EnvVar{Name: "GLOBAL_PROMETHEUS_USE_CLICKHOUSE", Value: "true"})
521+
} else {
522+
env = append(env,
523+
corev1.EnvVar{Name: "GLOBAL_PROMETHEUS_URL", Value: fmt.Sprintf("http://%s-prometheus.%s:9090", cr.Name, cr.Namespace)},
524+
)
525+
}
522526
}
523527

524528
if ec := cr.Spec.ExternalClickhouse; ec != nil {

controller/versions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
const (
1515
CorootImageRegistry = "ghcr.io/coroot"
1616

17-
ClickhouseImage = "clickhouse:25.1.3-ubi9-0"
17+
ClickhouseImage = "clickhouse:25.11.2-ubi9-0"
1818
PrometheusImage = "prometheus:2.55.1-ubi9-0"
1919
KubeStateMetricsImage = "kube-state-metrics:2.15.0-ubi9-0"
2020
)

0 commit comments

Comments
 (0)