CKAD · 18 November 2026 · 4 min read

WordPress on Kubernetes: the tutorial, object by object, and what the exams test

The official WordPress and MySQL tutorial on Kubernetes, read object by object: a Secret, two Deployments, two Services and two PersistentVolumeClaims, what the CKA and CKAD test in each, and what to change for production.

To run WordPress on Kubernetes you need seven objects: a Secret for the database password, a Deployment and a Service for MySQL, a Deployment and a Service for WordPress, and a PersistentVolumeClaim for each so files and data survive a Pod restart. WordPress finds MySQL by the Service's name. That is exactly what the official Kubernetes tutorial builds, and every one of those objects is something the CKA or CKAD asks you to create, inspect or fix. As written, though, it runs one Pod of each and is not meant for production.

TL;DR

  • One Secret, two Deployments, two Services and two PersistentVolumeClaims make the whole application.
  • WordPress reaches MySQL through the Service name wordpress-mysql, resolved by cluster DNS.
  • Both volumes are ReadWriteOnce, so each Deployment runs one Pod and uses the Recreate strategy.
  • Exam skills inside: Secrets as environment variables, Services and DNS, claims and access modes, Deployment strategies.
  • For production: a managed database or a StatefulSet, shared storage to scale, an Ingress, a NetworkPolicy, and real backups.

The problem: state on a platform built for replaceable Pods

Kubernetes assumes it can stop and replace any Pod at any time. WordPress keeps uploads and plugins on disk, and MySQL keeps all its data on disk. Those files must outlive any single Pod, which is what PersistentVolumes are for: storage with a life of its own, claimed by a Pod through a PersistentVolumeClaim.

The design, object by object

  • Secret mysql-pass. Holds the database password. The tutorial generates it with kustomize's secretGenerator; both Deployments read it as an environment variable.
  • MySQL. A Deployment running one mysql:8.0 Pod with the Recreate strategy, its data on a 20Gi ReadWriteOnce claim mounted at /var/lib/mysql. A headless Service called wordpress-mysql, on port 3306, gives it a stable name.
  • WordPress. A Deployment running one wordpress:6.2.1-apache Pod, also with Recreate, its files on a second 20Gi claim at /var/www/html. Its WORDPRESS_DB_HOST is simply wordpress-mysql.
  • The front door. A Service of type LoadBalancer exposes WordPress on port 80.
  • Storage. The claims name no StorageClass, so the cluster's default class provisions their volumes.

What the CKA and CKAD test in it

This small application is a tour of exam skills. On a cluster where it is running, these are the checks worth being fast at:

Shell
kubectl get pvckubectl describe pvc wp-pv-claimkubectl get svc wordpress-mysql -o widekubectl get endpointslices -l kubernetes.io/service-name=wordpress-mysqlkubectl exec deploy/wordpress -- env | grep WORDPRESS_DBkubectl get deploy wordpress -o jsonpath='{.spec.strategy.type}'
  • Claims and access modes (CKA Storage). A claim stuck in Pending usually means no StorageClass can satisfy it: describe shows why. ReadWriteOnce means one node at a time can mount the volume read-write.
  • Services and DNS (both exams). A Service with no endpoints means its selector matches no ready Pods. The name wordpress-mysql resolves inside the namespace; from elsewhere, use wordpress-mysql.<namespace>.svc.cluster.local.
  • Secrets as environment variables (CKAD). secretKeyRef under env, and how to check what a Pod actually received.
  • Deployment strategies (CKAD). Why Recreate here: see below.

Why Recreate, not a rolling update?

A rolling update starts the new Pod before stopping the old one. With a ReadWriteOnce volume, the new Pod can be left waiting for a volume the old Pod still holds, especially if it lands on another node. Recreate stops the old Pod first, at the cost of a short outage on every release. It is the same reason this design cannot simply be scaled to three replicas.

From tutorial to production

  • Check the storage class. On local test clusters the default class can keep data on a single node, and it is lost if the Pod moves. Use network-backed storage.
  • Use a managed database, or a StatefulSet. One MySQL Pod in a Deployment has no failover. A managed MySQL service handles backups, patching and failover; inside the cluster, a StatefulSet run by an operator is the better shape.
  • Move WordPress's files to scale it. Several WordPress Pods need ReadWriteMany storage, or media in object storage through a plugin. Then a rolling update and a HorizontalPodAutoscaler make sense.
  • Put an Ingress or Gateway in front. One cloud load balancer per Service adds up. An Ingress controller shares one entry point, terminates TLS and routes by host name.
  • Lock down the database. A NetworkPolicy that lets only the WordPress Pods reach port 3306 keeps everything else out. See NetworkPolicies explained.
  • Keep secrets out of git, set requests and limits, and back up the volumes. A volume is not a backup.

When not to use Kubernetes for WordPress

For a single blog, managed WordPress hosting or one virtual machine is cheaper and simpler. If nobody on the team runs Kubernetes already, the cluster becomes the hardest part of hosting a blog. And a mostly static site is better generated and served from a CDN.

Draw it before you build it

This architecture comes from our sister product archhy, where it was drawn with the official Kubernetes icons. To draw it yourself, open archhy, choose the Kubernetes pack in the palette and search by kubectl short names such as deploy, svc and pvc. Lay it out in three rows (control, traffic, storage) and label the line from WordPress to MySQL with WORDPRESS_DB_HOST = wordpress-mysql: it explains service discovery better than a paragraph. More in Draw a Kubernetes architecture diagram with archhy.

Based on

The Kubernetes documentation tutorial Example: Deploying WordPress and MySQL with Persistent Volumes (The Kubernetes Authors). The architecture walk-through and production advice are adapted from archhy's article on the same tutorial; the exam notes are Gazeek's.

Keep going

Practice claims, Services and Secrets on a real cluster in the CKAD course, and storage in the CKA course. For exam-style tasks, try the CKAD practice questions.

More from the blog