2026-03-31 17:08:42 +02:00
|
|
|
apiVersion: apps/v1
|
|
|
|
|
kind: StatefulSet
|
|
|
|
|
metadata:
|
|
|
|
|
name: clickhouse
|
|
|
|
|
namespace: cameleer
|
|
|
|
|
spec:
|
|
|
|
|
serviceName: clickhouse
|
|
|
|
|
replicas: 1
|
|
|
|
|
selector:
|
|
|
|
|
matchLabels:
|
|
|
|
|
app: clickhouse
|
|
|
|
|
template:
|
|
|
|
|
metadata:
|
|
|
|
|
labels:
|
|
|
|
|
app: clickhouse
|
|
|
|
|
spec:
|
|
|
|
|
containers:
|
|
|
|
|
- name: clickhouse
|
|
|
|
|
image: clickhouse/clickhouse-server:24.12
|
2026-03-31 17:54:44 +02:00
|
|
|
env:
|
|
|
|
|
- name: CLICKHOUSE_USER
|
|
|
|
|
valueFrom:
|
|
|
|
|
secretKeyRef:
|
|
|
|
|
name: clickhouse-credentials
|
|
|
|
|
key: CLICKHOUSE_USER
|
|
|
|
|
- name: CLICKHOUSE_PASSWORD
|
|
|
|
|
valueFrom:
|
|
|
|
|
secretKeyRef:
|
|
|
|
|
name: clickhouse-credentials
|
|
|
|
|
key: CLICKHOUSE_PASSWORD
|
|
|
|
|
- name: CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT
|
|
|
|
|
value: "1"
|
2026-03-31 17:08:42 +02:00
|
|
|
ports:
|
|
|
|
|
- containerPort: 8123
|
|
|
|
|
name: http
|
|
|
|
|
- containerPort: 9000
|
|
|
|
|
name: native
|
|
|
|
|
volumeMounts:
|
|
|
|
|
- name: data
|
|
|
|
|
mountPath: /var/lib/clickhouse
|
2026-03-31 17:31:17 +02:00
|
|
|
- name: initdb
|
|
|
|
|
mountPath: /docker-entrypoint-initdb.d
|
2026-03-31 22:54:43 +02:00
|
|
|
- name: config
|
|
|
|
|
mountPath: /etc/clickhouse-server/config.d/memory-tuning.xml
|
|
|
|
|
subPath: memory-tuning.xml
|
|
|
|
|
readOnly: true
|
2026-03-31 17:08:42 +02:00
|
|
|
resources:
|
|
|
|
|
requests:
|
|
|
|
|
memory: "2Gi"
|
|
|
|
|
cpu: "500m"
|
|
|
|
|
limits:
|
2026-03-31 22:54:43 +02:00
|
|
|
memory: "6Gi"
|
2026-03-31 17:08:42 +02:00
|
|
|
cpu: "2000m"
|
|
|
|
|
livenessProbe:
|
|
|
|
|
httpGet:
|
|
|
|
|
path: /ping
|
|
|
|
|
port: 8123
|
|
|
|
|
initialDelaySeconds: 10
|
|
|
|
|
periodSeconds: 10
|
|
|
|
|
timeoutSeconds: 3
|
|
|
|
|
failureThreshold: 3
|
|
|
|
|
readinessProbe:
|
|
|
|
|
httpGet:
|
|
|
|
|
path: /ping
|
|
|
|
|
port: 8123
|
|
|
|
|
initialDelaySeconds: 5
|
|
|
|
|
periodSeconds: 5
|
|
|
|
|
timeoutSeconds: 3
|
|
|
|
|
failureThreshold: 3
|
2026-03-31 17:31:17 +02:00
|
|
|
volumes:
|
|
|
|
|
- name: initdb
|
|
|
|
|
configMap:
|
|
|
|
|
name: clickhouse-initdb
|
2026-03-31 22:54:43 +02:00
|
|
|
- name: config
|
|
|
|
|
configMap:
|
|
|
|
|
name: clickhouse-config
|
2026-03-31 17:08:42 +02:00
|
|
|
volumeClaimTemplates:
|
|
|
|
|
- metadata:
|
|
|
|
|
name: data
|
|
|
|
|
spec:
|
|
|
|
|
accessModes: ["ReadWriteOnce"]
|
|
|
|
|
resources:
|
|
|
|
|
requests:
|
|
|
|
|
storage: 50Gi
|
|
|
|
|
---
|
|
|
|
|
apiVersion: v1
|
|
|
|
|
kind: Service
|
|
|
|
|
metadata:
|
|
|
|
|
name: clickhouse
|
|
|
|
|
namespace: cameleer
|
|
|
|
|
spec:
|
|
|
|
|
clusterIP: None
|
|
|
|
|
selector:
|
|
|
|
|
app: clickhouse
|
|
|
|
|
ports:
|
|
|
|
|
- port: 8123
|
|
|
|
|
targetPort: 8123
|
|
|
|
|
name: http
|
|
|
|
|
- port: 9000
|
|
|
|
|
targetPort: 9000
|
|
|
|
|
name: native
|
2026-03-31 17:31:17 +02:00
|
|
|
---
|
|
|
|
|
apiVersion: v1
|
|
|
|
|
kind: ConfigMap
|
2026-03-31 22:54:43 +02:00
|
|
|
metadata:
|
|
|
|
|
name: clickhouse-config
|
|
|
|
|
namespace: cameleer
|
|
|
|
|
data:
|
|
|
|
|
memory-tuning.xml: |
|
|
|
|
|
<clickhouse>
|
|
|
|
|
<!-- Fit comfortably in a 6Gi container (cgroup limit). -->
|
|
|
|
|
<!-- Without this file ClickHouse auto-sizes caches and buffers from the -->
|
|
|
|
|
<!-- cgroup limit, leaving almost no room for query execution. -->
|
|
|
|
|
|
|
|
|
|
<!-- Cap any single query/insert (including MV processing) at 2 GiB -->
|
|
|
|
|
<profiles>
|
|
|
|
|
<default>
|
|
|
|
|
<max_memory_usage>2147483648</max_memory_usage>
|
|
|
|
|
</default>
|
|
|
|
|
</profiles>
|
|
|
|
|
|
|
|
|
|
<!-- Shrink internal caches — defaults are sized for beefy servers -->
|
|
|
|
|
<mark_cache_size>134217728</mark_cache_size>
|
|
|
|
|
<index_mark_cache_size>67108864</index_mark_cache_size>
|
|
|
|
|
<uncompressed_cache_size>0</uncompressed_cache_size>
|
|
|
|
|
<compiled_expression_cache_size>67108864</compiled_expression_cache_size>
|
|
|
|
|
|
|
|
|
|
<merge_tree>
|
|
|
|
|
<max_bytes_to_merge_at_max_space_in_pool>536870912</max_bytes_to_merge_at_max_space_in_pool>
|
|
|
|
|
</merge_tree>
|
|
|
|
|
</clickhouse>
|
|
|
|
|
---
|
|
|
|
|
apiVersion: v1
|
|
|
|
|
kind: ConfigMap
|
2026-03-31 17:31:17 +02:00
|
|
|
metadata:
|
|
|
|
|
name: clickhouse-initdb
|
|
|
|
|
namespace: cameleer
|
|
|
|
|
data:
|
|
|
|
|
01-create-database.sql: |
|
|
|
|
|
CREATE DATABASE IF NOT EXISTS cameleer;
|