We learned how to install the Kubernetes cluster in the previous section. Now, let's create a more complex example with Kubernetes. In this application, we will deploy an application running a WordPress site and MySQL database using official Docker images.
- Create a persistent volume. Both WordPress and MySQL will use this volume to store data. We will create two local persistent volumes of size 5 GB each. Copy the following content to the
volumes.yaml
file:
apiVersion: v1kind: PersistentVolumemetadata: name: pv-1 labels: type: localspec: capacity: storage: 5Gi accessModes: - ReadWriteOnce hostPath: path: /tmp/data/pv-1 storageClassName: slow ---apiVersion: v1kind: PersistentVolumemetadata: name: pv-2 labels: type: localspec: capacity: storage: 5Gi accessModes: - ReadWriteOnce hostPath: path: /tmp/data/pv-2 storageClassName: slow
- Now, create the volume by running the following command:
$ kubectl create -f volumes.yaml persistentvolume...