GUIDE · HELM CHART · POSTHOG-K8S

Self-host PostHog on Kubernetes, step by step

From zero to PostHog in your own cluster with the community Helm chart posthog-k8s. First locally on kind or k3s, then in production with your own PostgreSQL, S3 and Argo CD. Every command can be copied.

THE SHORTEST PATH
$ helm install posthog \
    oci://ghcr.io/enricofranke/charts/posthog \
    --namespace posthog --create-namespace \
    --set posthog.siteUrl=https://posthog.example.com

COMMUNITY PROJECT · NOT AFFILIATED WITH POSTHOG INC. · THE FULL VERSION LIVES IN THE README ↗

What you need

01
EVALUATIONPRODUCTION
Kubernetes1.30 or newer: kind, k3s, k0s or Docker Desktop1.30 or newer
Memoryabout 16 GB with the CI values, about 18 GB with the defaultsabout 18 GB of requests with the defaults, more under heavy traffic
Storagea default StorageClassfast disks for ClickHouse and Redpanda, about 160 GB by default
PostgreSQLbundled by the chart (15.12)external, version 15 or newer (CloudNativePG, RDS …)
Object storagebundled by the chart (SeaweedFS)an S3-compatible bucket
Toolskubectl, Helm 3.8 or newerthe same, plus your GitOps tool

Try it locally (kind or k3s)

02
  1. Create a cluster

    Give Docker (Desktop) at least 16 GB of memory first. k3s already ships a StorageClass with local-path.

    KIND OR K3S
    # kind
    $ kind create cluster --name posthog
    # or k3s on a Linux machine
    $ curl -sfL https://get.k3s.io | sh -
    $ export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
  2. Install the chart

    On a 16 GB machine, use the values from CI. They contain fixed, public test secrets, so use them on your own machine only.

    16 GB MACHINE
    $ helm install posthog oci://ghcr.io/enricofranke/charts/posthog \
        --namespace posthog --create-namespace \
        -f https://raw.githubusercontent.com/enricofranke/posthog-k8s/main/charts/posthog/ci/kind-values.yaml

    With more memory, use the defaults and let the chart generate the secrets:

    DEFAULTS
    $ helm install posthog oci://ghcr.io/enricofranke/charts/posthog \
        --namespace posthog --create-namespace \
        --set posthog.siteUrl=http://localhost:8080 \
        --set posthog.publicUrl=http://localhost:8081 \
        --set posthog.secureCookies=false
  3. Wait for the first start

    A fresh database runs about 1,500 PostgreSQL and 300 ClickHouse migrations, which takes 15 to 25 minutes on a laptop. Until then web and the workers sit in Init:0/1, waiting for the migrate job. That is expected.

    WATCH
    $ kubectl -n posthog get pods -w
    $ kubectl -n posthog logs -f job/$(kubectl -n posthog get jobs -o name | grep migrate | cut -d/ -f2)
  4. Open PostHog

    Forward both router listeners: 8080 is the UI, 8081 the entry point for the SDKs. Then continue with the first login.

    PORT-FORWARD
    $ kubectl -n posthog port-forward svc/posthog-router 8080:8080 8081:8081
    # UI: http://localhost:8080   Ingest: http://localhost:8081

Install for production

03

