matomo
by tina.junold
Matomo is a self-hosted web analytics platform. This chart runs the ideaplexus/matomo image, which installs and migrates Matomo unattended, and supports single pods, replicas on a shared volume and replicas without one.
About this chart
matomo
Matomo is a self-hosted web analytics platform. This chart runs the ideaplexus/matomo image, which installs and migrates Matomo unattended, and supports single pods, replicas on a shared volume and replicas without one.
Homepage: https://gitlab.com/ideaplexus/charts
Maintainers
| Name | Url | |
|---|---|---|
| Tina Junold | [email protected] | https://ideaplexus.com |
Source Code
- https://gitlab.com/ideaplexus/charts/-/tree/main/charts/matomo
- https://gitlab.com/ideaplexus/matomo
- https://github.com/matomo-org/matomo
Requirements
Kubernetes: >=1.29.0-0
| Repository | Name | Version |
|---|---|---|
| https://charts.ideaplexus.com | common | 1.1.0 |
Quick start
The chart deploys Matomo, not its database. Point it at a MySQL or MariaDB you run yourself; the image creates the database if the user may, installs Matomo unattended on the first start and migrates it after every image update.
database:
host: mariadb
password: change-me
admin:
password: change-me-too
email: [email protected]
ingress:
enabled: true
hostname: analytics.example.org
tls: true
annotations:
cert-manager.io/cluster-issuer: letsencrypt
Without database.host, or without an admin password, Matomo starts its web
installer instead.
The image is ideaplexus/matomo. Its
README documents every setting the chart passes on. The image tag defaults to
the chart's appVersion, an immutable image release such as 5.14.1-1: the
Matomo version plus a revision that counts the image releases of that version.
The plain Matomo version tags (5.14.1, 5.14, 5) follow every build of the
image; set image.tag to one of them only if you want that.
Topologies
Matomo keeps its data in the database, but each pod also has a data directory,
/var/lib/matomo, with the generated configuration, caches, GeoIP databases,
plugins installed on start and the tracker files. How that directory is shared
decides the topology. The chart derives the image settings from
replicaCount, autoscaling, workload and persistence:
| Topology | Values | Data directory | Derived |
|---|---|---|---|
| Single pod | defaults | one ReadWriteOnce claim | Deployment strategy Recreate |
| Pods on a shared volume | replicaCount > 1, persistence.accessModes: [ReadWriteMany] | one claim, also mounted by the archiver | — |
| Pods without a shared volume | replicaCount > 1 with persistence.enabled: false, or workload: StatefulSet | an emptyDir, or one claim per pod | MATOMO_MULTI_SERVER=true |
Every topology with more than one pod needs redis.host: with the file cache
each pod misses the cache invalidations of the others. autoscaling.enabled
counts as more than one pod.
The chart refuses to render a combination that cannot work:
- more than one pod of a Deployment, or an autoscaled one, on a ReadWriteOnce claim: pods on other nodes cannot mount it,
- more than one pod without
redis.host, - an inline value and an existing secret for the same credential,
- the MaxMind database without a license key.
Pods on a shared volume
replicaCount: 3
redis:
host: valkey
persistence:
accessModes: [ReadWriteMany]
storageClass: nfs
Plugins and settings changed in the UI reach every pod, and the archiver's scheduled tasks, such as GeoIP updates, work on the same files.
Pods without a shared volume
workload: StatefulSet
replicaCount: 3
redis:
host: valkey
A StatefulSet gives every pod its own claim; persistence.enabled: false
gives every pod an emptyDir instead. Either way the chart sets
MATOMO_MULTI_SERVER, which disables the plugin administration in the UI —
a change there would only reach one pod. Manage plugins with plugins.install
and plugins.activate, or bundle them into a derived image. Every pod
downloads its own GeoIP database on start.
Credentials
Every credential is either an inline value, which the chart keeps in its own
secret, or the name and key of a secret you manage. They reach the pods as
secretKeyRef, never as a plain value.
| Credential | Inline | Existing secret |
|---|---|---|
| Database password | database.password | database.existingSecret, database.existingSecretPasswordKey |
| Super user password | admin.password | admin.existingSecret, admin.existingSecretPasswordKey |
| Redis password | redis.password | redis.existingSecret, redis.existingSecretPasswordKey |
| Marketplace license key | plugins.licenseKey | plugins.existingSecret, plugins.existingSecretLicenseKeyKey |
| MaxMind license key | geoip.maxmind.licenseKey | geoip.maxmind.existingSecret, geoip.maxmind.existingSecretLicenseKeyKey |
| Salt | salt.value | salt.existingSecret, salt.existingSecretKey |
The super user is only created on the first start. Changing admin later does
not change the user.
Salt
Matomo hashes tokens and sessions with MATOMO_SALT, so it has to be the same
in every pod and must never change. Without a value the chart generates one,
stores it in <release>-matomo-salt and looks it up on every upgrade. The
secret carries helm.sh/resource-policy: keep: it survives an uninstall, so a
reinstall against the same database keeps working. An upgrade that cannot find
the secret fails instead of generating a new salt.
helm template, and with it Argo CD and Flux, has no cluster access and would
generate a new salt on every render. With a GitOps tool, create the secret
yourself:
kubectl create secret generic matomo-salt --from-literal=salt="$(openssl rand -hex 32)"
salt:
existingSecret: matomo-salt
Archiving
archiver.enabled (the default) creates a CronJob that runs core:archive
once per archiver.schedule, with concurrencyPolicy: Forbid, and sets
MATOMO_BROWSER_ARCHIVING=false on the web pods. It gets the same environment
and configuration files as the web pods. It mounts the data volume only when
that is a shared ReadWriteMany claim; otherwise it writes its own configuration
into an emptyDir.
Archiving a large site needs more memory than serving it. Size the archiver on
its own with archiver.resources, and raise php.memoryLimit, which it uses
as well.
Init job
By default every pod initialises Matomo itself, serialised by a database lock: the first pod installs or migrates, the others wait and continue. That is enough for most installations.
initJob.enabled moves installation and migrations into a pre-install and
pre-upgrade hook, so they finish before the new pods roll out. The web pods
then run with MATOMO_INIT=configure: they wait for the installation and only
set up their own plugins.
- The hook runs before any other resource of the release exists. It needs a database that exists already, not one installed by the same release.
- Inline credentials and the configuration files reach the job through hook
copies,
<release>-matomo-init, created just before it. Hook resources are not removed byhelm uninstall; delete them yourself. - The job runs with an
emptyDir; it only writes to the database.
Behind an ingress
With ingress.enabled the chart derives url from ingress.hostname, with
https when the ingress has TLS, and sets the proxy headers Matomo needs to see
the visitor's IP and scheme:
| Value | Default behind the ingress |
|---|---|
proxy.clientHeaders | [HTTP_X_FORWARDED_FOR] |
proxy.schemeHeaders | [HTTP_X_FORWARDED_PROTO] |
proxy.assumeSecureProtocol | true with TLS |
Set a value to override it, or an empty list to switch a header off.
Cloudflare
geoip:
provider: cloudflare
database: none
trustedProxies:
- 10.0.0.0/8
The image maps Cloudflare's geo headers to Matomo's location provider, but only
for requests from geoip.trustedProxies (default: private ranges, which is
right behind an in-cluster ingress controller). City and region need the
Cloudflare managed transform "Add visitor location headers".
Configuration
Any INI setting can be set three ways, from lowest to highest precedence:
# a file mounted to /etc/matomo/conf.d/values.ini
configuration: |
[mail]
transport = "smtp"
host = "smtp.example.org"
# MATOMO_CONFIG__<Section>__<key> variables; lists become JSON arrays
config:
General:
login_allow_logme: true
login_whitelist_ip: [10.0.0.0/8]
# extraEnvVars, eg. from a secret
extraEnvVars:
- name: MATOMO_CONFIG__mail__password
valueFrom:
secretKeyRef:
name: smtp
key: password
configPhp is mounted to /etc/matomo/config.php for DI definitions. A change
to either file restarts the pods.
Plugins
| Way | Values |
|---|---|
| From the Marketplace on start | plugins.install, premium plugins with plugins.licenseKey |
| Activate or deactivate on every start | plugins.activate, plugins.deactivate |
| Bundled into a derived image | image.repository, image.tag |
Installing from the Marketplace in the UI also works with a single pod or a
shared volume, but needs containerSecurityContext.readOnlyRootFilesystem: false: Matomo insists on a writable plugin directory in the code. Everything
else runs with a read-only root filesystem.
Values
| Key | Type | Default | Description |
|---|---|---|---|
| admin.email | string | "" | Email address of the super user |
| admin.existingSecret | string | "" | Name of an existing secret holding the password. Evaluated as a template. |
| admin.existingSecretPasswordKey | string | "password" | Key inside that secret |
| admin.password | string | "" | Password of the super user, stored in a secret this chart creates. Mutually exclusive with admin.existingSecret. |
| admin.username | string | "admin" | Login of the super user |
| affinity | object | {} | Affinity rules for the web pods |
| archiver.activeDeadlineSeconds | string | nil | Seconds a run may take before it is stopped. Unset by default, archiving a large site takes long. |
| archiver.backoffLimit | int | 0 | Retries of a failed run |
| archiver.concurrencyPolicy | string | "Forbid" | Concurrency policy. Forbid keeps a long run from overlapping the next. |
| archiver.enabled | bool | true | Create the archiving CronJob and set MATOMO_BROWSER_ARCHIVING=false on the web pods |
| archiver.failedJobsHistoryLimit | int | 1 | Failed jobs to keep |
| archiver.options | string | "" | Additional core:archive options, MATOMO_ARCHIVE_OPTIONS, eg. --concurrent-requests-per-website=3 |
| archiver.podAnnotations | object | {} | Annotations for the archiver pods |
| archiver.resources | object | {} | Explicit container resources of the archiver. Archiving a large site needs more memory than the web pods. |
| archiver.resourcesPreset | string | "medium" | Container resources preset of the archiver, used when archiver.resources is empty |
| archiver.schedule | string | "5 * * * *" | Cron schedule |
| archiver.startingDeadlineSeconds | string | nil | Seconds a job may be late to start before the run is skipped |
| archiver.successfulJobsHistoryLimit | int | 1 | Successful jobs to keep |
| archiver.suspend | bool | false | Suspend the CronJob |
| archiver.timeZone | string | "" | Time zone of the schedule, eg. Europe/Berlin. Empty uses the controller's time zone. |
| autoInstall | bool | true | Install Matomo unattended on the first start, MATOMO_AUTO_INSTALL. Needs database.host and the admin credentials; false finishes the installation in the browser. |
| autoUpdate | bool | true | Run the database migrations of a new Matomo version on start, MATOMO_AUTO_UPDATE |
| autoscaling.enabled | bool | false | Create a HorizontalPodAutoscaler. replicaCount is then left to it. |
| autoscaling.maxReplicas | int | 5 | Maximum number of pods |
| autoscaling.minReplicas | int | 2 | Minimum number of pods |
| autoscaling.targetCPU | int | 75 | Target CPU utilization in percent |
| autoscaling.targetMemory | string | nil | Target memory utilization in percent |
| commonAnnotations | object | {} | Annotations added to every resource |
| commonLabels | object | {} | Labels added to every resource |
| config | object | {} | INI settings as {Section: {key: value}}, passed as MATOMO_CONFIG__<Section>__<key>. They win over configuration. Lists become JSON arrays, booleans 1 and 0. |
| configPhp | string | "" | PHP file with DI definitions, returning an array, mounted to /etc/matomo/config.php |
| configuration | string | "" | INI file mounted to /etc/matomo/conf.d/values.ini |
| containerPorts.http | int | 8080 | HTTP port Caddy listens on, CADDY_HTTP_PORT |
| containerSecurityContext.allowPrivilegeEscalation | bool | false | Disallow privilege escalation |
| containerSecurityContext.capabilities | object | {"drop":["ALL"]} | Linux capabilities |
| containerSecurityContext.enabled | bool | true | Enable the container security context |
| containerSecurityContext.readOnlyRootFilesystem | bool | true | Mount the root filesystem read-only. Only installing plugins from the Marketplace in the UI needs false, plugins.install works without. |
| containerSecurityContext.runAsGroup | int | 82 | Group id to run as |
| containerSecurityContext.runAsNonRoot | bool | true | Run as a non-root user |
| containerSecurityContext.runAsUser | int | 82 | User id to run as |
| customLivenessProbe | object | {} | A complete probe replacing the built-in liveness probe. Only used when livenessProbe.enabled is false. |
| c |
Deploy matomo with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has matomo on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartmatomo is pinned at v0.2.9 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply