Skip to content

Add method to set K8S custom environments akin to custom DSNs #96

Open

Description

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 key k8s.sentry.io/environment which would take precedence over SENTRY_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://xxxx@xxxx.ingest.us.sentry.io/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions