301 lines
10 KiB
YAML
301 lines
10 KiB
YAML
{{- if .Values.mariadbHelm }}
|
|
|
|
---
|
|
apiVersion: v1
|
|
kind: ConfigMap
|
|
metadata: { name: "{{ .Values.mariadbMaster }}-config", namespace: "{{ .Values.namespace }}" }
|
|
data:
|
|
replication.cnf: |
|
|
[mysqld]
|
|
skip_name_resolve=1
|
|
server-id=1
|
|
|
|
# --- log ---
|
|
log_bin=mysql-bin
|
|
binlog_format=ROW
|
|
binlog_expire_logs_seconds=604800
|
|
max_binlog_total_size=32212254720
|
|
|
|
# --- durability ---
|
|
innodb_flush_log_at_trx_commit=1
|
|
sync_binlog=1
|
|
|
|
# --- connection / thread pool ---
|
|
max_connections={{ .Values.profiles.mariadbMaster.maxConnections }}
|
|
thread_handling=pool-of-threads
|
|
thread_pool_size={{ .Values.profiles.mariadbMaster.threadPoolSize }}
|
|
thread_pool_max_threads=128
|
|
thread_pool_stall_limit=500
|
|
|
|
innodb_buffer_pool_size={{ .Values.profiles.mariadbMaster.innodbBufferPoolSize }}
|
|
innodb_buffer_pool_instances={{ .Values.profiles.mariadbMaster.innodbBufferPoolInstances }}
|
|
innodb_flush_method=O_DIRECT
|
|
innodb_flush_neighbors=0
|
|
innodb_io_capacity=2000
|
|
innodb_io_capacity_max=4000
|
|
innodb_log_file_size=1G
|
|
innodb_log_buffer_size=64M
|
|
|
|
# --- cache ---
|
|
query_cache_type=0
|
|
query_cache_size=0
|
|
table_open_cache={{ .Values.profiles.mariadbMaster.tableOpenCache }}
|
|
table_open_cache_instances={{ .Values.profiles.mariadbMaster.tableOpenCacheInstances }}
|
|
table_definition_cache={{ .Values.profiles.mariadbMaster.tableOpenCache }}
|
|
open_files_limit=65535
|
|
|
|
# --- buffers ---
|
|
tmp_table_size={{ .Values.profiles.mariadbMaster.tmpTableSize }}
|
|
max_heap_table_size={{ .Values.profiles.mariadbMaster.tmpTableSize }}
|
|
sort_buffer_size=2M
|
|
join_buffer_size=2M
|
|
read_buffer_size=256K
|
|
read_rnd_buffer_size=512K
|
|
|
|
# --- timeouts ---
|
|
wait_timeout=60
|
|
interactive_timeout=300
|
|
|
|
max_allowed_packet=64M
|
|
|
|
slow_query_log=1
|
|
long_query_time=1
|
|
slow_query_log_file=/var/lib/mysql/slow.log
|
|
log_error=/var/lib/mysql/error.log
|
|
|
|
---
|
|
apiVersion: v1
|
|
kind: ConfigMap
|
|
metadata: { name: "{{ .Values.mariadbSlave }}-config", namespace: "{{ .Values.namespace }}" }
|
|
data:
|
|
replication.cnf: |
|
|
[mysqld]
|
|
skip_name_resolve=1
|
|
server-id=2
|
|
read_only=1
|
|
|
|
# --- log ---
|
|
relay-log=relay-log
|
|
relay_log_purge=1
|
|
relay_log_recovery=1
|
|
|
|
# --- connection / thread pool ---
|
|
max_connections={{ .Values.profiles.mariadbSlave.maxConnections }}
|
|
thread_handling=pool-of-threads
|
|
thread_pool_size={{ .Values.profiles.mariadbSlave.threadPoolSize }}
|
|
thread_pool_max_threads=32
|
|
thread_pool_stall_limit=500
|
|
|
|
# --- InnoDB ---
|
|
innodb_buffer_pool_size={{ .Values.profiles.mariadbSlave.innodbBufferPoolSize }}
|
|
innodb_buffer_pool_instances={{ .Values.profiles.mariadbSlave.innodbBufferPoolInstances }}
|
|
innodb_flush_method=O_DIRECT
|
|
innodb_flush_neighbors=0
|
|
innodb_io_capacity=1000
|
|
innodb_io_capacity_max=2000
|
|
innodb_log_file_size=512M
|
|
innodb_log_buffer_size=32M
|
|
|
|
# --- durability (for standby recovery replica) ---
|
|
innodb_flush_log_at_trx_commit=1
|
|
sync_binlog=1
|
|
|
|
# --- cache ---
|
|
query_cache_type=0
|
|
query_cache_size=0
|
|
table_open_cache={{ .Values.profiles.mariadbSlave.tableOpenCache }}
|
|
table_open_cache_instances={{ .Values.profiles.mariadbSlave.tableOpenCacheInstances }}
|
|
table_definition_cache={{ .Values.profiles.mariadbSlave.tableOpenCache }}
|
|
open_files_limit=65535
|
|
|
|
# --- buffers ---
|
|
tmp_table_size={{ .Values.profiles.mariadbSlave.tmpTableSize }}
|
|
max_heap_table_size={{ .Values.profiles.mariadbSlave.tmpTableSize }}
|
|
sort_buffer_size=1M
|
|
join_buffer_size=1M
|
|
read_buffer_size=256K
|
|
read_rnd_buffer_size=512K
|
|
|
|
# --- timeouts ---
|
|
wait_timeout=60
|
|
interactive_timeout=300
|
|
|
|
max_allowed_packet=64M
|
|
|
|
# --- logs ---
|
|
slow_query_log=0
|
|
log_error=/var/lib/mysql/error.log
|
|
|
|
---
|
|
apiVersion: v1
|
|
kind: PersistentVolume
|
|
metadata: { name: "{{ .Values.mariadbMaster }}-pv" }
|
|
spec:
|
|
capacity: { storage: 100Gi }
|
|
volumeMode: Filesystem
|
|
accessModes: [ ReadWriteOnce ]
|
|
persistentVolumeReclaimPolicy: Retain
|
|
hostPath: { path: "{{ .Values.mariadbMasterPath }}", type: DirectoryOrCreate }
|
|
|
|
---
|
|
apiVersion: v1
|
|
kind: PersistentVolumeClaim
|
|
metadata: { name: "{{ .Values.mariadbMaster }}-pvc", namespace: "{{ .Values.namespace }}" }
|
|
spec:
|
|
volumeName: "{{ .Values.mariadbMaster }}-pv"
|
|
volumeMode: Filesystem
|
|
accessModes: [ ReadWriteOnce ]
|
|
resources: { requests: { storage: 100Gi } }
|
|
storageClassName: ""
|
|
|
|
---
|
|
apiVersion: v1
|
|
kind: PersistentVolume
|
|
metadata: { name: "{{ .Values.mariadbSlave }}-pv" }
|
|
spec:
|
|
capacity: { storage: 100Gi }
|
|
volumeMode: Filesystem
|
|
accessModes: [ ReadWriteOnce ]
|
|
persistentVolumeReclaimPolicy: Retain
|
|
hostPath: { path: "{{ .Values.mariadbSlavePath }}", type: DirectoryOrCreate }
|
|
|
|
---
|
|
apiVersion: v1
|
|
kind: PersistentVolumeClaim
|
|
metadata: { name: "{{ .Values.mariadbSlave }}-pvc", namespace: "{{ .Values.namespace }}" }
|
|
spec:
|
|
volumeName: "{{ .Values.mariadbSlave }}-pv"
|
|
volumeMode: Filesystem
|
|
accessModes: [ ReadWriteOnce ]
|
|
resources: { requests: { storage: 100Gi } }
|
|
storageClassName: ""
|
|
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: StatefulSet
|
|
metadata: { name: "{{ .Values.mariadbMaster }}", namespace: "{{ .Values.namespace }}" }
|
|
spec:
|
|
serviceName: "{{ .Values.mariadbMaster }}-headless"
|
|
replicas: 1
|
|
selector: { matchLabels: { app: "{{ .Values.mariadbMaster }}" } }
|
|
template:
|
|
metadata: { labels: { app: "{{ .Values.mariadbMaster }}" } }
|
|
spec:
|
|
terminationGracePeriodSeconds: 60
|
|
containers:
|
|
- name: "{{ .Values.mariadbMaster }}"
|
|
image: mariadb:12.2
|
|
resources:
|
|
requests: { cpu: "{{ .Values.profiles.mariadbMaster.cpuRequest }}", memory: "{{ .Values.profiles.mariadbMaster.memoryRequest }}" }
|
|
limits: { cpu: "{{ .Values.profiles.mariadbMaster.cpuLimit }}", memory: "{{ .Values.profiles.mariadbMaster.memoryLimit }}" }
|
|
ports:
|
|
- { containerPort: 3306 }
|
|
env:
|
|
- { name: MARIADB_ROOT_PASSWORD, valueFrom: { secretKeyRef: { name: "{{ .Values.mariadb }}-secret", key: root-password } } }
|
|
- { name: LD_PRELOAD, value: /usr/lib/x86_64-linux-gnu/libjemalloc.so.2 }
|
|
readinessProbe:
|
|
exec:
|
|
command: ["sh","-lc",'mariadb-admin ping -h 127.0.0.1 -uroot -p"$MARIADB_ROOT_PASSWORD" --silent']
|
|
initialDelaySeconds: 10
|
|
periodSeconds: 5
|
|
timeoutSeconds: 3
|
|
failureThreshold: 6
|
|
livenessProbe:
|
|
exec:
|
|
command: ["sh","-lc",'mariadb-admin ping -h 127.0.0.1 -uroot -p"$MARIADB_ROOT_PASSWORD" --silent']
|
|
initialDelaySeconds: 30
|
|
periodSeconds: 10
|
|
timeoutSeconds: 3
|
|
failureThreshold: 6
|
|
volumeMounts:
|
|
- { name: "{{ .Values.mariadbMaster }}-volume", mountPath: /var/lib/mysql }
|
|
- { name: "{{ .Values.mariadbMaster }}-config-volume", mountPath: /etc/mysql/conf.d/replication.cnf, subPath: replication.cnf }
|
|
volumes:
|
|
- name: "{{ .Values.mariadbMaster }}-volume"
|
|
persistentVolumeClaim: { claimName: "{{ .Values.mariadbMaster }}-pvc" }
|
|
- name: "{{ .Values.mariadbMaster }}-config-volume"
|
|
configMap: { name: "{{ .Values.mariadbMaster }}-config" }
|
|
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: StatefulSet
|
|
metadata: { name: "{{ .Values.mariadbSlave }}", namespace: "{{ .Values.namespace }}" }
|
|
spec:
|
|
serviceName: "{{ .Values.mariadbSlave }}-headless"
|
|
replicas: 1
|
|
selector: { matchLabels: { app: "{{ .Values.mariadbSlave }}" } }
|
|
template:
|
|
metadata: { labels: { app: "{{ .Values.mariadbSlave }}" } }
|
|
spec:
|
|
terminationGracePeriodSeconds: 60
|
|
containers:
|
|
- name: "{{ .Values.mariadbSlave }}"
|
|
image: mariadb:12.2
|
|
resources:
|
|
requests: { cpu: "{{ .Values.profiles.mariadbSlave.cpuRequest }}", memory: "{{ .Values.profiles.mariadbSlave.memoryRequest }}" }
|
|
limits: { cpu: "{{ .Values.profiles.mariadbSlave.cpuLimit }}", memory: "{{ .Values.profiles.mariadbSlave.memoryLimit }}" }
|
|
ports:
|
|
- { containerPort: 3306 }
|
|
env:
|
|
- { name: MARIADB_ROOT_PASSWORD, valueFrom: { secretKeyRef: { name: "{{ .Values.mariadb }}-secret", key: root-password } } }
|
|
readinessProbe:
|
|
exec:
|
|
command: ["sh","-lc",'mariadb-admin ping -h 127.0.0.1 -uroot -p"$MARIADB_ROOT_PASSWORD" --silent']
|
|
initialDelaySeconds: 10
|
|
periodSeconds: 5
|
|
timeoutSeconds: 3
|
|
failureThreshold: 6
|
|
livenessProbe:
|
|
exec:
|
|
command: ["sh","-lc",'mariadb-admin ping -h 127.0.0.1 -uroot -p"$MARIADB_ROOT_PASSWORD" --silent']
|
|
initialDelaySeconds: 30
|
|
periodSeconds: 10
|
|
timeoutSeconds: 3
|
|
failureThreshold: 6
|
|
volumeMounts:
|
|
- { name: "{{ .Values.mariadbSlave }}-volume", mountPath: /var/lib/mysql }
|
|
- { name: "{{ .Values.mariadbSlave }}-config-volume", mountPath: /etc/mysql/conf.d/replication.cnf, subPath: replication.cnf }
|
|
volumes:
|
|
- name: "{{ .Values.mariadbSlave }}-volume"
|
|
persistentVolumeClaim: { claimName: "{{ .Values.mariadbSlave }}-pvc" }
|
|
- name: "{{ .Values.mariadbSlave }}-config-volume"
|
|
configMap: { name: "{{ .Values.mariadbSlave }}-config" }
|
|
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata: { name: "{{ .Values.mariadbMaster }}", namespace: "{{ .Values.namespace }}" }
|
|
spec:
|
|
selector: { app: "{{ .Values.mariadbMaster }}" }
|
|
ports: [ { name: mysql, protocol: TCP, port: 3306, targetPort: 3306 } ]
|
|
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata: { name: "{{ .Values.mariadbSlave }}", namespace: "{{ .Values.namespace }}" }
|
|
spec:
|
|
selector: { app: "{{ .Values.mariadbSlave }}" }
|
|
ports: [ { name: mysql, protocol: TCP, port: 3306, targetPort: 3306 } ]
|
|
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata: { name: "{{ .Values.mariadbMaster }}-headless", namespace: "{{ .Values.namespace }}" }
|
|
spec:
|
|
clusterIP: None
|
|
selector: { app: "{{ .Values.mariadbMaster }}" }
|
|
ports:
|
|
- { name: mysql, protocol: TCP, port: 3306, targetPort: 3306 }
|
|
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata: { name: "{{ .Values.mariadbSlave }}-headless", namespace: "{{ .Values.namespace }}" }
|
|
spec:
|
|
clusterIP: None
|
|
selector: { app: "{{ .Values.mariadbSlave }}" }
|
|
ports:
|
|
- { name: mysql, protocol: TCP, port: 3306, targetPort: 3306 }
|
|
|
|
{{- end }}
|