How this Web Site was Born. Part 2 (Google Cloud Platform and Kubernetes Cluster)


I wanted to spin up something similar on GCP that I have running on AWS for this mini blog. AWS is running a CentOS7 VM with a docker instance of WordPress and MySQL. I signed up for a free year subscription on GCP ($300 credit). I then decided to create a Kubernetes cluster to house my WordPress/MySQL docker instances. Note: I know there is more than one way to skin a cat. This is the hard way to get a WordPress website running. (I tried to show my non-technical friend, he said: “Wow, you got a 1998 website running, I’m so proud of you (sarcasm).” Here is how i did it. I hope it helps.

GCP version (UNDER CONSTRUCTION, https required for .app domains):
AWS version:

STEP 1: Take the GCP tutorial

– Tutorial Name: Persistent Disks with WordPress and MySQL
– Tutorial Link:

STEP 2: Create Project, then open gcloud shell (top right in menu), run commands:

Basics and get yaml files from git

gcloud components install kubectl
gcloud config set project [your-project-id-here]
gcloud config set compute/zone us-central1-a
sudo yum install git            
git clone
cd kubernetes-engine-samples/wordpress-persistent-disks

Create a kubernetes cluster with CLI or from web GUI. I used web gui to choose shared CPU and less RAM for lower cost

gcloud container clusters create [your-cluster-name-here] --num-nodes=3

Create persistant volumes

gcloud container clusters get-credentials [your-cluster-name-here]
kubectl apply -f mysql-volumeclaim.yaml
kubectl apply -f wordpress-volumeclaim.yaml
kubectl get pvc

Create WordPress and MySQL container/pods

kubectl create secret generic mysql --from-literal=password=[your-new-password-here]
kubectl create -f mysql.yaml
kubectl get pod -l app=mysql
kubectl create -f mysql-service.yaml
kubectl get service mysql
kubectl create -f wordpress.yaml
kubectl get pod -l app=wordpress
kubectl get pod

Create load balancer for Ephemeral (temp) external IP

kubectl create -f wordpress-service.yaml
kubectl get svc -l app=wordpress

Optional: Create Static IP (May be easier in GUI)

gcloud compute addresses create my-static-ip-name –region us-central1

OPTIONAL: test data persistence. MySQL container should regenerate automatically after delete

kubectl get pods -o=wide
kubectl delete pod -l app=mysql 
kubectl get pods -o=wide

OPTIONAL: update the container version/software

kubectl apply -f wordpress.yaml 
kubectl apply -f mysql.yaml

OPTIONAL: DELETE/ClEANUP on GCP (or delete cluster from web gui)

kubectl delete service wordpress
gcloud compute forwarding-rules list
kubectl delete pvc wordpress-volumeclaim
kubectl delete pvc mysql-volumeclaim
gcloud container clusters delete keep-v-weird-cluster-x

OPTIONAL: (Not recomended for PRODUCTION) set size from 3 to 1 nodes to save money

gcloud container clusters resize [your-cluster-name-here] --region us-central1-a --size=1

Leave a Reply