This is how we run it ourselves: CloudNativePG, S3, the UI behind an identity-aware proxy, SDK traffic on a public hostname, secrets from a secret manager, deployed with Argo CD. Every detail is in docs/production.md.

  1. Create the namespace

    ClickHouse, Redpanda and Temporal do not run under the restricted Pod Security level, so use baseline.

    NAMESPACE
    $ kubectl create namespace posthog
    $ kubectl label namespace posthog \
        pod-security.kubernetes.io/enforce=baseline \
        pod-security.kubernetes.io/warn=restricted
  2. Provide PostgreSQL 15 or newer

    With CloudNativePG you create the cluster and the two databases Temporal needs. CNPG then generates the secret posthog-pg-app, which the chart reads directly.

    CLOUDNATIVEPG
    apiVersion: postgresql.cnpg.io/v1
    kind: Cluster
    metadata: {name: posthog-pg, namespace: posthog}
    spec:
      instances: 3
      imageName: ghcr.io/cloudnative-pg/postgresql:17.6
      postgresql:
        parameters: {max_connections: "400"}
      bootstrap:
        initdb: {database: posthog, owner: app}
      storage: {size: 30Gi}
    ---
    apiVersion: postgresql.cnpg.io/v1
    kind: Database
    metadata: {name: posthog-pg-temporal, namespace: posthog}
    spec: {name: temporal, owner: app, cluster: {name: posthog-pg}}
    ---
    apiVersion: postgresql.cnpg.io/v1
    kind: Database
    metadata: {name: posthog-pg-temporal-visibility, namespace: posthog}
    spec: {name: temporal_visibility, owner: app, cluster: {name: posthog-pg}}
  3. Create the S3 bucket

    One bucket and one IAM user restricted to it. Session replays, exports, symbol sets and AI data go there. Budget roughly 1 GB per 200 recordings. The minimal IAM policy is in docs/production.md.

  4. Create the secrets

    In production you sync them from your secret manager (External Secrets, Sealed Secrets, SOPS). For a first try the same works with kubectl:

    SECRETS
    $ kubectl -n posthog create secret generic posthog-app \
        --from-literal=SECRET_KEY="$(openssl rand -hex 32)" \
        --from-literal=ENCRYPTION_SALT_KEYS="$(openssl rand -hex 16)" \
        --from-literal=BROWSERLESS_TOKEN="$(openssl rand -hex 32)" \
        --from-literal=INTERNAL_API_SECRET="$(openssl rand -hex 32)" \
        --from-literal=INTERNAL_REQUEST_TOKEN="$(openssl rand -hex 32)" \
        --from-literal=RECORDING_API_JWT_SECRET="$(openssl rand -hex 32)"
    $ kubectl -n posthog create secret generic posthog-clickhouse \
        --from-literal=CLICKHOUSE_API_PASSWORD="$(openssl rand -hex 24)" \
        --from-literal=CLICKHOUSE_APP_PASSWORD="$(openssl rand -hex 24)" \
        --from-literal=CLICKHOUSE_BILLING_PASSWORD="$(openssl rand -hex 24)" \
        --from-literal=CLICKHOUSE_DICT_READER_PASSWORD="$(openssl rand -hex 24)" \
        --from-literal=CLICKHOUSE_SIGNALS_PASSWORD="$(openssl rand -hex 24)"
    $ kubectl -n posthog create secret generic posthog-s3 \
        --from-literal=accessKeyId=AKIA... --from-literal=secretAccessKey=...
    IMPORTANTENCRYPTION_SALT_KEYS (32 hex characters) must never change once data exists. Back the value up together with your PostgreSQL backups.
  5. Write values.yaml

    A complete values.yaml for this setup. Adjust the hostnames, bucket and StorageClass.

    VALUES.YAML
    posthog:
      siteUrl: https://posthog.example.com     # UI, behind an SSO proxy
      publicUrl: https://ph.example.com        # where SDKs send events
      existingSecret: posthog-app
      multiOrg: true
    secrets:
      keys:
        CLICKHOUSE_API_PASSWORD: {secret: posthog-clickhouse}
        CLICKHOUSE_APP_PASSWORD: {secret: posthog-clickhouse}
        CLICKHOUSE_BILLING_PASSWORD: {secret: posthog-clickhouse}
        CLICKHOUSE_DICT_READER_PASSWORD: {secret: posthog-clickhouse}
        CLICKHOUSE_SIGNALS_PASSWORD: {secret: posthog-clickhouse}
    postgresql:
      bundled: false
      external:
        host: posthog-pg-rw                    # CloudNativePG service
        username: app
        database: posthog
        existingSecret: posthog-pg-app
        urlKey: uri
        passwordKey: password
    temporal:
      skipDbCreate: true                       # Temporal databases from above
    objectStorage:
      endpoint: https://s3.eu-central-1.amazonaws.com
      bucket: my-posthog
      region: eu-central-1
      forcePathStyle: false                    # true for MinIO, SeaweedFS, Ceph
      existingSecret: posthog-s3
      bundled: {enabled: false}
    services:
      clickhouse:
        persistence: {size: 200Gi, storageClass: fast-ssd}
      kafka:
        persistence: {size: 50Gi, storageClass: fast-ssd}
    router:
      ingress:
        enabled: true
        className: nginx
        hosts:
          - {host: ph.example.com, listener: ingest}   # public, SDK paths only
    networkPolicy:
      enabled: true
      ingestIngressFrom:
        - namespaceSelector: {matchLabels: {kubernetes.io/metadata.name: ingress-nginx}}
      appIngressFrom:
        - namespaceSelector: {matchLabels: {kubernetes.io/metadata.name: teleport}}
  6. Set up two hostnames

    • posthog.example.com → posthog-router:8080, UI and API. Reachable only through your identity-aware proxy (Teleport, oauth2-proxy, Pomerium, Authelia, Cloudflare Access) or a private ingress.
    • ph.example.com → posthog-router:8081, the SDK entry point. Public. Anything that is not an SDK path gets a 404.

    A tunnel works instead of an ingress, for example Cloudflare Tunnel: point it at http://posthog-router.posthog.svc:8081 and leave router.ingress.enabled at false. Backends in the same cluster send their events there directly.

  7. Install

    In production, pin a chart version with --version. Current versions are listed under GitHub Releases.

    HELM
    $ helm install posthog oci://ghcr.io/enricofranke/charts/posthog \
        --namespace posthog --version <version> -f values.yaml

    With Argo CD, use the Application from docs/argocd.md, with ServerSideApply=true and every secret external. Argo CD renders without lookup, so secrets generated by the chart would change on every sync.

  8. Before going live

    • point-in-time recovery for PostgreSQL, with one restore actually tested
    • a scheduled ClickHouse backup (BACKUP DATABASE posthog TO File('/var/lib/clickhouse/backups/<date>'), then copied to S3)
    • versioning or replication on the bucket
    • alerts on Kafka lag, ClickHouse disk, router 5xx and pod restarts
    • first user created, two-factor login for admins

