Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
iambriccardo committed Dec 10, 2024
1 parent 278312b commit 7a39a6b
Show file tree
Hide file tree
Showing 8 changed files with 178 additions and 0 deletions.
52 changes: 52 additions & 0 deletions scripts/relay-init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash

set -euo pipefail

CONFIG_DIR="config"

# Ensure the config directory is cleaned up on exit
trap "rm -rf ${CONFIG_DIR}" EXIT

# Prompt the user for the Sentry upstream URL
read -p "Enter your Sentry upstream URL (e.g. https://oXXXX.ingest.sentry.io): " SENTRY_UPSTREAM

# Create a configuration directory for relay if it doesn't exist
mkdir -p "${CONFIG_DIR}"

echo "Initializing Relay configuration..."
# Run relay config init to create config files (.relay/config.yml and credentials.json)
# We assume you'll choose the default configuration by pressing enter.
docker run --rm -it \
-v "$(pwd)/${CONFIG_DIR}":/work/.relay \
getsentry/relay \
config init

# At this point, config.yml and credentials.json should be in ${CONFIG_DIR}
CREDENTIALS_FILE="${CONFIG_DIR}/credentials.json"

if [ ! -f "${CREDENTIALS_FILE}" ]; then
echo "Error: ${CREDENTIALS_FILE} not found. Make sure relay config init completed successfully."
exit 1
fi

echo "Reading credentials from ${CREDENTIALS_FILE}..."
# Parse the credentials file directly with jq
SECRET_KEY=$(jq -r '.secret_key' "${CREDENTIALS_FILE}")
PUBLIC_KEY=$(jq -r '.public_key' "${CREDENTIALS_FILE}")
RELAY_ID=$(jq -r '.id' "${CREDENTIALS_FILE}")

echo "Credentials and upstream URL obtained successfully."

cat <<EOF
Setup complete!
Your relay chart can now be installed with the following command:
helm install sentry-relay ../sentry-relay \\
--set relay.upstream="${SENTRY_UPSTREAM}" \\
--set credentials.secretKey="${SECRET_KEY}" \\
--set credentials.publicKey="${PUBLIC_KEY}" \\
--set credentials.relayId="${RELAY_ID}"
Once deployed, you can port-forward and test sending events as noted in the chart's NOTES.txt.
EOF
6 changes: 6 additions & 0 deletions sentry-relay/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: sentry-relay
description: A Helm chart for deploying Sentry Relay
type: application
version: 0.1.0
appVersion: "latest"
16 changes: 16 additions & 0 deletions sentry-relay/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Thank you for installing my-sentry-relay!

To test your Relay instance:

1. Port forward the service:
kubectl port-forward svc/{{ include "my-sentry-relay.fullname" . }} 3000:3000

2. Update your DSN to point to Relay:
Original DSN: https://<key>@oX.ingest.sentry.io/<project_id>
Relay DSN: http://<key>@localhost:3000/<project_id>

3. Test with sentry-cli:
export SENTRY_DSN='http://<key>@localhost:3000/<project_id>'
sentry-cli send-event -m 'A test event'

4. Check in your Sentry project for the event.
11 changes: 11 additions & 0 deletions sentry-relay/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "my-sentry-relay.fullname" . }}-config
data:
config.yml: |
relay:
mode: {{ .Values.relay.mode }}
upstream: {{ .Values.relay.upstream }}
host: {{ .Values.relay.host }}
port: {{ .Values.relay.port }}
43 changes: 43 additions & 0 deletions sentry-relay/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "my-sentry-relay.fullname" . }}
labels:
app: {{ include "my-sentry-relay.name" . }}
spec:
replicas: 1
selector:
matchLabels:
app: {{ include "my-sentry-relay.name" . }}
template:
metadata:
labels:
app: {{ include "my-sentry-relay.name" . }}
spec:
containers:
- name: relay
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args: ["run"]
ports:
- containerPort: {{ .Values.relay.port }}
volumeMounts:
- name: relay-config
mountPath: /work/.relay
- name: relay-credentials
mountPath: /work/.relay
readOnly: true
resources:
requests:
cpu: {{ .Values.resources.requests.cpu }}
memory: {{ .Values.resources.requests.memory }}
limits:
cpu: {{ .Values.resources.limits.cpu }}
memory: {{ .Values.resources.limits.memory }}
volumes:
- name: relay-config
configMap:
name: {{ include "my-sentry-relay.fullname" . }}-config
- name: relay-credentials
secret:
secretName: {{ include "my-sentry-relay.fullname" . }}-credentials
12 changes: 12 additions & 0 deletions sentry-relay/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ include "my-sentry-relay.fullname" . }}-credentials
type: Opaque
stringData:
credentials.json: |
{
"secret_key": "{{ .Values.credentials.secretKey }}",
"public_key": "{{ .Values.credentials.publicKey }}",
"id": "{{ .Values.credentials.relayId }}"
}
15 changes: 15 additions & 0 deletions sentry-relay/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "my-sentry-relay.fullname" . }}
labels:
app: {{ include "my-sentry-relay.name" . }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: {{ .Values.relay.port }}
protocol: TCP
name: http
selector:
app: {{ include "my-sentry-relay.name" . }}
23 changes: 23 additions & 0 deletions sentry-relay/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
image:
repository: getsentry/relay
tag: latest
pullPolicy: IfNotPresent

service:
type: ClusterIP
port: 3000

relay:
mode: managed
host: 127.0.0.0
port: 3000

credentials:

resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 500m
memory: 512Mi

0 comments on commit 7a39a6b

Please sign in to comment.