I have an EKS cluster which has following files.
1)mysql deployment file 2)pvc claim file 3)storageclass file
when I run all three files, dynamically ebs volume is created. Then I make an entry in mysql table and try to delete and recreate the pod.
Now everything in ebs volume gets deleted and there is no data.
I am trying to figure out how to make the data persistent when pod or deployment gets deleted and started again.
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql
spec:
selector:
matchLabels:
application: mysql
replicas: 1
template:
metadata:
labels:
application: mysql
spec:
containers:
- name: mysql
image: vjk94/data-admin2:version2
volumeMounts:
- mountPath: /var/lib/mysql
name: mysql-data
volumes:
- name: mysql-data
persistentVolumeClaim:
claimName: mysql-data
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: mysql-data
spec:
storageClassName: ebs-sc
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: ebs-sc
provisioner: kubernetes.io/aws-ebs
parameters:
type: gp2
fsType: ext4
reclaimPolicy: Retain
allowVolumeExpansion: true
mountOptions:
- debug
volumeBindingMode: WaitForFirstConsumer