MySQL deployment with PVC, Limits, my.cnf with LoadBalancer
PVC
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysql-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 40Gi
MySQL config
apiVersion: v1
kind: ConfigMap
metadata:
name: mysql-config
data:
my.cnf: |
[mysqld]
innodb_flush_log_at_trx_commit=2
sync_binlog=0
bulk_insert_buffer_size=256M
innodb_buffer_pool_size=4G
innodb_log_file_size=1G
innodb_log_buffer_size=64M
innodb_redo_log_capacity = 2G
max_allowed_packet = 256M
MySQL Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysqlsingle
spec:
replicas: 1
selector:
matchLabels:
app: mysqlsingle
template:
metadata:
labels:
app: mysqlsingle
spec:
containers:
- name: mysqlsingle
image: mysql:8.0
env:
- name: MYSQL_ROOT_PASSWORD
value: "123"
ports:
- containerPort: 3306
resources:
requests:
memory: "4Gi"
cpu: "2"
limits:
memory: "8Gi"
cpu: "4"
volumeMounts:
- mountPath: /var/lib/mysql
name: mysql-data
- mountPath: /etc/mysql/my.cnf
name: mysql-config-volume
subPath: my.cnf
volumes:
- name: mysql-data
persistentVolumeClaim:
claimName: mysql-pvc
- name: mysql-config-volume
configMap:
name: mysql-config
---
apiVersion: v1
kind: Service
metadata:
name: mysqlsingle
spec:
type: LoadBalancer
selector:
app: mysqlsingle
ports:
- port: 3306
targetPort: 3306