First login and a test event

04
  1. Create the first user

    Open the UI (posthog.siteUrl, locally http://localhost:8080) and sign up. The first user becomes the owner of the first organization; signup closes automatically afterwards. Invite everyone else from the UI.

  2. Copy the project API key

    Under Settings → Project → Project API key you find the key that starts with phc_.

  3. Send an event

    TEST EVENT
    $ TOKEN=phc_...
    $ curl -X POST http://localhost:8081/e/ -H 'Content-Type: application/json' \
        -d "{\"api_key\":\"$TOKEN\",\"event\":\"hello\",\"distinct_id\":\"me\"}"

    In production, replace http://localhost:8081 with your publicUrl. The event shows up under Activity within seconds.

  4. Add the snippet

    Put the JavaScript snippet from Settings → Project on your site, with api_host set to your publicUrl.

Upgrading

05
  1. Read the changelog

    Read the CHANGELOG entry of every version you skip, in particular its Upgrade notes.

  2. Back up

    PostgreSQL via PITR or a dump, ClickHouse via BACKUP DATABASE posthog TO File('/var/lib/clickhouse/backups/<name>'). helm rollback rolls back the pods, not the database schema.

  3. Run the upgrade

    HELM UPGRADE
    $ helm upgrade posthog oci://ghcr.io/enricofranke/charts/posthog \
        --namespace posthog --version <new version> -f values.yaml
    $ kubectl -n posthog get pods -w

    With Argo CD, bump targetRevision.

0.1.X → 0.2.0Chart 0.2.0 moves PostHog from its 2026-09-11 state to its 2026-11-03 state. Before upgrading: check that PostgreSQL is 15 or newer. Back up ClickHouse, because it moves from 26.6 to 26.9 and there is no way back afterwards. Create the new secrets INTERNAL_REQUEST_TOKEN, RECORDING_API_JWT_SECRET and CLICKHOUSE_SIGNALS_PASSWORD. An empty raw_sessions_v3 in the old shape is rebuilt by the migrate job on its own; if the table holds rows, the job stops and prints the manual steps. Read the note on the $ai_* events. Terminate Temporal workflows that were started on the old queues before the upgrade. All the details are in the 0.2.0 upgrade notes in the CHANGELOG.

Uninstalling

06

helm uninstall removes the workloads. The volumes of ClickHouse, Redpanda, Zookeeper and Redis stay until you delete them yourself. External PostgreSQL databases and the S3 bucket are not touched.

PersistentVolumes with the Retain policy keep their data on the node until you remove them.

CLEAN UP
$ helm uninstall posthog --namespace posthog
$ kubectl -n posthog get pvc
# only if the data should really go:
$ kubectl -n posthog delete pvc --all
$ kubectl delete namespace posthog

Troubleshooting

07
web and the workers stay in Init:0/1

The migrate job is still running, which takes 15 to 25 minutes on a fresh database, or it is waiting for ClickHouse and PostgreSQL. Follow its logs with the command from “Wait for the first start”.

The wait-for-migrations init container is OOMKilled

Since PostHog moved to Django 6.1, migrate --check needs more than 1 GiB. Chart 0.2.0 gives it 2 GiB, and migrations.waitResources raises it further.

Replay Vision, session summaries or video exports never run

Before 0.2.0 the only Temporal worker polled a single queue, while PostHog schedules these workflows on queues of their own. Since 0.2.0 one worker polls all of them and PostHog's search attributes are registered. Workflows started before the upgrade stay where they are: terminate them with the Temporal CLI.

Replay Vision analyses with Gemini only and needs REPLAY_VISION_GEMINI_API_KEY. Self-hosted organizations are capped by REPLAY_VISION_MONTHLY_CREDIT_QUOTA.

Exceptions arrive, but no issue appears

cymbal cannot reach the bucket. Look for NoSuchBucket in the cymbal-resolution logs.

The ingest listener returns 404

By design for anything that is not an SDK path. Add extra paths to router.ingest.webPaths.

Where do I find more?

In docs/troubleshooting.md, with the commands to look things up. e2e/diagnose.sh <namespace> prints exit reasons, previous logs and events in one go.

Up and running?

The project page explains how the chart is built and what is not in it (yet). Questions, bugs and verified setups belong in the GitHub issues.

posthog-k8s is a community project, not affiliated with or endorsed by PostHog Inc. "PostHog" is a trademark of PostHog Inc. The chart is Apache-2.0 licensed and uses PostHog's public images unmodified.