KubePress


KubePress Logo

A Kubernetes operator for deploying/managing WordPress Instances. Highly Available MySQL Cluster, PHPMyAdmin and SFTP included.

Key FeaturesHow To UseInstallationBuild and DevelopmentLicense

Video Demo

Made with ❤️ by Hostzero

Key Features

Need help with your DevOps or Kubernetes setup? Contact us at Hostzero for professional support and services!

How To Use

Deploying a WordPress instance with KubePress involves two steps:

  1. Create a Secret containing the WordPress credentials (These will be used as the intial username/password for WordPress, SFTP and the Database user).
  2. Create a WordPress Custom Resource that references the Secret created in step 1.

For more detailed instructions, please refer to the User Guide.

Create the secret in the same namespace where you want to deploy the WordPress instance.

kubectl apply -f - <<EOF
apiVersion: v1
kind: Secret
metadata:
  name: wp--w1-com
  namespace: kubepress
type: Opaque
data:
  username: YWRtaW4=          # admin
  password: cGFzc3dvcmQK      # password
EOF

After that, you can create the WordPress Custom Resource as shown below.

kubectl apply -f - <<EOF
apiVersion: crm.hostzero.de/v1
kind: WordPressSite
metadata:
    name: wp--w1-com
    namespace: kubepress
spec:
    siteTitle: w1
    adminEmail: admin@example.com
    adminUserSecretKeyRef: wp--w1-com
    database:
        createNew: true
    wordpress:
        image: wordpress:latest
        maxUploadLimit: 64M
        replicas: 1
        resources:
            cpuLimit: 500m
            cpuRequest: 250m
            memoryLimit: 1Gi
            memoryRequest: 512Mi
        storageSize: 10Gi
    ingress:
        host: w1.com
        tls: false
EOF

After a few seconds, the operator will create all the necessary resources for your WordPress instance. After that the website should be accessible:

curl -I w1.com/wp-login.php

Installation

Installation of KubePress is done using a Helm chart. The chart is located in the dist/chart directory and is generated by the kubebuilder toolchain.

Install the MariaDB Operator

helm repo add mariadb-operator https://helm.mariadb.com/mariadb-operator

helm install mariadb-operator-crds mariadb-operator/mariadb-operator-crds

helm install mariadb-operator \
  -n mariadb-operator --create-namespace \
  mariadb-operator/mariadb-operator

Please refer to the official MariaDB Operator Docs for detailed instructions.

Install the KubePress Operator

Helm must be installed to use the charts. Please refer to Helm’s documentation to get started.

Once Helm has been set up correctly, add the repo as follows:

helm repo add kubepress https://hostzero-gmbh.github.io/KubePress/

Before installing the operator make sure that all the config values are correct.

Especially make sure that all the values under the key controllerManager.env in dist/chart/values.yaml are set correctly. What these values do is explained in the comments in the values.yaml file.

To install the KubePress Helm chart, you can use the following command:

helm upgrade --install my-kubepress kubepress/kubepress --namespace kubepress-controller -f dist/chart/values.yaml

Test the Helm chart with dry-run

Before trying the real thing, you can test the Helm chart with a dry-run to see if everything is set up correctly.

helm upgrade --install kubepress dist/chart/ --namespace kubepress-controller -f dist/chart/values.yaml --dry-run

Uninstallation

To delete the Helm release, you can use the following command:

helm uninstall kubepress --namespace kubepress-controller

Build and Development

Prerequisites

Understanding the Codebase

The KubePress operator is built using the Operator SDK, which simplifies the development of Kubernetes operators. To understand the codebase, familiarize yourself with the following directories:

Building the Operator

To build the KubePress operator, follow these steps:

  1. Do a build with docker
    docker build -t kubepress-dev:0.1.17 .
    
  2. If you want to regenerate the types and CRDs, you can run the following command:
    make generate
    
  3. Set the version of the helm chart to 0.1.17 in chart/Chart.yaml.
  4. Then install the operator with helm as outlined in the Installation section above.

Testing TLS

For testing TLS, deploy a self-signed issuer:

kubectl apply -f - <<EOF
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
  name: selfsigned-cluster-issuer
spec:
  selfSigned: {}
EOF

Helm Chart Generation

To generate the Helm chart, you can use the following command:

# Enable or Update the helm chart via the helm plugin to an existing project
# Before run the edit command, run `make manifests` to generate the manifest under `config/`
make manifests
kubebuilder edit --plugins=helm/v1-alpha

This is documented in the Kubebuilder documentation.

License

This project is licensed under the MIT License. See the LICENSE file for details.