PVC
yaml
1apiVersion: v12kind: PersistentVolumeClaim3metadata:4 name: mysql-pvc5spec:6 accessModes:7 - ReadWriteOnce8 resources:9 requests:10 storage: 40GiMySQL config
yaml
1apiVersion: v12kind: ConfigMap3metadata:4 name: mysql-config5data:6 my.cnf: |7 [mysqld]8 innodb_flush_log_at_trx_commit=29 sync_binlog=010 bulk_insert_buffer_size=256M11 innodb_buffer_pool_size=4G12 innodb_log_file_size=1G13 innodb_log_buffer_size=64M14 innodb_redo_log_capacity = 2G15 max_allowed_packet = 256MMySQL Deployment
yaml
1apiVersion: apps/v12kind: Deployment3metadata:4 name: mysqlsingle5spec:6 replicas: 17 selector:8 matchLabels:9 app: mysqlsingle10 template:11 metadata:12 labels:13 app: mysqlsingle14 spec:15 containers:16 - name: mysqlsingle17 image: mysql:8.018 env:19 - name: MYSQL_ROOT_PASSWORD20 value: "123"21 ports:22 - containerPort: 330623 resources:24 requests:25 memory: "4Gi"26 cpu: "2"27 limits:28 memory: "8Gi"29 cpu: "4"30 volumeMounts:31 - mountPath: /var/lib/mysql32 name: mysql-data33 - mountPath: /etc/mysql/my.cnf34 name: mysql-config-volume35 subPath: my.cnf36 volumes:37 - name: mysql-data38 persistentVolumeClaim:39 claimName: mysql-pvc40 - name: mysql-config-volume41 configMap:42 name: mysql-config43---44apiVersion: v145kind: Service46metadata:47 name: mysqlsingle48spec:49 type: LoadBalancer50 selector:51 app: mysqlsingle52 ports:53 - port: 330654 targetPort: 3306