k8s mysql 启动binlog
apiVersion: v1
kind: ConfigMap
metadata:
name: mysql-config
data:
mysqld.cnf: |-
[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
#log-error = /var/log/mysql/error.log
## By default we only accept connections from localhost
##bind-address = 127.0.0.1
## Disabling symbolic-links is recommended to prevent assorted security risks
#symbolic-links=0
symbolic-links=0
log-bin=/var/lib/mysql/mysql-bin
server-id=1
configMap 挂在 /etc/mysql/mysql.conf.d 目录下的 mysqld.cnf
apiVersion: v1
kind: ReplicationController
metadata:
labels:
app: mysql-business
name: mysql-business
spec:
replicas: 1
selector:
app: mysql-business
template:
metadata:
labels:
app: mysql-business
spec:
containers:
- name: mysql-business
image: docker-registry-node:5000/mysql:5.7.37
ports:
- containerPort: 3306
env:
- name: MYSQL_ROOT_PASSWORD
value: "123456"
volumeMounts:
- name: mysql-volume
mountPath: /var/lib/mysql
- name: mysql-config-volume
mountPath: /etc/mysql/mysql.conf.d
volumes:
- name: mysql-volume
hostPath:
path: /var/lib/mysql
- name: mysql-config-volume
configMap:
#defaultMode: 420
name: mysql-config
参考: configMap defaultMode :https://www.orchome.com/10358