Deadsimple Wordpress in Kubernetes

2 minute read Updated

A microtutorial to run WordPress locally in Kubernetes under Docker.

How to install Wordpress with Bravada theme for local development in 8 steps.

Tip: If this tutorial is too high-level for you, have a look here instead.

Step 1: Install Dependencies

Step 2: Clone Sources

  1. Clone WordPress Helm Chart from OSA
  2. Clone WordPress from Pantheon Systems

Put them next to each other.

Step 3: Create Cluster

Bootstrap K3s in a multi-node Docker cluster:

k3d cluster create k3s-wordpress -i rancher/k3s:latest \
    --api-port 6550 --agents 2

Step 4: Update WordPress

Remove spurious themes and push to remote:

cd wordpress && \
rm -rf wp-content/themes/twenty* && \
git commit -m "perf: ⚡️ remove theme cruft" && \
git push -u gitlab default

Helm Chart requires GitLab for WordPress customizations.

Step 5: Prepare Chart

cd ../wordpress-helm && \
cp && chmod +x && \
cp values-local.yaml.example values-local.yaml

Edit values-local.yaml and your own CLI image if desired:

228  repository: comfusion/wp-cli-docker
229  tag:
230  pullPolicy: Always

Find and edit themes_install section to add Bravada and TwentyTwentyOne themes:

45  themes_install:
46  - twentytwentyone
47  - bravada
48  theme_active: bravada
49  theme_fallback: twentytwentyone

Also configure git_repo to use GitLab repo created in Step 4.

Step 6: Deploy Chart

export KUBECONFIG=$(k3d kubeconfig write k3s-wordpress)

kubectl create namespace sandbox && \
./ -n sandbox

Wait until pods are Ready up with watch kubectl get pods -n sandbox. Debug init-container with Lens…

Step 7: Connect to Lens

Write kubeconfig:

k3d kubeconfig write k3s-wordpress -o `pwd`/kubeconfig-k3d-dev

Open kubeconfig-k3d-dev in Lens:


Watch wordpress-production-0 Ansible logs for errors:


Step 8: Browse the Site

With pods Ready proxy the ClusterIP service (prefix with sudo -E if needed):

kubectl port-forward service/wordpress-production 80:8080 -n sandbox

Browse the site:

Enable Redis in values-local.yaml. Run ./ -n sandbox. Profit.