在 Kubernetes 集群中部署 Sentry 错误监控系统。官方没有提供 K8s 部署文档,但我们可以使用社区的 Helm Chart 。
版本信息
App Version: 24.5.0
Chart Version: 23.1.0
核心配置 values.yaml 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 filestore: backend: filesystem filesystem: path: /var/lib/sentry/files persistence: accessMode: ReadWriteMany enabled: true persistentWorkers: true size: 10Gi storageClass: "efs" nginx: ingress: enabled: true hostname: sentry.company.com ingressClassName: "alb" path: / pathType: Prefix postgresql: postgresqlPassword: "examplePassword" postgresqlPostgresPassword: "examplePassword" sourcemaps: enabled: true user: create: true email: [email protected] password: examplePassword zookeeper: autopurge: purgeInterval: 3 snapRetainCount: 3
配置说明
配置项
说明
注意事项
filestore
文件存储
必须使用 ReadWriteMany 存储类
postgresql
数据库密码
防止启动报错,详见 issue
nginx.ingress
入口配置
根据实际 Ingress Controller 调整
zookeeper.autopurge
自动清理
避免数据过大
ClickHouse 报错修复 问题现象 部署后 sentry-clickhouse
Pod 一直处于 CrashLoopBackOff
状态:
1 2 snuba.clickhouse.errors.ClickhouseWriterError: Method write is not supported by storage Distributed with more than one shard and no sharding key provided
原因分析 分布式表 metrics_raw_v2_dist
缺少 sharding key 配置。相关 issue:
解决步骤 进入 ClickHouse 容器重建表:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 kubectl exec -it sentry-clickhouse-0 -- bash clickhouse-client -h sentry-clickhouse DROP TABLE default.metrics_raw_v2_dist ON CLUSTER 'sentry-clickhouse' SYNC; CREATE TABLE default.metrics_raw_v2_dist ON CLUSTER 'sentry-clickhouse' ( `use_case_id` LowCardinality(String), `org_id` UInt64, `project_id` UInt64, `metric_id` UInt64, `timestamp` DateTime, `tags.key` Array(UInt64), `tags.value` Array(UInt64), `metric_type` LowCardinality(String), `set_values` Array(UInt64), `count_value` Float64, `distribution_values` Array(Float64), `materialization_version` UInt8, `retention_days` UInt16, `partition` UInt16, `offset` UInt64, `timeseries_id` UInt32 ) ENGINE = Distributed('sentry-clickhouse' , 'default' , 'metrics_raw_v2_local' , sipHash64('timeseries_id' )); -- 关键:添加 sharding key
执行后 Pod 会恢复正常。
替代方案 如果 Sentry 过于复杂,可以考虑 GlitchTip - 一个轻量级的 Sentry 替代品。
注意事项
存储类必须支持 ReadWriteMany (如 EFS、NFS)
PostgreSQL 密码务必提前配置,否则可能导致初始化失败
ClickHouse 问题需要手动修复,Chart 未自动处理