Matomo on Kubernetes

We provide a comparison between: Docker Images, Helm Charts and a Kubernetes Operator.

Matomo is an open source web analytics platform that consists of the following components:

  1. Backend component written in PHP: github.com/matomo-org/matomo
  2. Relational database, e.g. MySQL or MariaDB
  3. Optional use of Redis for queued tracking and caching.

Matomo Docker for Kubernetes.

Matomo publishes Docker Images on GitHub (github.com/matomo-org/docker), which allow easy local installation. Using volumes, the initial configuration can be persisted.

Warning: When upgrading Matomo, the initial configuration will be overwritten and Matomo must be reconfigured again.

To solve this problem, it is necessary to check at each container startup if a database migration or initialization is necessary. In Kubernetes, this task can be handled by an InitCotainer. With the Matomo Plugin ExtraTools this action can be performed from the command line.

However, deploying the Matomo Docker image on Kubernetes is still quite laborious, as several components have to be configured manually (deployment, service, ingress).

In addition, an external (managed) database must be used and linked to the manual installation.

Matomo Helm Chart

Helm charts offer the possibility to summarize the manually configured components in a Chart. On the platform Artifact Hub multiple Matomo Helm Charts can be found.

However, these Helm charts still must be configured by the user. Often it must be defined in which configuration Matomo should be installed (e.g. with or without Redis). Before every update it still needs to be checked, whether the new images are still compatible with the existing volumes and data structure. A major upgrade of database versions is often not possible via Helm-Charts.

In summary, it can be said that Helm-Charts are a quick way to install Matomo, but in the long run it can lead to a significant effort.

Step-by-step instructions can be found here:

Matomo Kubernetes Operator

Another option for automatic installation and operation for Matomo on Kubernetes is a Kubernetes Operator. It not only can adjust the initial installation to the cloud infrastructure and needs of the customer, but also takes care of future updates. If needed an update of the Kubernetes Operator also initiates an automated update of Matomo. Additionally, Kubernetes Operators offer the ability to dynamically adjust the type of installation based on the load profile.

We at Glasskube have developed a Kubernetes operator for Matomo, which can be already previewed:

If a Kubernetes cluster already exists and kubectl is installed, you need to clone our Git repository github.com/glasskube/operator as first step for the Matomo installation.

git clone git@github.com:glasskube/operator.git

The script deploy.sh installs the required dependencies and custom resource definitions.

# Cluster-wide deployment of version X.Y.Z (or latest)
# of the Glasskube operator 
deploy/deploy.sh -v latest

Once the installation of the operator is complete, Matomo can now be installed. For this purpose the following custom resource must be installed:

Important A DNS entry must be set on the LoadBalancer or the Ingress Host. SSL certificates are automatically generated by LoadBalancer or cert-manager if a ClusterIssuer is configured.

Matomo.yaml

apiVersion: "glasskube.eu/v1alpha1"
kind: Matomo
metadata:
  name: matomo
  namespace: matomo
spec:
  host: matomo.hostname.tld # hostname
kubectl apply -f Matomo.yaml

Now the installation is complete. Updates to the Kubernetes operator will automatically update Matomo.

Conclusion

Matomo can be installed in a Kubernetes cluster in several ways. An installation using the Docker image is helpful to learn more about Kubernetes without too many new technologies. An installation via Helm helps to deploy the needed resources much faster. A Kubernetes operator supports running Matomo in autopilot mode.

Get started in less than 10 minutes

Glasskube installs, runs, and updates open source software automatically in your cloud without IT effort.

But it does not have to be like this

Now full data control is one click away