IOMesh for MySQL
Setup k8s Cluster Storage
Create a file named
iomesh-mysql-sc.yaml
with the following contentS:kind: StorageClass apiVersion: storage.k8s.io/v1 metadata: name: iomesh-mysql-sc provisioner: com.iomesh.csi-driver # driver.name in values.yaml when install IOMesh cluster reclaimPolicy: Retain allowVolumeExpansion: true parameters: csi.storage.k8s.io/fstype: "ext4" replicaFactor: "2" thinProvision: "true"
Apply the yaml config:
kubectl apply -f iomesh-mysql-sc.yaml
Deploy MySQL
Create a file named
mysql-deployment.yaml
. It describes a Deployment that runs MySQL and creates a PVC that consumes the IOMesh storage.apiVersion: v1 kind: PersistentVolumeClaim metadata: name: iomesh-mysql-pvc spec: storageClassName: iomesh-mysql-sc accessModes: - ReadWriteOnce resources: requests: storage: 10Gi --- apiVersion: v1 kind: Service metadata: name: mysql spec: ports: - port: 3306 selector: app: mysql clusterIP: None --- apiVersion: apps/v1 kind: Deployment metadata: name: mysql spec: selector: matchLabels: app: mysql strategy: type: Recreate template: metadata: labels: app: mysql spec: containers: - image: mysql:5.6 name: mysql env: # Use secret in real usage - name: MYSQL_ROOT_PASSWORD value: password ports: - containerPort: 3306 name: mysql volumeMounts: - name: mysql-persistent-storage mountPath: /var/lib/mysql volumes: - name: mysql-persistent-storage persistentVolumeClaim: claimName: iomesh-mysql-pvc # pvc from iomesh created above
Apply the yaml config:
kubectl apply -f mysql-deployment.yaml
Operate MySQL Data
Users can use the features provided by IOMesh storage to perform such operations as expansion/snapshot/rollback/clone of the Persistent Volumes where MySQL data are located, see the reference for details application-operations