This guide covers creating K8s volumes and configuring a WP instance with a MySQL database in a most simple way — a perfect introduction to Kubernetes for newbies.
It is a direct followup to the articles on dockerizing and automating the delivery of WordPress projects, allowing you to introduce the power of Docker to your dev setup. Now it’s time to unleash it on a cluster of Google-powered nodes.
Since we only have one node in the cluster we’ll use a hostPath
volume. This type of volume mounts the path from the node's filesystem into K8s.
apiVersion: v1kind: PersistentVolumemetadata: name: local-pv-1 labels: type: localspec: capacity: storage: 10Gi accessModes: - ReadWriteOnce hostPath: path: /k8/volume/pv-1---apiVersion: v1kind: PersistentVolumemetadata: name: local-pv-2 labels: type: localspec: capacity: storage: 10Gi accessModes: - ReadWriteOnce hostPath: path: /k8/volume/pv-2
This config will create two R/W 10GB volumes in the node paths:
/k8/volume/pv-1/k8/volume/pv-2
To create the volumes, run
kubectl apply -f volumes.yml
You can run the command below to check if eveything’s correct:
kubectl get pvNAME CAPACITY ACCESSMODES RECLAIMPOLICY STATUS CLAIM STORAGECLASS REASON AGElocal-pv-1 10Gi RWO Retain Available 13slocal-pv-2 10Gi RWO Retain Available 13s
Other posts: