Files
cameleer-server/deploy/clickhouse.yaml
hsiegeln a669df08bd
Some checks failed
CI / cleanup-branch (push) Has been skipped
CI / build (push) Failing after 40s
CI / docker (push) Has been skipped
CI / deploy (push) Has been skipped
CI / deploy-feature (push) Has been skipped
fix(clickhouse): tune memory settings to prevent OOM on insert
ClickHouse 24.12 auto-sizes caches from the cgroup limit, leaving
insufficient headroom for MV processing and background merges.
Adds a custom config that shrinks mark/index/expression caches and
caps per-query memory at 2 GiB. Bumps container limit 4Gi → 6Gi.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 22:54:43 +02:00

141 lines
3.7 KiB
YAML

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
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"
ports:
- containerPort: 8123
name: http
- containerPort: 9000
name: native
volumeMounts:
- name: data
mountPath: /var/lib/clickhouse
- name: initdb
mountPath: /docker-entrypoint-initdb.d
- name: config
mountPath: /etc/clickhouse-server/config.d/memory-tuning.xml
subPath: memory-tuning.xml
readOnly: true
resources:
requests:
memory: "2Gi"
cpu: "500m"
limits:
memory: "6Gi"
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
volumes:
- name: initdb
configMap:
name: clickhouse-initdb
- name: config
configMap:
name: clickhouse-config
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
---
apiVersion: v1
kind: ConfigMap
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
metadata:
name: clickhouse-initdb
namespace: cameleer
data:
01-create-database.sql: |
CREATE DATABASE IF NOT EXISTS cameleer;