Top Tags

MySQL deployment with PVC, Limits, my.cnf with LoadBalancer

Deploying MySQL with PVC, Limits, my.cnf with LoadBalancer

PVC

yaml
1apiVersion: v1
2kind: PersistentVolumeClaim
3metadata:
4 name: mysql-pvc
5spec:
6 accessModes:
7 - ReadWriteOnce
8 resources:
9 requests:
10 storage: 40Gi

MySQL config

yaml
1apiVersion: v1
2kind: ConfigMap
3metadata:
4 name: mysql-config
5data:
6 my.cnf: |
7 [mysqld]
8 innodb_flush_log_at_trx_commit=2
9 sync_binlog=0
10 bulk_insert_buffer_size=256M
11 innodb_buffer_pool_size=4G
12 innodb_log_file_size=1G
13 innodb_log_buffer_size=64M
14 innodb_redo_log_capacity = 2G
15 max_allowed_packet = 256M

MySQL Deployment

yaml
1apiVersion: apps/v1
2kind: Deployment
3metadata:
4 name: mysqlsingle
5spec:
6 replicas: 1
7 selector:
8 matchLabels:
9 app: mysqlsingle
10 template:
11 metadata:
12 labels:
13 app: mysqlsingle
14 spec:
15 containers:
16 - name: mysqlsingle
17 image: mysql:8.0
18 env:
19 - name: MYSQL_ROOT_PASSWORD
20 value: "123"
21 ports:
22 - containerPort: 3306
23 resources:
24 requests:
25 memory: "4Gi"
26 cpu: "2"
27 limits:
28 memory: "8Gi"
29 cpu: "4"
30 volumeMounts:
31 - mountPath: /var/lib/mysql
32 name: mysql-data
33 - mountPath: /etc/mysql/my.cnf
34 name: mysql-config-volume
35 subPath: my.cnf
36 volumes:
37 - name: mysql-data
38 persistentVolumeClaim:
39 claimName: mysql-pvc
40 - name: mysql-config-volume
41 configMap:
42 name: mysql-config
43---
44apiVersion: v1
45kind: Service
46metadata:
47 name: mysqlsingle
48spec:
49 type: LoadBalancer
50 selector:
51 app: mysqlsingle
52 ports:
53 - port: 3306
54 targetPort: 3306