sentry-kubernetes
sentry-kubernetes copied to clipboard
Add method to set K8S custom environments akin to custom DSNs
Currently, an error is reported to the correct DNS in Sentry, however it uses the environment set in SENTRY_ENVIRONMENT. This is very inflexible and limits you to a single environment.
We'd like the ability override the default environment and enable custom environment overrides akin to the SENTRY_K8S_CUSTOM_DSNS setting by adding a newSENTRY_K8S_CUSTOM_ENVIRONMENTS variable.
New Configuration Variable
SENTRY_K8S_CUSTOM_ENVIRONMENTS- if set to 1, enables custom environments to be specified in the annotations with keyk8s.sentry.io/environmentwhich would take precedence overSENTRY_ENVIRONMENT. Disabled by default.
Example resource using SENTRY_K8S_CUSTOM_DSNS and SENTRY_K8S_CUSTOM_ENVIRONMENTS via annotations:
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: pod-crashloop
type: test-pod
name: pod-crashloop
annotations:
k8s.sentry.io/dsn: "https://[email protected]/xxxx"
k8s.sentry.io/environment: "staging"
spec:
containers:
- image: alpine:3
name: pod-crashloop
command:
- sh
- "-c"
- |
sleep 1
invalid_command
dnsPolicy: ClusterFirst
restartPolicy: Always