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/low-memory.xml
subPath: low-memory.xml
readOnly: true
- name: config
mountPath: /etc/clickhouse-server/users.d/low-memory-users.xml
subPath: low-memory-users.xml
readOnly: true
resources:
requests:
memory: "2Gi"
cpu: "500m"
limits:
memory: "4Gi"
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:
# Server-level tuning for 4Gi container.
# Based on https://kb.altinity.com/altinity-kb-setup-and-maintenance/configure_clickhouse_for_low_mem_envs/
low-memory.xml: |
warning
false
0.75
0
268435456
67108864
16777216
67108864
2000
64
8
2
2
1
1
1
2
4
1
1
0
0
1024
1073741824
134217728
134217728
2
2
2
# User profile settings — per-query limits and parallelism.
low-memory-users.xml: |
2
1610612736
8192
1000
600
1
0
5000
0
0
1073741824
1073741824
---
apiVersion: v1
kind: ConfigMap
metadata:
name: clickhouse-initdb
namespace: cameleer
data:
01-create-database.sql: |
CREATE DATABASE IF NOT EXISTS cameleer;