Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add geoip support to sentry deployment #1516

Merged
merged 2 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions charts/sentry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,34 @@ geodata:
path: /geodata/GeoLite2-City.mmdb
```

or

Warning:
storage must support ReadWriteMany

```yaml
# enable and reference the volume
geodata:
accountID: "example"
licenseKey: "example"
editionIDs: "example"
persistence:
## 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: "-"
size: 1Gi
volumeName: "data-sentry-geoip"
# mountPath of the volume containing the database
mountPath: "/usr/share/GeoIP"
# path to the geoip database inside the volumemount
path: "/usr/share/GeoIP/GeoLite2-City.mmdb"
```

## External Kafka configuration

You can either provide a single host, which is there by default in `values.yaml`, like this:
Expand Down
36 changes: 36 additions & 0 deletions charts/sentry/templates/deployment-geoip-job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{{- if .Values.geodata.accountID }}
apiVersion: batch/v1
kind: Job
metadata:
name: geoip-install-job
annotations:
"helm.sh/hook": "pre-install"
"helm.sh/hook-weight": "3"
spec:
template:
spec:
initContainers:
- name: init-geoip-conf
image: busybox
command: ['sh', '-c', 'echo -e "AccountID $(echo $GEOIPUPDATE_ACCOUNT_ID)\nLicenseKey $(echo $GEOIPUPDATE_LICENSE_KEY)\nEditionIDs $(echo $GEOIPUPDATE_EDITION_IDS)" > /usr/share/GeoIP/GeoIP.conf']
envFrom:
- secretRef:
name: {{ template "sentry.fullname" . }}-geoip-env
volumeMounts:
- name: {{ .Values.geodata.volumeName }}
mountPath: {{ .Values.geodata.mountPath }}
containers:
- name: geoipupdate
image: ghcr.io/maxmind/geoipupdate:v7.0.1
envFrom:
- secretRef:
name: {{ template "sentry.fullname" . }}-geoip-env
volumeMounts:
- name: {{ .Values.geodata.volumeName }}
mountPath: {{ .Values.geodata.mountPath }}
volumes:
- name: {{ .Values.geodata.volumeName }}
persistentVolumeClaim:
claimName: data-sentry-geoip
restartPolicy: OnFailure
{{- end }}
22 changes: 22 additions & 0 deletions charts/sentry/templates/pvc-geoip.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{- if .Values.geodata.accountID }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: data-sentry-geoip
labels:
app: sentry
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: {{ .Values.geodata.persistence.size }}
{{- if (eq "-" .Values.geodata.persistence.storageClass) }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .Values.geodata.persistence.storageClass }}"
{{- end }}
Comment on lines +17 to +21

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@patsevanton according to the comment in the values.yaml shouldn't that be:

{{- if .Values.geodata.persistence.storageClass }}
{{- if (eq "-" .Values.geodata.persistence.storageClass) }}
  storageClassName: ""
{{- else }}
  storageClassName: "{{ .Values.geodata.persistence.storageClass }}"
{{- end }}
{{- end }}

Copy link
Contributor Author

@patsevanton patsevanton Oct 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sdernbach-ionos please review PR #1524

{{- end }}
5 changes: 5 additions & 0 deletions charts/sentry/templates/relay/deployment-relay.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ spec:
defaultMode: 0644
- name: credentials
emptyDir: {}
{{- if and .Values.geodata.volumeName .Values.geodata.accountID }}
- name: {{ .Values.geodata.volumeName }}
persistentVolumeClaim:
claimName: data-sentry-geoip
{{- end }}
{{- if .Values.relay.volumes }}
{{ toYaml .Values.relay.volumes | indent 6 }}
{{- end }}
Expand Down
16 changes: 16 additions & 0 deletions charts/sentry/templates/secret-geoip-env.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{- if .Values.geodata.accountID }}
apiVersion: v1
kind: Secret
metadata:
name: {{ template "sentry.fullname" . }}-geoip-env
labels:
app: sentry
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
type: Opaque
data:
GEOIPUPDATE_ACCOUNT_ID: {{ .Values.geodata.accountID | b64enc | quote }}
GEOIPUPDATE_LICENSE_KEY: {{ .Values.geodata.licenseKey | b64enc | quote }}
GEOIPUPDATE_EDITION_IDS: {{ .Values.geodata.editionIDs | b64enc | quote }}
{{- end -}}
5 changes: 5 additions & 0 deletions charts/sentry/templates/sentry/web/deployment-sentry-web.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ spec:
{{- if .Values.sentry.web.priorityClassName }}
priorityClassName: "{{ .Values.sentry.web.priorityClassName }}"
{{- end }}
{{- if and .Values.geodata.volumeName .Values.geodata.accountID }}
- name: {{ .Values.geodata.volumeName }}
persistentVolumeClaim:
claimName: data-sentry-geoip
{{- end }}
{{- if .Values.sentry.web.volumes }}
{{ toYaml .Values.sentry.web.volumes | indent 6 }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ spec:
secret:
secretName: {{ .Values.filestore.gcs.secretName }}
{{ end }}
{{- if and .Values.geodata.volumeName .Values.geodata.accountID }}
- name: {{ .Values.geodata.volumeName }}
persistentVolumeClaim:
claimName: data-sentry-geoip
{{- end }}
{{- if .Values.sentry.workerEvents.priorityClassName }}
priorityClassName: "{{ .Values.sentry.workerEvents.priorityClassName }}"
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ spec:
{{- if .Values.sentry.workerTransactions.priorityClassName }}
priorityClassName: "{{ .Values.sentry.workerTransactions.priorityClassName }}"
{{- end }}
{{- if and .Values.geodata.volumeName .Values.geodata.accountID }}
- name: {{ .Values.geodata.volumeName }}
persistentVolumeClaim:
claimName: data-sentry-geoip
{{- end }}
{{- if .Values.sentry.workerTransactions.volumes }}
{{ toYaml .Values.sentry.workerTransactions.volumes | indent 6 }}
{{- end }}
Expand Down
18 changes: 17 additions & 1 deletion charts/sentry/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,26 @@ relay:
# - name: security.protocol
# value: "SSL"

# enable and reference the volume
geodata:
path: ""
accountID: ""
licenseKey: ""
editionIDs: ""
persistence:
## 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: "-"
size: 1Gi
volumeName: ""
# mountPath of the volume containing the database
mountPath: ""
# path to the geoip database inside the volumemount
path: ""

sentry:
# to not generate a sentry-secret, use these 2 values to reference an existing secret
Expand Down