惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
大猫的无限游戏
大猫的无限游戏
B
Blog
阮一峰的网络日志
阮一峰的网络日志
IT之家
IT之家
Hugging Face - Blog
Hugging Face - Blog
博客园 - 【当耐特】
Jina AI
Jina AI
博客园 - 聂微东
T
The Blog of Author Tim Ferriss
宝玉的分享
宝玉的分享
L
LangChain Blog
M
MIT News - Artificial intelligence
Blog — PlanetScale
Blog — PlanetScale
腾讯CDC
酷 壳 – CoolShell
酷 壳 – CoolShell
Y
Y Combinator Blog
F
Fortinet All Blogs
H
Help Net Security
B
Blog RSS Feed
J
Java Code Geeks
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Apple Machine Learning Research
Apple Machine Learning Research
S
SegmentFault 最新的问题

Oskyla 烹茶室

修复 Joplin on KDE 菜单栏显示问题 Copy Fail:Linux 内核 2017 年至今的高危漏洞(附临时缓解方案) | CVE-2026-31431 Hermes Agent — 在 K3s / K8s 中运行指南 在 K3s 节点上安装并使用 nerdctl Mouser:轻量开源的罗技鼠标驱动替代方案 Claude Opus 4.7:优缺点与评测信息汇总 openFuyao NPU-Operator故障排查 openFuyao 2603 共测测试报告 openFuyao InferNex AI推理集成部署 310P(300I Pro) 环境问题记录及解决 ceph mon Operation not permitted 问题解决 Ascend 310P + openFuyao + NPU-Operator 故障排查 KDE Plasma6 禁用全局菜单,恢复正常应用菜单 终极指南:在 Linux 裸机服务器上快速部署 Moltbot (原 Clawbot) 并集成飞书 Windows 配置 Claude Code 解决 settings.json 不生效 Windows 配置 Claude Code 全流程 2025-12-31 | 年终总结 AI 生图精品提示词|第二期:城市星球 AI 生图精品提示词|第一期 Kubernetes kubectl --raw 使用指南 彻底解决阿里云和 tailscale 冲突 2025-10-21 | 沉淀思维 macOS 单独为鼠标或触控板开启自然滚动 2025-10-16 | 负载高低 2025-10-15 | 睡眠周期 2025-10-14 | 转换情绪与独立观点 go 拉取 gitcode.com 私有 mod Git 将某个文件恢复到其他分支的状态 SSH 通过跳板机连接 lxc 使用 chronyc 构建 ntp 服务 2025-10-13 | 独立思考于未来能源
k8s 使用官方 compose 部署 plausible
Tianlun Song · 2024-11-11 · via Oskyla 烹茶室

本文 首发于 🌱 煎茶转载 请注明 来源

主要记录使用 kompose 转换部署 compose 程序的思路,具体过程根据情况调整。

首先获取官方 compose 配置:

git clone -b v2.1.4 --single-branch https://github.com/plausible/community-edition plausible-ce
cd plausible-ce

调整配置

之后根据需要定制配置文件:

$ touch .env
$ echo "BASE_URL=https://plausible.example.com" >> .env
$ echo "SECRET_KEY_BASE=$(openssl rand -base64 48)" >> .env

# 服务暴露根据需要配置
# 这里采用反代的方法
$ echo "HTTP_PORT=8000" >> .env

之后定制一下 compose.yaml,其中有一些不合理的地方,直接使用 kompose 转换会出问题:

diff --git a/compose.yml b/compose.yml
index 2fe91e5..dd42713 100644
--- a/compose.yml
+++ b/compose.yml
@@ -1,16 +1,18 @@
 services:
-  plausible_db:
+  plausible-db:
     image: postgres:16-alpine
     restart: always
     volumes:
       - db-data:/var/lib/postgresql/data
     environment:
       - POSTGRES_PASSWORD=postgres
+    ports:
+      - 5432:5432
     healthcheck:
       test: ["CMD-SHELL", "pg_isready -U postgres"]
       start_period: 1m
 
-  plausible_events_db:
+  plausible-events-db:
     image: clickhouse/clickhouse-server:24.3.3.102-alpine
     restart: always
     volumes:
@@ -24,6 +26,8 @@ services:
       nofile:
         soft: 262144
         hard: 262144
+    ports:
+      - 5432:5432
     healthcheck:
       test: ["CMD-SHELL", "wget --no-verbose --tries=1 -O - http://127.0.0.1:8123/ping || exit 1"]
       start_period: 1m
@@ -33,9 +37,9 @@ services:
     restart: always
     command: sh -c "/entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh run"
     depends_on:
-      plausible_db:
+      plausible-db:
         condition: service_healthy
