Launch a Wordpress site on Kubernetes in just 1 minute

TL;DR: How to use a Wordpress helm chart to set up a marketing frontend quickly and easily.

Wordpress on Kubernetes in just 1 minute!

The marketing frontend

Nowadays it’s rare to find a marketing page or website (landing, portfolio, product specs, …) which doesn’t use Wordpress.

I’m not going to enter in its benefits in detail, just enumerate the most important:

  • Ease of creating content (anyone can do it, no programming skills required).
  • SEO-ready.
  • A lot of plug-ins and themes.
  • Great support and adoption.

But is has a big cons: plug-ins vulnerabilities.

For that reason, it’s very important to isolate any Wordpress instance of business logic. Run Wordpress inside containers helps in this security task.

Let’s go to see how can we do it with Kubernetes.

Bitnami Wordpress Helm Chart

Probably you know what a Helm chart is. If not, we can define it as Kubernetes manifest templates(deployment, ingress, service account, …) that they are rendered with a few values introduced by the user (Ie: domain name, SSL certs, ports, …)

We just need to define these variables, render and execute the manifest templates.

In the other hand, Bitnami develops Helm charts for a lot of services.

One of them it’s for Wordpress.

You can checkout it in this GitHub repository.

The Bitnami Wordpress charts cover all the neccesary software to execute Wordpress without problems (PHP engine, MariaDB, etc).

Let’s do it

First, you need to install Helm binary if you haven’t already. Check its official installation page, it’s easy peasy.

Now we add the bitnami repository

$ helm repo add bitnami

With your favorite text editor/IDE, create a YAML file with the following content

This configuration file set-ups the Wordpress to be accessible using nginx ingress.

The most important parts are:

  • Using HTTPS for liveness and readiness probe. If you use the default HTTP protocol, the probes don’t work.
  • Using cert-manager to create a free LetsEncrypt SSL certificate. We use a cluster issuer. In the example: “letsencrypt-prod”
  • Allow uploads to unlimited size. It’s necessary to upload media contents, files, etc.
  • Allow more timeout offsets.

You can view all the available options in its Readme page.

We are ready to execute the chart now.

$ helm install -f wp-values.yaml -n mkt mkt-wp bitnami/wordpress

With the “-f” flag we specify the values to render the template. We set a custom namespace too with “-n” (note: the namespace must exists before; use kubectl create namespace <namespace> for create one).

The last two parameters are the instance name and the chart to render and apply.

If all goes well, you’ll see in the console the instructions to access and get the credentials.

If you need to get the admin password, you can use de the following command:

$ echo (kubectl get secret --namespace <namespace> wordpress -o jsonpath="{.data.wordpress-password}" | base64 --decode)

That’s all friends!

The last thing you need it’s check that everything is ok and start to create content for your new marketing frontend :)

Everything looks ok in the Rancher workload panel

Follow me if you want to stay update about Kubernetes, Go and DevOps :)

CTO @ & Beyond-Full-stack developer #go #python #kubernetes

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store