Kubernetes MySQL

deplopyment

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
apiVersion: v1
kind: PersistentVolume
metadata:
name: common-mysql-pv
labels:
name: common-mysql-pv
spec:
capacity:
storage: 200Gi
accessModes:
- ReadWriteOnce
storageClassName: class-common-mysql
persistentVolumeReclaimPolicy: Retain
gcePersistentDisk:
pdName: "common-mysql-disk"
fsType: "ext4"

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: common-mysql-pv-claim
spec:
accessModes:
- ReadWriteOnce
storageClassName: class-common-mysql
resources:
requests:
storage: 200Gi
selector:
matchLabels:
name: common-mysql-pv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: mysql-deployment
labels:
app: mysql
spec:
replicas: 1
selector:
matchLabels:
app: mysql
template:
metadata:
labels:
app: mysql
spec:
containers:
- image:
name: mysql
args: ["--ignore-db-dir=lost+found"]
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mysql
key: password
ports:
- containerPort: 3306
volumeMounts:
- name: mysql-persistent-storage
mountPath: /var/lib/mysql
volumes:
- name: mysql-persistent-storage
persistentVolumeClaim:
claimName: common-mysql-pv-claim

Problem:
[ERROR] –initialize specified but the data directory has files in it. Aborting.

solution: args: [“–ignore-db-dir=lost+found”]