WordPress on Kubernetes

The Definitive Guide to WordPress on k8s

Installing Redis in Kubernetes

Redis is a very fast and flexible in-memory key-value store, which is perfect to run as a persistent object caching backend for WordPress. In this section we’ll explore a couple of deployment options for a Redis service in Kubernetes and create our own StatefulSet in our cluster.

Note: all code samples from this section are available on GitHub.

Redis Persistence

When we refer to an object caching backend for WordPress, we often use the term persistent which in that context means the data can persist across HTTP requests, contrary to how the native object caching works. However, in Redis, persistence means something else.

Redis is an in-memory key-value database, and with persistence, Redis is able to save all its data to a non-volatile storage device, such as a disk (or a persistent volume in our case). This keeps the data across Redis restarts and is necessary when using it as a canonical source for your data, or when working with very large amounts of data.

In the WordPress case, we’re planning to use Redis as just a cache, meaning any data it contains is okay to lose. We do not need to store this data to disk, nor do we need it to persist across Redis server restarts. In fact, this may cause cache inconsistency, given that the canonical data may have changed during a restart.

This requirement allows us to have a simpler, more portable and slightly more efficient configuration. So we’ll run Redis in non-persistent mode (in-memory only), however it will provide a very much persistent object caching backend for WordPress.

Redis Operators

There are a couple of Redis operators available from third party vendors, and a paid enterprise version too. Feel free to explore those if you wish, however given our simple use case for Redis, we’ll skip using a proper operator and instead create our own StatefulSet.

There’s a very neat and flexible Bitnami Redis Helm chart for Redis too, which supports master-replica and cluster configurations. However, given that most WordPress plugins for Redis do not even support these topologies, we’ll leave this more complex setup for a different post.

This article is for premium members only. Memberships start from $125/year and unlock access to all existing and future content on kubeadm.org, including all reference architectures.

Already a member? Login here