[Kubernetes (K8S)] Helm install Sentry 9.x to collect and aggregate crash reporting within Kubernetes (K8S)

Sentry

Sentry is a service that helps you monitor and fix crashes in realtime. The server is in Python, but it contains a full API for sending events from any language, in any application.

This article is about how to use Helm to install Sentry 9.x on Kubernetes (K8S).

Prerequisites

  • Kubernetes (K8S)
    Kubernetes (K8s) is an open-source system for automating deployment, scaling, and management of containerized applications.

    For more information about installing and using Kubernetes (K8s), see the Kubernetes (K8s) Docs.

  • Helm
    Helm is the best way to find, share, and use software built for Kubernetes.

    For more information about installing and using Helm, see the Helm Docs.


As of Nov 13, 2020, charts in this repo will no longer be updated. For more information, see the Helm Charts Deprecation and Archive Notice, and Update.


You can use Azure Helm mirror - http://mirror.azure.cn/kubernetes/charts/ to replace https://kubernetes-charts.storage.googleapis.com

How to Install

Helm install sentry into sentry namespace.

1
2
3
4
5
6
7
8
9
10
11
12
# crate namespace:
$ kubectl create namespace sentry

# Add the Stable Helm repository:
$ helm repo add stable http://mirror.azure.cn/kubernetes/charts/
# (Deprecation) $ helm repo add stable https://kubernetes-charts.storage.googleapis.com

# Update your local Helm chart repository cache:
$ helm repo update

# To install Helm chart:
$ helm install sentry stable/sentry -n sentry -f values.yaml

See Helm release about sentry

1
2
3
$ helm list --namespace sentry
NAME NAMESPACE REVISION UPDATED STATUS CHART
sentry sentry 1 2021-01-23 11:19:51.65893 +0800 +0800 deployed sentry-v9.1.2 v4.4.3

See pods about sentry.

1
2
3
4
5
6
7
8
9
10
11
$ kubectl get pods -n sentry 
NAME READY STATUS RESTARTS AGE
sentry-cron-6c46dd9547-nzxbq 1/1 Running 0 36m
sentry-metrics-5ccd67487f-59j64 1/1 Running 0 36m
sentry-sentry-postgresql-0 1/1 Running 0 36m
sentry-sentry-redis-master-0 1/1 Running 0 36m
sentry-sentry-redis-slave-0 1/1 Running 0 36m
sentry-sentry-redis-slave-1 1/1 Running 0 15m
sentry-web-5864cddf47-mmql9 1/1 Pending 0 36m
sentry-worker-cf5967658-7zfs7 1/1 Running 0 11m
sentry-worker-cf5967658-bmq9d 1/1 Running 0 11m

Custom values.yaml

Remember to replace content within {{ }} with your prefer value.

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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# charts/values.yaml at master · helm/charts
# https://github.com/helm/charts/blob/master/stable/sentry/values.yaml

# Admin user to create
user:
# Indicated to create the admin user or not,
# Default is true as the initial installation.
create: true
email: {{ .Values.user.email }}
password: {{ .Values.user.password }}

# Name of the service and what port to expose on the pod
# Don't change these unless you know what you're doing
service:
type: ClusterIP

# Configure the location of Sentry artifacts
filestore:

filesystem:

## Enable persistence using Persistent Volume Claims
## ref: http://kubernetes.io/docs/user-guide/persistent-volumes/
##
persistence:
# enabled: true
# database data Persistent Volume Storage Class
# If defined, storageClassName: <storageClass>
# If set to "-", storageClassName: "", which disables dynamic provisioning
# If undefined (the default) or set to null, no storageClassName spec is
# set, choosing the default provisioner. (gp2 on AWS, standard on
# GKE, AWS & OpenStack)
#
storageClass: {{ .Values.filestore.filesystem.persistence.storageClass }}


## Configure ingress resource that allow you to access the
## Sentry installation. Set up the URL
## ref: http://kubernetes.io/docs/user-guide/ingress/
##
ingress:
enabled: true
annotations:
kubernetes.io/ingress.class: "nginx"
# kubernetes.io/tls-acme: "true"

certmanager.k8s.io/acme-challenge-type: http01
certmanager.k8s.io/cluster-issuer: {{ .Values.clusterIssuer }}
# cert-manager.io/acme-challenge-type: dns01
# cert-manager.io/cluster-issuer: cert-manager-webhook-dnspod-cluster-issuer

hostname: {{ .Values.ingress.hostname }}

tls:
- secretName: {{ .Values.ingress.secretName }}
hosts:
- {{ .Values.ingress.hostname }}

postgresql:
password: {{ .Values.postgresql.password }}
postgresqlPassword: {{ .Values.postgresql.password }}

redis:
password: {{ .Values.redis.password }}

## Prometheus Exporter / Metrics
##
metrics:
enabled: true

Web UI

Then, you can visit https://{{ .Values.ingress.hostname }} to access Sentry Web UI.

FAQS

502 Bad Gateway

Sentry may fail to initialize or upgrade database since it will take too long. You can do it yoursef.

First, enter into Pod sentry-web bash.

1
$ kubectl exec -n sentry `kubectl get pods -n sentry | grep sentry-web | awk '{print $2}'` -it -- bash

Then, run sentry upgrade within container to run all migrations and create an admin account.

1
$ sentry upgrade

Finally, you can visit Web UI without any error.

Update PostgreSQL database password

Sentry can’t update PostgreSQL database password automatic when you change password. You can do it yoursef too.

First, enter into Pod sentry-postgresql bash.

1
$ kubectl exec -n sentry `kubectl get pods -n sentry | grep sentry-postgresql | awk '{print $2}'` -it -- bash

Then, change database password within container.

1
2
3
4
5
6
7
8
9
10
11
12
13
# Allow postgres login without password from local.
$ sed -ibak 's/^\([^#]*\)md5/\1trust/g' /opt/bitnami/postgresql/conf/pg_hba.conf

# Relaod PostgreSQL configuration.
$ pg_ctl reload

# Show password
$ echo ${POSTGRES_PASSWORD}

# Modify password.
# Remember to replace {{ POSTGRES_PASSWORD }} with your prefer password.
$ psql -U postgres
postgres=# alter user postgres with password "{{ POSTGRES_PASSWORD }}";

References

[1] charts/stable/sentry at master · helm/charts - https://github.com/helm/charts/tree/master/stable/sentry

[2] Azure Helm mirror - http://mirror.azure.cn/kubernetes/charts/

[3] charts/values.yaml at master · helm/charts - https://github.com/helm/charts/blob/master/stable/sentry/values.yaml

[4] Sentry | Error Tracking Software — JavaScript, Python, PHP, Ruby, more - https://sentry.io/welcome/

[5] getsentry/sentry: Sentry is cross-platform application monitoring, with a focus on error reporting. - https://github.com/getsentry/sentry

[6] Helm - https://helm.sh/

[7] Kubernetes - https://kubernetes.io/

[8] Modify the default administrator password - https://docs.bitnami.com/aws/infrastructure/postgresql/administration/change-reset-password/