cancel
Showing results for 
Search instead for 
Did you mean: 

How to make sure that Kyma persistent storage is mounted correctly?

hagarnabil
Explorer
0 Kudos
302

Hi everyone,

I've deployed mysql with persistent storage but I don't know how to make sure if my data is really mounted correctly. These are my files,

apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql
spec:
selector:
matchLabels:
app: mysql
strategy:
type: Recreate
template:
metadata:
labels:
app: mysql
spec:
containers:
- image: hagarrnabil/mysql
name: mysql
env:
- name: MYSQL_ROOT_PASSWORD
value: P@ssword
- name: MYSQL_DATABASE
value: mysql
- name: MYSQL_USER
value: admin
- name: MYSQL_PASSWORD
value: P@ssword
ports:
- containerPort: 3306
name: mysql
volumeMounts:
- name: mysql-persistent-storage
mountPath: /var/lib/mysql
volumes:
- name: mysql-persistent-storage
persistentVolumeClaim:
claimName: mysql-pv-claim
---
apiVersion: v1
kind: Service
metadata:
name: mysql
spec:
ports:
- port: 3306
selector:
app: mysql
apiVersion: v1
kind: PersistentVolume
metadata:
name: mysql-pv-volume
labels:
type: local
spec:
storageClassName: manual
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/data"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysql-pv-claim
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: manual
provisioner: kubernetes.io/aws-ebs
parameters:
type: gp2
reclaimPolicy: Retain
allowVolumeExpansion: true
mountOptions:
- debug
volumeBindingMode: Immediate

Thanks in advance!

gabbi
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Hagar Nabil,

A few comments.

  • You do not need to define Persistent Volume and Storage Class
  • Only Persistent Volume Claim should suffice. You should use the default storage class.
  • You can verify that the data is persisted by restarting the pod and verifying the data is still there.

Please check this sample for reference: https://github.com/SAP-samples/kyma-runtime-extension-samples/tree/main/database-mssql

I would recommend reading about Kubernetes Persistent volume claims and dynamic provisioning.

BR

Gaurav

Accepted Solutions (0)

Answers (0)