# How to Self Host Sentry?

**Step-1**: You need to start with setting up your Kubernetes Cluster, to know the Step-by-step flow of setting up a cluster follow these [Instructions](https://scoutflo-documentation.gitbook.io/scoutflo-documentation/key-feature/create-a-new-cluster).

**Step-2:** Navigate to the "App Store" section on the left side navigation bar. And type 'sentry', in the search bar.

<figure><img src="https://4241237958-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtffWbX4svYQUS7SraAdG%2Fuploads%2FtcRO2v7us1maZ5yaNJY9%2Fimage.png?alt=media&#x26;token=b886a276-74b9-49e1-8bd4-956bcc3d7e99" alt="" width="563"><figcaption></figcaption></figure>

**Step-3**: Click on the 'Sentry' app card on the App store to open the 'Pre Deployment' screen of Sentry open source app.

<figure><img src="https://4241237958-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtffWbX4svYQUS7SraAdG%2Fuploads%2FkItH77p8LHXn4fv5HCOQ%2Fimage.png?alt=media&#x26;token=90591de9-443e-4be8-8621-dd926b0ed099" alt="" width="563"><figcaption></figcaption></figure>

* Select the desired '**Cluster**' where you want to deploy the Sentry app. If there is no cluster been added yet, you will be asked to be first add a cluster and then start the Sentry deployment process.
* The input field beside the cluster input drop-down is for entering the desired '**Namespace**' where you want to deploy the Sentry and it resources.

**Step-4**: Once you fill in the cluster details, you can switch to the next tab - '**Environment Variables**'.

<figure><img src="https://4241237958-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtffWbX4svYQUS7SraAdG%2Fuploads%2FoF5pkYldSyz8pd56uiOQ%2Fimage.png?alt=media&#x26;token=724211ca-6554-4f42-adf6-03da8750ef62" alt="" width="563"><figcaption></figcaption></figure>

* At the top right corner, click on the '**Chart Version**' drop-down, where you can select your desired Sentry helm chart version to deploy it on your cluster.

**Step-5**: Once you finalize your **Sentry Helm Chart Version**, it will open the `values.yaml` file on this screen, where you have to edit the following variables:

<figure><img src="https://4241237958-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtffWbX4svYQUS7SraAdG%2Fuploads%2FvCVIq3dseN4KsQC83WXN%2Fimage.png?alt=media&#x26;token=cd45fecf-08c2-4b7f-a2e7-48c31384998a" alt="" width="563"><figcaption></figcaption></figure>

1. Disable the 'Ingress' variable key:

   `ingress:`   \
   `enabled: false`&#x20;
2. Search for "controller" in the search bar inside the Monaco code editor:

   <figure><img src="https://4241237958-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtffWbX4svYQUS7SraAdG%2Fuploads%2FSPNhc75Zj8KFFpgssRsd%2Fimage.png?alt=media&#x26;token=12467f6c-01a4-4470-bfb2-4bf5b1be2583" alt="" width="563"><figcaption></figcaption></figure>

* You will be directed to this section where just below the variable 'controller' add an extra variable:

  `broker:`

  `replicaCount: 1`&#x20;

3. Search for "pdb" in the search bar inside the Monaco code editor:

   <figure><img src="https://4241237958-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtffWbX4svYQUS7SraAdG%2Fuploads%2F9AJpUk9oocHT19q3NLlB%2Fimage.png?alt=media&#x26;token=4a336052-ea0d-4511-a0c0-cad976c6bea4" alt="" width="563"><figcaption></figcaption></figure>

* Change the key value `create: true` to `create: false`.

**Step-6:** After setting up all the above variable values, hit on the CTA 'Deploy' button at the top right corner.

<figure><img src="https://4241237958-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtffWbX4svYQUS7SraAdG%2Fuploads%2FJLwcMohIwuamQjyEjlXq%2Fimage.png?alt=media&#x26;token=c4f1a45d-3581-494b-863c-6e166a226acc" alt="" width="563"><figcaption></figcaption></figure>

* You will be redirected to the Logs page where you can check the details of each step which Scoutflo automates for the deployment of the Sentry open source tool.

<figure><img src="https://4241237958-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtffWbX4svYQUS7SraAdG%2Fuploads%2Fml5Z7fhAeiEZXsBhxudI%2Fimage.png?alt=media&#x26;token=bb43b2a5-0c3a-4a38-8436-61f9af640250" alt="" width="563"><figcaption></figcaption></figure>

***

### Post Deployment of Sentry:

* Once the Sentry app is successfully deployed you can open the 'Post Deploy' screen of the Sentry, where you can check all these details:

<figure><img src="https://4241237958-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtffWbX4svYQUS7SraAdG%2Fuploads%2FUbq4vGrUjyLd1QSHbRCM%2Fimage.png?alt=media&#x26;token=2c494206-1f9a-47da-96ad-04ec5f7d99e0" alt="" width="563"><figcaption></figcaption></figure>

* When you try to open the App URL, you will see this error on the externally exposed service:

<figure><img src="https://4241237958-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtffWbX4svYQUS7SraAdG%2Fuploads%2FiYQWP7MxpSrDI3Je2ygf%2Fimage.png?alt=media&#x26;token=9e1e0a35-1ab0-40fe-9d5f-665d0611f9c5" alt="" width="563"><figcaption></figcaption></figure>

* You will have to take two more steps before being able to start using the Sentry.

1. Post the Sentry deployment, there are various cronjobs that are automatically run for clean up and setup of the Sentry Databases.
2. First we need to run an script which will run a command '**Sentry Upgrade**' which is used to do the **PostgreSQL DB migration** and create a new **Sentry Organization.**

```
resource: |
  apiVersion: batch/v1
  kind: Job
  metadata:
   name: sentry-upgrade
   namespace: <your-sentry-namespace>
   labels:
   app: sentry
   component: upgrade
  spec:
   backoffLimit: 1
   template:
   spec:
   restartPolicy: Never
   containers:
   - name: sentry-upgrade
   image: ghcr.io/getsentry/sentry:25.8.0
   command: ["sentry", "upgrade", "--noinput"]
   env:
   - name: SENTRY_SECRET_KEY
   valueFrom:
   secretKeyRef:
   name: <your-sentry-namespace>-sentry-secret
   key: key
   - name: POSTGRES_PASSWORD
   valueFrom:
   secretKeyRef:
   name: <your-sentry-namespace>-sentry-postgresql
   key: postgres-password
   - name: POSTGRES_USER
   value: postgres
   - name: POSTGRES_NAME
   value: sentry
   - name: POSTGRES_HOST
   value: <your-sentry-namespace>-sentry-postgresql
   - name: POSTGRES_PORT
   value: "5432"
   - name: SNUBA
   value: http://<your-sentry-namespace>-snuba:1218
   - name: VROOM
   value: http://<your-sentry-namespace>-vroom:8085
   volumeMounts:
   - name: config
   mountPath: /etc/sentry
   volumes:
   - name: config
   configMap:
   name: <your-sentry-namespace>-sentry
```

{% hint style="info" %}

### Organization creation details:

* The Sentry upgrade command internally creates a **default organization** in the database as part of migrations.
* The organization is not explicitly named in the Kubernetes job YAML.
* Usually, the default organization will be created with a default or internal name.
* To customize or rename the organization (e.g., "Your-org-Sentry"), you typically do this after login via the Sentry UI or through Sentry API.
* The superuser created in the second job can log in and manage the organization settings afterward.
  {% endhint %}

3. Run another Script to create a **username** and **password** to **signup** in the Sentry organization created above.

```
resource: |
  apiVersion: batch/v1
  kind: Job
  metadata:
    name: sentry-create-superuser
    namespace: <your-sentry-namespace>
    labels:
      app: sentry
      component: create-superuser
  spec:
    backoffLimit: 1
    template:
      spec:
        restartPolicy: Never
        containers:
          - name: sentry-create-superuser
            image: ghcr.io/getsentry/sentry:25.8.0
            command:
              - sentry
              - createuser
              - --email
              - <your-login-email>
              - --password
              - <your-login-pssword>
              - --superuser
              - --no-input
            env:
              - name: SENTRY_SECRET_KEY
                valueFrom:
                  secretKeyRef:
                    name: <your-sentry-namespace>-sentry-secret
                    key: key
              - name: POSTGRES_PASSWORD
                valueFrom:
                  secretKeyRef:
                    name: <your-sentry-namespace>-sentry-postgresql
                    key: postgres-password
              - name: POSTGRES_USER
                value: postgres
              - name: POSTGRES_NAME
                value: sentry
              - name: POSTGRES_HOST
                value: <your-sentry-namespace>-sentry-postgresql
              - name: POSTGRES_PORT
                value: "5432"
              - name: SNUBA
                value: http://<your-sentry-namespace>-snuba:1218
              - name: VROOM
                value: http://<your-sentry-namespace>-vroom:8085
            volumeMounts:
              - name: config
                mountPath: /etc/sentry
        volumes:
          - name: config
            configMap:
              name: <your-sentry-namespace>-sentry
```

***

### Scoutflo Voyager:

* To continue the Post Deployment setup of the Sentry app, you can use the Scoutflo's AI powered Kubernetes Chat to directly apply the above Job scripts in your cluster where the sentry is setup.
* Click on the CTA button **"Try Scoutflo AI":**

<figure><img src="https://4241237958-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtffWbX4svYQUS7SraAdG%2Fuploads%2FDSGeUwDv4YT3toAJF2j5%2Fimage.png?alt=media&#x26;token=c05afa39-0cba-4f6c-bf18-f1199cb3631a" alt="" width="563"><figcaption></figcaption></figure>

* Navigate to the "**Provisioner**" mode on the left side nav bar:

<figure><img src="https://4241237958-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtffWbX4svYQUS7SraAdG%2Fuploads%2FajRlwigiFQfEhA7oUMe8%2Fimage.png?alt=media&#x26;token=fe417de8-51db-46e5-8b06-96980af4aa1d" alt="" width="563"><figcaption></figcaption></figure>

* Click and switch to the "**Kubernetes**" **sub mode** and select the **cluster** you have deployed the **Sentry**:

<figure><img src="https://4241237958-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtffWbX4svYQUS7SraAdG%2Fuploads%2FTCQ879HB6nNqCGxQhUKD%2Fimage.png?alt=media&#x26;token=3bddaa5b-c48d-4db4-a4ed-721e519d83f0" alt="" width="563"><figcaption></figcaption></figure>

* **You can now enter your NLP prompt for applying the job scripts.**
