Abstract
This article provides the instructions on how to provision an application(say Percona-MySQL) using OpenEBS Local PV-hostpath. The default hostpath is configured as /var/openebs/local.
Prerequisites
- Kubernetes 1.12 or higher is required to use OpenEBS Local PV.
- OpenEBS version 1.0.0 or higher.
Step-by-Step
The following is the sample deployment configuration of Percona application which is going to consume OpenEBS Local PV-hostpath.
STEP 1
For utilizing OpenEBS Local PV based on hostpath, use default StorageClass name as openebs-hostpath
in the PVC spec of the Percona deployment.
--- apiVersion: apps/v1beta1 kind: Deployment metadata: name: percona labels: name: percona spec: replicas: 1 selector: matchLabels: name: percona template: metadata: labels: name: percona spec: securityContext: fsGroup: 999 tolerations: - key: "ak" value: "av" operator: "Equal" effect: "NoSchedule" containers: - resources: limits: cpu: 0.5 name: percona image: percona args: - "--ignore-db-dir" - "lost+found" env: - name: MYSQL_ROOT_PASSWORD value: k8sDem0 ports: - containerPort: 3306 name: percona volumeMounts: - mountPath: /var/lib/mysql name: demo-vol1 volumes: - name: demo-vol1 persistentVolumeClaim: claimName: demo-vol1-claim --- kind: PersistentVolumeClaim apiVersion: v1 metadata: name: demo-vol1-claim spec: storageClassName: openebs-hostpath accessModes: - ReadWriteOnce resources: requests: storage: 5G --- apiVersion: v1 kind: Service metadata: name: percona-mysql labels: name: percona-mysql spec: ports: - port: 3306 targetPort: 3306 selector: name: percona
STEP 2
Deploy the application using the following command. In this example, the above configuration YAML spec is saved as demo-percona-mysql-pvc.yaml
kubectl apply -f demo-percona-mysql-pvc.yaml
Verify application status
The Percona application will be running on the OpenEBS local PV on hostpath. Verify if the application is running using the following command.
kubectl get pod -n <namespace>
The output will be similar to the following.
NAME READY STATUS RESTARTS AGE
percona-7b64956695-hs7tv 1/1 Running 0 21s
Verify PVC & PV status
Verify PVC status using the following command.
kubectl get pvc -n <namespace>
The output will be similar to the following.
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
demo-vol1-claim Bound pvc-2e4b123e-88ff-11e9-bc28-42010a8001ff 5G RWO openebs-hostpath 28s
Verify PV status using the following command.
kubectl get pv
The output will be similar to the following.
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
pvc-2e4b123e-88ff-11e9-bc28-42010a8001ff 5G RWO Delete Bound default/demo-vol1-claim openebs-hostpath 22s