matomo

by tina.junold

Helm chartv0.2.9App 5.14.3-4Verified publisher

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

NameEmailUrl
Tina Junold[email protected]https://ideaplexus.com

Source Code

Requirements

Kubernetes: >=1.29.0-0

RepositoryNameVersion
https://charts.ideaplexus.comcommon1.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:

TopologyValuesData directoryDerived
Single poddefaultsone ReadWriteOnce claimDeployment strategy Recreate
Pods on a shared volumereplicaCount > 1, persistence.accessModes: [ReadWriteMany]one claim, also mounted by the archiver—
Pods without a shared volumereplicaCount > 1 with persistence.enabled: false, or workload: StatefulSetan emptyDir, or one claim per podMATOMO_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.

CredentialInlineExisting secret
Database passworddatabase.passworddatabase.existingSecret, database.existingSecretPasswordKey
Super user passwordadmin.passwordadmin.existingSecret, admin.existingSecretPasswordKey
Redis passwordredis.passwordredis.existingSecret, redis.existingSecretPasswordKey
Marketplace license keyplugins.licenseKeyplugins.existingSecret, plugins.existingSecretLicenseKeyKey
MaxMind license keygeoip.maxmind.licenseKeygeoip.maxmind.existingSecret, geoip.maxmind.existingSecretLicenseKeyKey
Saltsalt.valuesalt.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 by helm 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:

ValueDefault behind the ingress
proxy.clientHeaders[HTTP_X_FORWARDED_FOR]
proxy.schemeHeaders[HTTP_X_FORWARDED_PROTO]
proxy.assumeSecureProtocoltrue 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

WayValues
From the Marketplace on startplugins.install, premium plugins with plugins.licenseKey
Activate or deactivate on every startplugins.activate, plugins.deactivate
Bundled into a derived imageimage.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

KeyTypeDefaultDescription
admin.emailstring""Email address of the super user
admin.existingSecretstring""Name of an existing secret holding the password. Evaluated as a template.
admin.existingSecretPasswordKeystring"password"Key inside that secret
admin.passwordstring""Password of the super user, stored in a secret this chart creates. Mutually exclusive with admin.existingSecret.
admin.usernamestring"admin"Login of the super user
affinityobject{}Affinity rules for the web pods
archiver.activeDeadlineSecondsstringnilSeconds a run may take before it is stopped. Unset by default, archiving a large site takes long.
archiver.backoffLimitint0Retries of a failed run
archiver.concurrencyPolicystring"Forbid"Concurrency policy. Forbid keeps a long run from overlapping the next.
archiver.enabledbooltrueCreate the archiving CronJob and set MATOMO_BROWSER_ARCHIVING=false on the web pods
archiver.failedJobsHistoryLimitint1Failed jobs to keep
archiver.optionsstring""Additional core:archive options, MATOMO_ARCHIVE_OPTIONS, eg. --concurrent-requests-per-website=3
archiver.podAnnotationsobject{}Annotations for the archiver pods
archiver.resourcesobject{}Explicit container resources of the archiver. Archiving a large site needs more memory than the web pods.
archiver.resourcesPresetstring"medium"Container resources preset of the archiver, used when archiver.resources is empty
archiver.schedulestring"5 * * * *"Cron schedule
archiver.startingDeadlineSecondsstringnilSeconds a job may be late to start before the run is skipped
archiver.successfulJobsHistoryLimitint1Successful jobs to keep
archiver.suspendboolfalseSuspend the CronJob
archiver.timeZonestring""Time zone of the schedule, eg. Europe/Berlin. Empty uses the controller's time zone.
autoInstallbooltrueInstall Matomo unattended on the first start, MATOMO_AUTO_INSTALL. Needs database.host and the admin credentials; false finishes the installation in the browser.
autoUpdatebooltrueRun the database migrations of a new Matomo version on start, MATOMO_AUTO_UPDATE
autoscaling.enabledboolfalseCreate a HorizontalPodAutoscaler. replicaCount is then left to it.
autoscaling.maxReplicasint5Maximum number of pods
autoscaling.minReplicasint2Minimum number of pods
autoscaling.targetCPUint75Target CPU utilization in percent
autoscaling.targetMemorystringnilTarget memory utilization in percent
commonAnnotationsobject{}Annotations added to every resource
commonLabelsobject{}Labels added to every resource
configobject{}INI settings as {Section: {key: value}}, passed as MATOMO_CONFIG__<Section>__<key>. They win over configuration. Lists become JSON arrays, booleans 1 and 0.
configPhpstring""PHP file with DI definitions, returning an array, mounted to /etc/matomo/config.php
configurationstring""INI file mounted to /etc/matomo/conf.d/values.ini
containerPorts.httpint8080HTTP port Caddy listens on, CADDY_HTTP_PORT
containerSecurityContext.allowPrivilegeEscalationboolfalseDisallow privilege escalation
containerSecurityContext.capabilitiesobject{"drop":["ALL"]}Linux capabilities
containerSecurityContext.enabledbooltrueEnable the container security context
containerSecurityContext.readOnlyRootFilesystembooltrueMount the root filesystem read-only. Only installing plugins from the Marketplace in the UI needs false, plugins.install works without.
containerSecurityContext.runAsGroupint82Group id to run as
containerSecurityContext.runAsNonRootbooltrueRun as a non-root user
containerSecurityContext.runAsUserint82User id to run as
customLivenessProbeobject{}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.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartmatomo is pinned at v0.2.9 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. 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