paint-brush
How to run WordPress on Kubernetesby@BuddyWorks
2,263 reads
2,263 reads

How to run WordPress on Kubernetes

by BuddyNovember 22nd, 2017
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

This guide covers creating K8s volumes and configuring a WP instance with a MySQL database in a most simple way — a perfect introduction to <a href="https://hackernoon.com/tagged/kubernetes" target="_blank">Kubernetes </a>for newbies.

Company Mentioned

Mention Thumbnail
featured image - How to run WordPress on Kubernetes
Buddy HackerNoon profile picture

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.

Configure a PersistentVolume in the K8s cluter

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.

Create volumes.yml

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

Create your K8s volumes

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

Like what your read? Check out the full guide here!

Other posts:

1. How to Dockerize WordPress sites

2. How to automate WordPress delivery with Docker and Buddy