203 lines
5.3 KiB
YAML
203 lines
5.3 KiB
YAML
apiVersion: mysql.presslabs.org/v1alpha1
|
|
kind: MysqlCluster
|
|
metadata:
|
|
name: mysql-cluster
|
|
spec:
|
|
replicas: {{groups['mysql']|length}}
|
|
secretName: my-secret
|
|
|
|
## For setting custom docker image or specifying mysql version
|
|
## the image field has priority over mysqlVersion.
|
|
image: {{BASE_IMAGE_URL}}/{{mysql_image}}
|
|
mysqlVersion: "8.0"
|
|
|
|
# initBucketURL: gs://bucket_name/backup.xtrabackup.gz
|
|
# initBucketSecretName:
|
|
|
|
## PodDisruptionBudget
|
|
# minAvailable: 1
|
|
|
|
## For recurrent backups set backupSchedule with a cronjob expression with seconds
|
|
backupSchedule: "0 0 0 * * *"
|
|
backupURL: local:/mysql-backup/
|
|
# backupSecretName:
|
|
backupScheduleJobsHistoryLimit: 10
|
|
backupRemoteDeletePolicy: delete
|
|
backupPVCSize: 8Gi
|
|
# backupSaveDays: 11
|
|
|
|
## Custom Server ID Offset for replication
|
|
# serverIDOffset: 100
|
|
|
|
## Configs that will be added to my.cnf for cluster
|
|
mysqlConf:
|
|
default-time-zone: '+08:00'
|
|
max-connections: 1000
|
|
# plugin-load: rpl_semi_sync_master=semisync_master.so
|
|
# plugin-load-add: rpl_semi_sync_slave=semisync_slave.so
|
|
# rpl-semi-sync-master-enabled: 'on'
|
|
# rpl-semi-sync-slave-enabled: 'on'
|
|
slave-skip-errors: all
|
|
sql-mode: >-
|
|
STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
|
|
|
|
## Specify additional pod specification
|
|
# podSpec:
|
|
# imagePullSecrets: []
|
|
# labels: {}
|
|
# annotations: {}
|
|
# affinity:
|
|
# podAntiAffinity:
|
|
# preferredDuringSchedulingIgnoredDuringExecution:
|
|
# weight: 100
|
|
# podAffinityTerm:
|
|
# topologyKey: "kubernetes.io/hostname"
|
|
# labelSelector:
|
|
# matchlabels: <cluster-labels>
|
|
# backupAffinity: {}
|
|
# backupNodeSelector: {}
|
|
# backupPriorityClassName:
|
|
# backupTolerations: []
|
|
# # Override the default preStop hook with a custom command/script
|
|
# mysqlLifecycle:
|
|
# preStop:
|
|
# exec:
|
|
# command:
|
|
# - /scripts/demote-if-master
|
|
# nodeSelector: {}
|
|
# resources:
|
|
# requests:
|
|
# memory: 1G
|
|
# cpu: 200m
|
|
# tolerations: []
|
|
# priorityClassName:
|
|
# serviceAccountName: default
|
|
# # Use a initContainer to fix the permissons of a hostPath volume.
|
|
# initContainers:
|
|
# - name: volume-permissions
|
|
# image: busybox
|
|
# securityContext:
|
|
# runAsUser: 0
|
|
# command:
|
|
# - sh
|
|
# - -c
|
|
# - chmod 750 /data/mysql; chown 999:999 /data/mysql
|
|
# volumeMounts:
|
|
# - name: data
|
|
# mountPath: /data/mysql
|
|
|
|
## Specify additional volume specification
|
|
volumeSpec:
|
|
# # https://godoc.org/k8s.io/api/core/v1#EmptyDirVolumeSource
|
|
# emptyDir: {}
|
|
|
|
# # https://godoc.org/k8s.io/api/core/v1#HostPathVolumeSource
|
|
# hostPath:
|
|
# path:
|
|
# type:
|
|
|
|
# # https://godoc.org/k8s.io/api/core/v1#PersistentVolumeClaimSpec
|
|
persistentVolumeClaim:
|
|
accessModes: [ "ReadWriteOnce" ]
|
|
resources:
|
|
requests:
|
|
storage: 10Gi
|
|
storageClassName: local-storage
|
|
selector:
|
|
matchLabels:
|
|
pv: mysql-cluster
|
|
|
|
## Specify service objectives
|
|
## If thoses SLO are not fulfilled by cluster node then that node is
|
|
## removed from scheme
|
|
# targetSLO:
|
|
# maxSlaveLatency: 10s
|
|
|
|
## You can use custom volume for /tmp partition if needed.
|
|
## Is disabled by default
|
|
## tmpfsSize: 1Gi
|
|
|
|
## Set cluster in read only
|
|
# readOnly: false
|
|
|
|
## Use `pigz` for parallel compression/decompression of backups
|
|
## Or specify any arbitrary compress/decompress commands with args
|
|
# backupCompressCommand:
|
|
# - pigz
|
|
# - --stdout
|
|
#
|
|
# backupDecompressCommand:
|
|
# - pigz
|
|
# - --decompress
|
|
|
|
## Add metrics exporter extra arguments
|
|
# metricsExporterExtraArgs:
|
|
# - --collect.info_schema.userstats
|
|
# - --collect.perf_schema.file_events
|
|
|
|
## Add extra arguments to rclone
|
|
# rcloneExtraArgs:
|
|
# - --buffer-size=1G
|
|
# - --multi-thread-streams=8
|
|
# - --retries-sleep=10s
|
|
# - --retries=10
|
|
# - --transfers=8
|
|
|
|
## Add extra arguments to xbstream
|
|
# xbstreamExtraArgs:
|
|
# - --parallel=8
|
|
|
|
## Add extra arguments to xtrabackup
|
|
# xtrabackupExtraArgs:
|
|
# - --parallel=8
|
|
|
|
## Add extra arguments to xtrabackup during --prepare
|
|
# xtrabackupPrepareExtraArgs:
|
|
# - --use-memory=5G
|
|
|
|
## Set xtrabackup target directory (the directory needs to exist)
|
|
# xtrabackupTargetDir: /var/lib/mysql/.tmp/xtrabackup/
|
|
|
|
## Add additional SQL commands to run during init of mysql
|
|
initFileExtraSQL:
|
|
- "CREATE USER 'greatwall'@'%' IDENTIFIED BY 'Greatwall8888' "
|
|
- "CREATE DATABASE IF NOT EXISTS `nacos` "
|
|
- "GRANT ALL ON *.* TO 'greatwall'@'%' "
|
|
|
|
---
|
|
apiVersion: v1
|
|
kind: Secret
|
|
metadata:
|
|
name: my-secret
|
|
type: Opaque
|
|
data:
|
|
# Greatwall8888
|
|
ROOT_PASSWORD: R3JlYXR3YWxsODg4OAo=
|
|
|
|
{% for node in groups['mysql'] %}
|
|
---
|
|
apiVersion: v1
|
|
kind: PersistentVolume
|
|
metadata:
|
|
name: mysql-cluster-{{hostvars[node].NODE_ID}}
|
|
labels:
|
|
pv: mysql-cluster
|
|
spec:
|
|
accessModes:
|
|
- ReadWriteOnce
|
|
capacity:
|
|
storage: 10Gi
|
|
local:
|
|
path: /data/mysql
|
|
nodeAffinity:
|
|
required:
|
|
nodeSelectorTerms:
|
|
- matchExpressions:
|
|
- key: kubernetes.io/hostname
|
|
operator: In
|
|
values:
|
|
- "{{hostvars[node].NODE_ID}}"
|
|
persistentVolumeReclaimPolicy: Retain
|
|
storageClassName: local-storage
|
|
{% endfor %}
|