-      plausible_events_db:
+      plausible-events-db:
         condition: service_healthy
     volumes:
       - plausible-data:/var/lib/plausible
@@ -43,6 +47,9 @@ services:
       nofile:
         soft: 65535
         hard: 65535
+    env_file: ".env"
+    ports:
+      - 8000:8000
     environment:
       - TMPDIR=/var/lib/plausible/tmp
       # required: https://github.com/plausible/community-edition/wiki/configuration#required
@@ -54,28 +61,28 @@ services:
       - DISABLE_REGISTRATION
       - ENABLE_EMAIL_VERIFICATION
       # web: https://github.com/plausible/community-edition/wiki/configuration#web
-      - HTTP_PORT
+      - HTTP_PORT=8000
       - HTTPS_PORT
       # databases: https://github.com/plausible/community-edition/wiki/configuration#database
-      - DATABASE_URL
-      - CLICKHOUSE_DATABASE_URL
+      - DATABASE_URL=postgres://postgres:postgres@plausible_db:5432/plausible_db
+      - CLICKHOUSE_DATABASE_URL=http://plausible_events_db:8123/plausible_events_db

之后需要对 clickhouse 做一些配置,暂时解决 Application: Disabling cgroup memory observer because of an error during initialization: Code: 107. DB::Exception: Cannot find cgroups v1 or v2 current memory file 问题:

diff --git a/clickhouse/ipv4-only.xml b/clickhouse/ipv4-only.xml
index 7eb0a5c..4c8222d 100644
--- a/clickhouse/ipv4-only.xml
+++ b/clickhouse/ipv4-only.xml
@@ -1,3 +1,4 @@
 <clickhouse>
     <listen_host>0.0.0.0</listen_host>
+    <cgroups_memory_usage_observer_wait_time>0</cgroups_memory_usage_observer_wait_time>
 </clickhouse>

转换资源清单

一切就绪后转换:

kompose convert -f compose.yaml  --controller statefulset -o plausible.yaml

检查一下文件,不喜欢的可以再调整,比如条整 pvc 大小。

最后使用 ingress 暴露:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-plausible
  namespace: plausible
  annotations:
    cert-manager.io/cluster-issuer: issuer01
spec:
  ingressClassName: nginx
  rules:
  - host: example.com
    http:
      paths:
      - backend:
          service:
            name: plausible
            port:
              number: 8000
        path: /
        pathType: Prefix
  tls:
  - hosts:
      - example.com
    secretName: plausible-example-com-tls

检查 pod 状态,检查服务状态,最后访问,结束。

问题解决

pv 权限问题

如果出现这个故障:

Attaching to plausible
plausible  | Loading plausible..
plausible  | Starting dependencies..
plausible  | Starting repos..
plausible  | Plausible.Repo database already exists
plausible  | Plausible.IngestRepo database already exists
plausible  | Creation of Db successful!
plausible  | Loading plausible..
plausible  | Starting dependencies..
plausible  | Starting repos..
plausible  | Runtime terminating during boot (terminating)
plausible  | 09:55:19.599 [notice] Application tzdata exited: exited in: Tzdata.App.start(:normal, [])
plausible  |     ** (EXIT) an exception was raised:
plausible  |         ** (MatchError) no match of right hand side value: {:error, {:shutdown, {:failed_to_start_child, Tzdata.EtsHolder, {%File.Error{reason: :enoent, path: "/var/lib/plausible/tzdata_data/release_ets", action: "list directory"}, [{File, :ls!, 1, [file: ~c"lib/file.ex", line: 1700]}, {Tzdata.EtsHolder, :release_files_for_dir, 1, [file: ~c"lib/tzdata/ets_holder.ex", line: 127]}, {Tzdata.EtsHolder, :make_sure_a_release_is_on_file, 0, [file: ~c"lib/tzdata/ets_holder.ex", line: 90]}, {Tzdata.EtsHolder, :init, 1, [file: ~c"lib/tzdata/ets_holder.ex", line: 16]}, {:gen_server, :init_it, 2, [file: ~c"gen_server.erl", line: 2057]}, {:gen_server, :init_it, 6, [file: ~c"gen_server.erl", line: 2012]}, {:proc_lib, :init_p_do_apply, 3, [file: ~c"proc_lib.erl", line: 329]}]}}}}
plausible  |             (tzdata 1.1.2) lib/tzdata/tzdata_app.ex:13: Tzdata.App.start/2
plausible  |             (kernel 10.0) application_master.erl:295: :application_master.start_it_old/4
plausible  |
plausible exited with code 1

找到 pv 位置执行:

chown -R 999:nogroup /mnt/hdd-mirror/docker/plausible/data/

之后重启 plausible pod 即可。

References

#Kubernetes