Skip to content

Commit 978ca63

Browse files
authored
consolidated instructions for configuring external object storage (#932)
Updating our existing external object storage documentation to cover both use cases (precise index upload and search jobs). This PR is mostly structural reorganization of the existing content spread across two doc pages for improved readability/ discoverability. ## Pull Request approval You will need to get your PR approved by at least one member of the Sourcegraph team. For reviews of docs formatting, styles, and component usage, please tag the docs team via the #docs Slack channel.
1 parent b0ba550 commit 978ca63

File tree

2 files changed

+53
-44
lines changed

2 files changed

+53
-44
lines changed

docs/admin/external_services/object_storage.mdx

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
# Using a managed object storage service (S3 or GCS)
22

3-
By default, Sourcegraph will use a `sourcegraph/blobstore` server bundled with the instance to temporarily store code graph indexes uploaded by users.
3+
By default, Sourcegraph will use a `sourcegraph/blobstore` server bundled with the instance to temporarily store [code graph indexes](../../code-search/code-navigation/precise_code_navigation) uploaded by users as well as the results of [search jobs](../../code-search/types/search-jobs).
44

55
You can alternatively configure your instance to instead store this data in an S3 or GCS bucket. Doing so may decrease your hosting costs as persistent volumes are often more expensive than the same storage space in an object store service.
66

7-
To target a managed object storage service, you will need to set a handful of environment variables for configuration and authentication to the target service. **If you are running a sourcegraph/server deployment, set the environment variables on the server container. Otherwise, if running via Docker-compose or Kubernetes, set the environment variables on the `frontend`, `worker`, and `precise-code-intel-worker` containers.**
7+
## Code Graph Indexes
8+
9+
To target a managed object storage service for storing [code graph index uploads](../../code-search/code-navigation/precise_code_navigation), you will need to set a handful of environment variables for configuration and authentication to the target service.
10+
11+
- If you are running a `sourcegraph/server` deployment, set the environment variables on the server container
12+
- If you are running via Docker-compose or Kubernetes, set the environment variables on the `frontend`, `worker`, and `precise-code-intel-worker` containers
813

914
### Using S3
1015

1116
To target an S3 bucket you've already provisioned, set the following environment variables. Authentication can be done through [an access and secret key pair](https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys) (and optional session token), or via the EC2 metadata API.
1217

13-
**_Warning:_** Remember never to commit aws access keys in git. Consider using a secret handling service offered by your cloud provider.
18+
<Callout type="warning"> Never commit AWS access keys in Git. You should consider using a secret handling service offered by your cloud provider. </Callout>
1419

1520
- `PRECISE_CODE_INTEL_UPLOAD_BACKEND=S3`
1621
- `PRECISE_CODE_INTEL_UPLOAD_BUCKET=<my bucket name>`
@@ -21,9 +26,9 @@ To target an S3 bucket you've already provisioned, set the following environment
2126
- `PRECISE_CODE_INTEL_UPLOAD_AWS_USE_EC2_ROLE_CREDENTIALS=true` (optional; set to use EC2 metadata API over static credentials)
2227
- `PRECISE_CODE_INTEL_UPLOAD_AWS_REGION=us-east-1` (default)
2328

24-
**_Note:_** If a non-default region is supplied, ensure that the subdomain of the endpoint URL (_the `AWS_ENDPOINT` value_) matches the target region.
29+
<Callout type="note"> If a non-default region is supplied, ensure that the subdomain of the endpoint URL (_the `AWS_ENDPOINT` value_) matches the target region. </Callout>
2530

26-
> NOTE: You don't need to set the `PRECISE_CODE_INTEL_UPLOAD_AWS_ACCESS_KEY_ID` environment variable when using `PRECISE_CODE_INTEL_UPLOAD_AWS_USE_EC2_ROLE_CREDENTIALS=true` because role credentials will be automatically resolved. Attach the IAM role to the EC2 instances hosting the `frontend`, `worker`, and `precise-code-intel-worker` containers in a multi-node environment.
31+
<Callout type="tip"> You don't need to set the `PRECISE_CODE_INTEL_UPLOAD_AWS_ACCESS_KEY_ID` environment variable when using `PRECISE_CODE_INTEL_UPLOAD_AWS_USE_EC2_ROLE_CREDENTIALS=true` because role credentials will be automatically resolved. Attach the IAM role to the EC2 instances hosting the `frontend`, `worker`, and `precise-code-intel-worker` containers in a multi-node environment. </Callout>
2732

2833

2934
### Using GCS
@@ -42,3 +47,45 @@ If you would like to allow your Sourcegraph instance to control the creation and
4247

4348
- `PRECISE_CODE_INTEL_UPLOAD_MANAGE_BUCKET=true`
4449
- `PRECISE_CODE_INTEL_UPLOAD_TTL=168h` (default)
50+
51+
## Search Job Results
52+
53+
To target a third party managed object storage service for storing [search job results](../../code-search/types/search-jobs), you must set a handful of environment variables for configuration and authentication to the target service.
54+
55+
- If you are running a `sourcegraph/server` deployment, set the environment variables on the server container
56+
- If you are running via Docker-compose or Kubernetes, set the environment variables on the `frontend` and `worker` containers
57+
58+
### Using S3
59+
60+
Set the following environment variables to target an S3 bucket you've already provisioned. Authentication can be done through [an access and secret key pair](https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys) (and optionally through session token) or via the EC2 metadata API.
61+
62+
<Callout type="warning"> Never commit AWS access keys in Git. You should consider using a secret handling service offered by your cloud provider.</Callout>
63+
64+
- `SEARCH_JOBS_UPLOAD_BACKEND=S3`
65+
- `SEARCH_JOBS_UPLOAD_BUCKET=<my bucket name>`
66+
- `SEARCH_JOBS_UPLOAD_AWS_ENDPOINT=https://s3.us-east-1.amazonaws.com`
67+
- `SEARCH_JOBS_UPLOAD_AWS_ACCESS_KEY_ID=<your access key>`
68+
- `SEARCH_JOBS_UPLOAD_AWS_SECRET_ACCESS_KEY=<your secret key>`
69+
- `SEARCH_JOBS_UPLOAD_AWS_SESSION_TOKEN=<your session token>` (optional)
70+
- `SEARCH_JOBS_UPLOAD_AWS_USE_EC2_ROLE_CREDENTIALS=true` (optional; set to use EC2 metadata API over static credentials)
71+
- `SEARCH_JOBS_UPLOAD_AWS_REGION=us-east-1` (default)
72+
73+
<Callout type="note"> If a non-default region is supplied, ensure that the subdomain of the endpoint URL (the `AWS_ENDPOINT` value) matches the target region.</Callout>
74+
75+
<Callout type="tip"> You don't need to set the `SEARCH_JOBS_UPLOAD_AWS_ACCESS_KEY_ID` environment variable when using `SEARCH_JOBS_UPLOAD_AWS_USE_EC2_ROLE_CREDENTIALS=true` because role credentials will be automatically resolved.</Callout>
76+
77+
### Using GCS
78+
79+
Set the following environment variables to target a GCS bucket you've already provisioned. Authentication is done through a service account key, either as a path to a volume-mounted file or the contents read in as an environment variable payload.
80+
81+
- `SEARCH_JOBS_UPLOAD_BACKEND=GCS`
82+
- `SEARCH_JOBS_UPLOAD_BUCKET=<my bucket name>`
83+
- `SEARCH_JOBS_UPLOAD_GCP_PROJECT_ID=<my project id>`
84+
- `SEARCH_JOBS_UPLOAD_GOOGLE_APPLICATION_CREDENTIALS_FILE=</path/to/file>`
85+
- `SEARCH_JOBS_UPLOAD_GOOGLE_APPLICATION_CREDENTIALS_FILE_CONTENT=<{"my": "content"}>`
86+
87+
### Provisioning buckets
88+
89+
If you would like to allow your Sourcegraph instance to control the creation and lifecycle configuration management of the target buckets, set the following environment variables:
90+
91+
- `SEARCH_JOBS_UPLOAD_MANAGE_BUCKET=true`

docs/code-search/types/search-jobs.mdx

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -40,45 +40,7 @@ Search Jobs requires an object storage to store the results of your search jobs.
4040
By default, Search Jobs stores results using our bundled `blobstore` service.
4141
If the `blobstore` service is deployed, and you want to use it to store results from Search Jobs, you don't need to configure anything.
4242

43-
To use a third party managed object storage service, you must set a handful of environment variables for configuration and authentication to the target service.
44-
45-
- If you are running a `sourcegraph/server` deployment, set the environment variables on the server container
46-
- If you are running via Docker-compose or Kubernetes, set the environment variables on the `frontend` and `worker` containers
47-
48-
### Using S3
49-
50-
Set the following environment variables to target an S3 bucket you've already provisioned. Authentication can be done through [an access and secret key pair](https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys) (and optionally through session token) or via the EC2 metadata API.
51-
52-
<Callout type="tip"> Never commit AWS access keys in Git. You should consider using a secret handling service offered by your cloud provider.</Callout>
53-
54-
- `SEARCH_JOBS_UPLOAD_BACKEND=S3`
55-
- `SEARCH_JOBS_UPLOAD_BUCKET=<my bucket name>`
56-
- `SEARCH_JOBS_UPLOAD_AWS_ENDPOINT=https://s3.us-east-1.amazonaws.com`
57-
- `SEARCH_JOBS_UPLOAD_AWS_ACCESS_KEY_ID=<your access key>`
58-
- `SEARCH_JOBS_UPLOAD_AWS_SECRET_ACCESS_KEY=<your secret key>`
59-
- `SEARCH_JOBS_UPLOAD_AWS_SESSION_TOKEN=<your session token>` (optional)
60-
- `SEARCH_JOBS_UPLOAD_AWS_USE_EC2_ROLE_CREDENTIALS=true` (optional; set to use EC2 metadata API over static credentials)
61-
- `SEARCH_JOBS_UPLOAD_AWS_REGION=us-east-1` (default)
62-
63-
<Callout type="note"> If a non-default region is supplied, ensure that the subdomain of the endpoint URL (the `AWS_ENDPOINT` value) matches the target region.</Callout>
64-
65-
<Callout type="note"> You don't need to set the `SEARCH_JOBS_UPLOAD_AWS_ACCESS_KEY_ID` environment variable when using `SEARCH_JOBS_UPLOAD_AWS_USE_EC2_ROLE_CREDENTIALS=true` because role credentials will be automatically resolved.</Callout>
66-
67-
### Using GCS
68-
69-
Set the following environment variables to target a GCS bucket you've already provisioned. Authentication is done through a service account key, either as a path to a volume-mounted file or the contents read in as an environment variable payload.
70-
71-
- `SEARCH_JOBS_UPLOAD_BACKEND=GCS`
72-
- `SEARCH_JOBS_UPLOAD_BUCKET=<my bucket name>`
73-
- `SEARCH_JOBS_UPLOAD_GCP_PROJECT_ID=<my project id>`
74-
- `SEARCH_JOBS_UPLOAD_GOOGLE_APPLICATION_CREDENTIALS_FILE=</path/to/file>`
75-
- `SEARCH_JOBS_UPLOAD_GOOGLE_APPLICATION_CREDENTIALS_FILE_CONTENT=<{"my": "content"}>`
76-
77-
### Provisioning buckets
78-
79-
If you would like to allow your Sourcegraph instance to control the creation and lifecycle configuration management of the target buckets, set the following environment variables:
80-
81-
- `SEARCH_JOBS_UPLOAD_MANAGE_BUCKET=true`
43+
To use a third party managed object storage service, see instructions in [externalizing object storage](../../admin/external_services/object_storage#search-job-results).
8244

8345
## Supported result types
8446

0 commit comments

Comments
 (0)