简体   繁体   English

在 kubernetes 集群中部署 sentry helm

[英]Deploy sentry helm in kubernetes cluster

I have deployed sentry on kubernetes last week, using this helm chart stable/sentry .我上周在 kubernetes 上部署了哨兵,使用了这个 helm chart stable/sentry

Pods work fine but i cannot access to the website, it crash every time I access to the endpoint. Pod 工作正常,但我无法访问该网站,每次访问端点时它都会崩溃。

I checked logs of the worker, sentry-web and postgres pods and see this.我检查了 worker、sentry-web 和 postgres pod 的日志并看到了这一点。

This is logs of the website pod:这是网站 pod 的日志:

    self._result_cache = list(self.iterator())
  File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py", line 220, in iterator
    for row in compiler.results_iter():
  File "/usr/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 713, in results_iter
    for rows in self.execute_sql(MULTI):
  File "/usr/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 786, in execute_sql
    cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/site-packages/sentry_sdk/integrations/django/__init__.py", line 396, in execute
    return real_execute(self, sql, params)
  File "/usr/local/lib/python2.7/site-packages/django/db/backends/util.py", line 53, in execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/site-packages/django/db/utils.py", line 99, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/usr/local/lib/python2.7/site-packages/django/db/backends/util.py", line 53, in execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/site-packages/sentry/db/postgres/decorators.py", line 80, in inner
    raise_the_exception(self.db, e)
  File "/usr/local/lib/python2.7/site-packages/sentry/db/postgres/decorators.py", line 78, in inner
    return func(self, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/sentry/db/postgres/decorators.py", line 22, in inner
    return func(self, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/sentry/db/postgres/decorators.py", line 101, in inner
    six.reraise(exc_info[0], exc_info[0](msg), exc_info[2])
  File "/usr/local/lib/python2.7/site-packages/sentry/db/postgres/decorators.py", line 94, in inner
    return func(self, sql, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/sentry/db/postgres/base.py", line 74, in execute
    return self.cursor.execute(sql, clean_bad_params(params))
django.db.utils.ProgrammingError: ProgrammingError('relation "sentry_projectkey" does not exist\nLINE 1: ...te_limit_window", "sentry_projectkey"."data" FROM "sentry_pr...\n                                                             ^\n',)
SQL: SELECT "sentry_projectkey"."id", "sentry_projectkey"."project_id", "sentry_projectkey"."label", "sentry_projectkey"."public_key", "sentry_projectkey"."secret_key", "sentry_projectkey"."roles", "sentry_projectkey"."status", "sentry_projectkey"."date_added", "sentry_projectkey"."rate_limit_count", "sentry_projectkey"."rate_limit_window", "sentry_projectkey"."data" FROM "sentry_projectkey" WHERE ("sentry_projectkey"."project_id" = %s  AND "sentry_projectkey"."roles" =  "sentry_projectkey"."roles" | 1) LIMIT 1

And this is logs of the postgres pod:这是 postgres pod 的日志:

ERROR:  relation "sentry_option" does not exist at character 114
STATEMENT:  SELECT "sentry_option"."id", "sentry_option"."key", "sentry_option"."value", "sentry_option"."last_updated" FROM "sentry_option" WHERE "sentry_option"."last_updated" >= '2019-09-13 14:02:49.793126+00:00' 
ERROR:  relation "sentry_monitor" does not exist at character 328
STATEMENT:  SELECT "sentry_monitor"."id", "sentry_monitor"."guid", "sentry_monitor"."organization_id", "sentry_monitor"."project_id", "sentry_monitor"."name", "sentry_monitor"."status", "sentry_monitor"."type", "sentry_monitor"."config", "sentry_monitor"."next_checkin", "sentry_monitor"."last_checkin", "sentry_monitor"."date_added" FROM "sentry_monitor" WHERE ("sentry_monitor"."next_checkin" < '2019-09-13 15:02:50.996171+00:00'  AND "sentry_monitor"."type" IN (2, 3) AND NOT ("sentry_monitor"."status" IN (1, 2, 3))) LIMIT 10000
ERROR:  relation "sentry_scheduledjob" does not exist at character 179
STATEMENT:  SELECT "sentry_scheduledjob"."id", "sentry_scheduledjob"."name", "sentry_scheduledjob"."payload", "sentry_scheduledjob"."date_added", "sentry_scheduledjob"."date_scheduled" FROM "sentry_scheduledjob" WHERE "sentry_scheduledjob"."date_scheduled" <= '2019-09-13 15:02:51.984402+00:00'  LIMIT 101
ERROR:  relation "sentry_authidentity" does not exist at character 288
STATEMENT:  SELECT "sentry_authidentity"."id", "sentry_authidentity"."user_id", "sentry_authidentity"."auth_provider_id", "sentry_authidentity"."ident", "sentry_authidentity"."data", "sentry_authidentity"."last_verified", "sentry_authidentity"."last_synced", "sentry_authidentity"."date_added" FROM "sentry_authidentity" WHERE "sentry_authidentity"."last_synced" <= '2019-09-13 14:02:56.685172+00:00' 

And the worker pods:和工作人员舱:

    result = func(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/sentry/tasks/options.py", line 36, in sync_options
    for option in Option.objects.filter(last_updated__gte=cutoff_dt).iterator():
  File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py", line 220, in iterator
    for row in compiler.results_iter():
  File "/usr/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 713, in results_iter
    for rows in self.execute_sql(MULTI):
  File "/usr/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 786, in execute_sql
    cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/site-packages/sentry_sdk/integrations/django/__init__.py", line 396, in execute
    return real_execute(self, sql, params)
  File "/usr/local/lib/python2.7/site-packages/django/db/backends/util.py", line 53, in execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/site-packages/django/db/utils.py", line 99, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/usr/local/lib/python2.7/site-packages/django/db/backends/util.py", line 53, in execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/site-packages/sentry/db/postgres/decorators.py", line 80, in inner
    raise_the_exception(self.db, e)
  File "/usr/local/lib/python2.7/site-packages/sentry/db/postgres/decorators.py", line 78, in inner
    return func(self, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/sentry/db/postgres/decorators.py", line 22, in inner
    return func(self, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/sentry/db/postgres/decorators.py", line 101, in inner
    six.reraise(exc_info[0], exc_info[0](msg), exc_info[2])
  File "/usr/local/lib/python2.7/site-packages/sentry/db/postgres/decorators.py", line 94, in inner
    return func(self, sql, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/sentry/db/postgres/base.py", line 74, in execute
    return self.cursor.execute(sql, clean_bad_params(params))
ProgrammingError: ProgrammingError('relation "sentry_option" does not exist\nLINE 1: ...ion"."value", "sentry_option"."last_updated" FROM "sentry_op...\n                                                             ^\n',)
SQL: SELECT "sentry_option"."id", "sentry_option"."key", "sentry_option"."value", "sentry_option"."last_updated" FROM "sentry_option" WHERE "sentry_option"."last_updated" >= %s 
15:09:24 [ERROR] celery.worker.job: Task sentry.tasks.options.sync_options[e1684c22-6593-48d9-94c7-2c47ee7fc397] raised unexpected: ProgrammingError(u'ProgrammingError(\'relation "sentry_option" does not exist\\nLINE 1: ...ion"."value", "sentry_option"."last_updated" FROM "sentry_op...\\n                                                             ^\\n\',)\nSQL: SELECT "sentry_option"."id", "sentry_option"."key", "sentry_option"."value", "sentry_option"."last_updated" FROM "sentry_option" WHERE "sentry_option"."last_updated" >= %s ',) (data={u'hostname': 'celery@teq-sentry-worker-6ddfb9658c-gbkth', u'name': 'sentry.tasks.options.sync_options', u'args': '[]', u'internal': False, u'kwargs': '{}', u'id': 'e1684c22-6593-48d9-94c7-2c47ee7fc397'})

您必须手动迁移架构,运行以下命令来迁移架构:

kubectl exec -it <your-pod-name> sentry upgrade

Solve.解决。 Thank you everyone for your help.感谢大家的帮助。 The problem is I'm not have enough RAM in order to run the migration script, so I upgrade the VPS to 8GB RAM and then it's work.问题是我没有足够的 RAM 来运行迁移脚本,所以我将 VPS 升级到 8GB RAM,然后它就可以工作了。

Because the migration script have some memory leak so pods need at least 4GB free memory to run.由于迁移脚本存在内存泄漏,因此 Pod 至少需要 4GB 可用内存才能运行。 See this comment on Github在 Github 上查看此评论

Faced a similar issue.遇到了类似的问题。 In our case, we have enabled ingress (Nginx).在我们的例子中,我们启用了入口(Nginx)。 And this setting conflict with service.type: LoadBalancer , just change it to ClusterIP and do the clear setup again.而且这个设置与 service.type: LoadBalancer冲突,只需将其更改为ClusterIP并再次进行清除设置。

TLDR - DB init starts on "post-install" event (all deployed components is in a ready state) but in case of LoadBallancer, ingress and --wait combination the web Service must have assigned IP ( https://github.com/helm/helm/blob/master/docs/using_helm.md#helpful-options-for-installupgraderollback ). TLDR - DB init 从“安装后”事件开始(所有部署的组件都处于就绪状态),但在 LoadBalancer、ingress 和--wait组合的情况下,Web 服务必须已分配 IP( https://github.com/ helm/helm/blob/master/docs/using_helm.md#helpful-options-for-installupgraderollback )。 For some reason it wasn't true and web service always returns false .出于某种原因,它不是 true 并且 Web 服务总是返回false After change the service setting from LoadBalancer to ClusterIP the issue is gone.将服务设置从LoadBalancer更改为ClusterIP ,问题就消失了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM