Plausible is a GDPR, CCPA and cookie law compliant Google Analytics alternative, that can help you analyse traffic on your web services. They offer a paid service but there is also the option to run a Self-Hosted installation. Unfortunately they don't offer an official Helm Chart (yet), but there are at least two actively maintained Helm charts available:

varac-projects / plausible-analytics-helm-chart · GitLab
Helm chart for Plausible Analytics. Based on the unmaintained chart https://github.com/8gears/plausible-analytics-helm-chart
GitHub - 8gears/plausible-analytics-helm-chart: A Plausible Analytics Helm Chart for Kubernetes
A Plausible Analytics Helm Chart for Kubernetes. Contribute to 8gears/plausible-analytics-helm-chart development by creating an account on GitHub.

The last time I tried the Helm chart from 8gears it just wouldn't work. So I'm using the varac-projects Helm chart. After a bit of trial and error I managed to get it working. While some of its values are not working it seems, It even supports Geolocation based on MaxMind. So let's get straight to it.

I use K3s on my VPS with MetalLB, ingress-nginx and Let's Encrypt. But my guide should also work just fine if you use Vanilla K8s.

First we add the Helm repo and run update:

helm repo add varac-plausible https://0xacab.org/api/v4/projects/3963/packages/helm/stable
helm repo update

Next we create a small YAML file. In my case I'm using Ingress and Let's Encrypt. You might want to adjust this for your environment. At least the URL and passwords.

cat > plausible.yml << EOF
disableAuth: false
disableRegistration: true
baseURL: https://analytics.roksblog.de
adminUser:
  email: admin@blasiblah.com
  name: admin
  password: strongPassW0rd
postgresql: # Postgres Database
  enabled: true
  # Sub-chart values, see https://artifacthub.io/packages/helm/bitnami/postgresql
  # The URL to the Postgres Database Connection String see -> https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING
  # Replace POSTGRES_PW with the auth.postgresPassword below !
  #url: postgres://postgres:blabla123@plausible-analytics-postgresql.plausible-analytics.svc.cluster.local:5432/postgres
  url: postgres://postgres:anotherStrongPass@plausible-analytics-postgresql.plausible-analytics.svc.cluster.local:5432/postgres
  auth:
    postgresPassword: anotherStrongPass
clickhouse:
    clickhouse:
      imageVersion: 23.3.5.9-alpine
    url: http://plausible-analytics-clickhouse:8123/plausible_events_db
ingress:
    annotations:
      cert-manager.io/cluster-issuer: letsencrypt-staging
      kubernetes.io/ingress.class: nginx
      nginx.ingress.kubernetes.io/proxy-body-size: 600m
      nginx.org/client-max-body-size: 600m
    enabled: true
    hosts:
    - host: analytics.roksblog.de
      paths:
      - /
    tls:
    - hosts:
      - analytics.roksblog.de
      secretName: analytics.roksblog.de
EOF

Now we can deploy using our YAML file

helm upgrade --install --create-namespace -n plausible-analytics plausible-analytics varac-plausible/plausible-analytics -f plausible.yml

After a few moments we should see our pods up and running

kubectl get pods -n plausible-analytics

Example

[localuser@node01 ~]$ kubectl get pods -n plausible-analytics
NAME                                       READY   STATUS    RESTARTS   AGE
plausible-analytics-postgresql-0           1/1     Running   0          24h
plausible-analytics-clickhouse-replica-0   1/1     Running   0          24h
plausible-analytics-clickhouse-0           1/1     Running   0          24h
plausible-analytics-7789cf5f55-s6mq8       1/1     Running   0          24h

Fore some reason the "disableRegistration" parameter doesn't work. So when we log in to plausible for the first time we need to set up an account.

After that we are asked which website we would like to analyze.

Next we need to copy the small code snippet. We need to inject this in our web application. For example in Ghost blog.

For this we open Settings in Ghost and navigate to Advanced -> Code Injection.

We simply paste the code snippet in the header section and click on save.

Plausible will now start collecting data.

In my opinion, a very useful tool. Not only does it give you a very good indication of how often a page is visited. You can also deduce which content on the page is often visited. And it also complies with the GDPR guidelines. :)