IOMesh for MySQL
Prerequisite
Verify that your IOMesh cluster is already deployed.
Procedure
NOTE: The following example does not apply to a
AArch64Kubernetes cluster.
Create a YAML config
iomesh-mysql-sc.yamlwith the following content. You may also use the default StorageClassiomesh-csi-driver. See more details in Create StorageClass.kind: StorageClass apiVersion: storage.k8s.io/v1 metadata: name: iomesh-mysql-sc provisioner: com.iomesh.csi-driver # The driver name in `iomesh.yaml`. reclaimPolicy: Retain allowVolumeExpansion: true parameters: csi.storage.k8s.io/fstype: "ext4" replicaFactor: "2" thinProvision: "true"Apply the YAML config to create the StorageClass.
kubectl apply -f iomesh-mysql-sc.yamlCreate a YAML config
mysql-deployment.yamlwith the following content, containingPersistentVolumeClaim,Service, andDeployment. Enter a password to allow access to the database as instructed below.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: # Enter a password to allow access to the database. - 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-pvcFor more information, refer to Kubernetes Deployment and Service.
Apply the YAML config to deploy MySQL.
kubectl apply -f mysql-deployment.yamlAfter completion, IOMesh will create a PV for the MySQL pod with configurations such as filesystem type and replication factor specified in the StorageClass.
You can expand, snapshot, or clone persistent volumes where MySQL data are located. For details, refer to Volume Operations and VolumeSnapshot Operations.