Skip to content

Commit 8be9505

Browse files
authored
Update readmes (#18)
1 parent 2f457e2 commit 8be9505

File tree

10 files changed

+71
-37
lines changed

10 files changed

+71
-37
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
The Sourcegraph Enterprise license (the “Enterprise License”)
2-
Copyright (c) 2018 Sourcegraph Inc.
2+
Copyright (c) 2021 Sourcegraph Inc.
33

44
With regard to the Sourcegraph Software:
55

README.md

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,24 @@
11
# Terraform module for Sourcegraph executors (AWS)
22

3-
This repository provides a [Terraform module](https://learn.hashicorp.com/tutorials/terraform/module-use?in=terraform/modules) to provision Sourcegraph executor compute resources on AWS.
3+
This repository provides a [Terraform module](https://learn.hashicorp.com/tutorials/terraform/module-use?in=terraform/modules) to provision [Sourcegraph executor](https://docs.sourcegraph.com/admin/executors) compute resources on AWS. If you are installing executors for the first time, [follow our complete setup guide](https://docs.sourcegraph.com/admin/deploy_executors).
44

55
![Infrastructure overview](https://raw.githubusercontent.com/sourcegraph/terraform-aws-executors/master/images/infrastructure.png)
66

7-
## Usage examples
7+
This repository provides four submodules:
88

9-
There are several examples in the [`examples`](./examples) directory.
9+
1. The [executors module](https://registry.terraform.io/modules/sourcegraph/executors/aws/latest/submodules/executors) provisions compute resources for executors.
10+
1. The [docker-mirror module](https://registry.terraform.io/modules/sourcegraph/executors/aws/latest/submodules/docker-mirror) provisions a Docker registry pull-through cache.
11+
1. The [networking module](https://registry.terraform.io/modules/sourcegraph/executors/aws/latest/submodules/networking) provisions a network to be shared by the executor and Docker registry resources.
12+
1. The [credentials module](https://registry.terraform.io/modules/sourcegraph/executors/aws/latest/submodules/credentials) provisions credentials required by the Sourcegraph instance to enable observability and auto-scaling of executors.
1013

11-
#### [`examples/single-executor`](./examples/single-executor)
14+
The [multiple-executors example](https://github.com/sourcegraph/terraform-aws-executors/blob/master/examples/multiple-executors) uses the submodule directly to provision multiple executor resource groups performing different types of work. Follow this example if you are:
1215

13-
This example uses the [root module](https://registry.terraform.io/modules/sourcegraph/executors/aws/latest) that provisions a network, a Docker registry mirror, and a set of resources to run _one_ type of executor. To provision more than one type of executor (multiple queues or multiple environments), see the following `multiple-executors` example.
16+
1. Provisioning executors for use with multiple features (e.g., both [auto-indexing](https://docs.sourcegraph.com/code_intelligence/explanations/auto_indexing) and [server-side batch changes](https://docs.sourcegraph.com/batch_changes/explanations/server_side)), or
17+
1. Provisioning resources for multiple Sourcegraph instances (e.g., test, prod)
1418

15-
The following variables must be supplied:
19+
This repository also provides a [root module](https://registry.terraform.io/modules/sourcegraph/executors/aws/latest) combining the executors, network, and docker-mirror resources into an easier to use package.
1620

17-
**Note**: these variables must be set in tandem with changes to the target [Sourcegraph deployment](https://docs.sourcegraph.com/admin/deploy_executors).
18-
19-
- `executor_sourcegraph_external_url`: The URL from which the target Sourcegraph instance is accessible from the executor instances.
20-
- `executor_sourcegraph_executor_proxy_password`: The shared executor password defined in Sourcegraph. The value must be the same as the `executors.accessToken` site setting described in [Configuring executors and instance communication](https://docs.sourcegraph.com/admin/deploy_executors#configuring-executors-and-instance-communication).
21-
- `executor_queue_name`: The name of the target queue to process (e.g., `codeintel`, `batches`).
22-
- `executor_metrics_environment_label`: The name of the target environment (e.g., `staging`, `prod`). This value must be the same as the `EXECUTOR_METRIC_ENVIRONMENT_LABEL` environment variable as described in [Configuring auto scaling](https://docs.sourcegraph.com/admin/deploy_executors#aws).
23-
- `executor_instance_tag`: Compute instances are tagged by this value by the key `executor_tag`. We recommend this value take the form `{executor_queue_name}-{executor_metrics_environment_label}`. This value must be the same as `INSTANCE_TAG` as described in [Configuring observability](https://docs.sourcegraph.com/admin/deploy_executors#aws-1).
24-
25-
All of this module's variables are defined in [variables.tf](./variables.tf).
26-
27-
#### [`examples/multiple-executors`](./examples/multiple-executors)
28-
29-
This example uses [networking](https://registry.terraform.io/modules/sourcegraph/executors/aws/latest/submodules/networking), [docker-mirror](https://registry.terraform.io/modules/sourcegraph/executors/aws/latest/submodules/docker-mirror), and [executors](https://registry.terraform.io/modules/sourcegraph/executors/aws/latest/submodules/executors) submodules that provision a network, a Docker registry mirror, and sets of resources running one or more types of executors.
30-
31-
The following variables must be supplied:
32-
33-
- `sourcegraph_external_url`, `sourcegraph_executor_proxy_password`, `queue_name`, `metrics_environment_label`, and `instance_tag`: Analogous to the `executor_*` variables in the `single-executor` example.
34-
- `resource_prefix`: A prefix unique to each set of compute resources. This prevents collisions between two uses of the `executors` module. We recommend this value be constructed the same way `instance_tag` is constructed.
35-
- `docker_registry_mirror`: This variable is given the value `"http://${module.docker-mirror.ip_address}:5000"`, which converts the raw external IP address to an address resolvable by the executor instances.
36-
37-
If your deployment environment already has a Docker registry that can be used, only the `executor` submodule must be used (and references to the `networking` and `docker-mirror` modules can be dropped). The Docker registry mirror address can be supplied along with its containing vcp and subnet as pre-existing identifier literals.
38-
39-
All of these module's variables are defined in [modules/networking/variables.tf](./modules/networking/variables.tf), [modules/docker-mirror/variables.tf](./modules/docker-mirror/variables.tf), and [modules/executors/variables.tf](./modules/executors/variables.tf).
21+
The [single-executor example](https://github.com/sourcegraph/terraform-aws-executors/blob/master/examples/single-executor) uses the root module to provision a single executor type. Follow this example if you are deploying to a single Sourcegraph instance and using a single executors-backed feature.
4022

4123
## Requirements
4224

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Multiple executor example
2+
3+
This example uses [networking](https://registry.terraform.io/modules/sourcegraph/executors/aws/latest/submodules/networking), [docker-mirror](https://registry.terraform.io/modules/sourcegraph/executors/aws/latest/submodules/docker-mirror), and [executors](https://registry.terraform.io/modules/sourcegraph/executors/aws/latest/submodules/executors) submodules that provision a network, a Docker registry mirror, and sets of resources running one or more types of executors.
4+
5+
The following variables must be supplied:
6+
7+
- `sourcegraph_external_url`, `sourcegraph_executor_proxy_password`, `queue_name`, `metrics_environment_label`, and `instance_tag`: Analogous to the `executor_*` variables in the `single-executor` example.
8+
- `resource_prefix`: A prefix unique to each set of compute resources. This prevents collisions between two uses of the `executors` module. We recommend this value be constructed the same way `instance_tag` is constructed.
9+
- `docker_registry_mirror`: This variable is given the value `"http://${module.docker-mirror.ip_address}:5000"`, which converts the raw external IP address to an address resolvable by the executor instances.
10+
11+
If your deployment environment already has a Docker registry that can be used, only the `executor` submodule must be used (and references to the `networking` and `docker-mirror` modules can be dropped). The Docker registry mirror address can be supplied along with its containing VPC and subnet as pre-existing identifier literals.
12+
13+
All of these module's variables are defined in [modules/networking/variables.tf](https://github.com/sourcegraph/terraform-aws-executors/blob/master/modules/networking/variables.tf), [modules/docker-mirror/variables.tf](https://github.com/sourcegraph/terraform-aws-executors/blob/master/modules/docker-mirror/variables.tf), and [modules/executors/variables.tf](https://github.com/sourcegraph/terraform-aws-executors/blob/master/modules/executors/variables.tf).

examples/single-executor/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Single executor example
2+
3+
This example uses the [root module](https://registry.terraform.io/modules/sourcegraph/executors/aws/latest) that provisions a network, a Docker registry mirror, and a set of resources to run _one_ type of executor. To provision more than one type of executor (multiple queues or multiple environments), see the following `multiple-executors` example.
4+
5+
The following variables must be supplied:
6+
7+
**Note**: these variables must be set in tandem with changes to the target [Sourcegraph deployment](https://docs.sourcegraph.com/admin/deploy_executors).
8+
9+
- `executor_sourcegraph_external_url`: The URL from which the target Sourcegraph instance is accessible from the executor instances.
10+
- `executor_sourcegraph_executor_proxy_password`: The shared executor password defined in Sourcegraph. The value must be the same as the `executors.accessToken` site setting described in [Configuring executors and instance communication](https://docs.sourcegraph.com/admin/deploy_executors#configuring-executors-and-instance-communication).
11+
- `executor_queue_name`: The name of the target queue to process (e.g., `codeintel`, `batches`).
12+
- `executor_metrics_environment_label`: The name of the target environment (e.g., `staging`, `prod`). This value must be the same as the `EXECUTOR_METRIC_ENVIRONMENT_LABEL` environment variable as described in [Configuring auto scaling](https://docs.sourcegraph.com/admin/deploy_executors#aws).
13+
- `executor_instance_tag`: Compute instances are tagged by this value by the key `executor_tag`. We recommend this value take the form `{executor_queue_name}-{executor_metrics_environment_label}`. This value must be the same as `INSTANCE_TAG` as described in [Configuring observability](https://docs.sourcegraph.com/admin/deploy_executors#aws-1).
14+
15+
All of this module's variables are defined in [variables.tf](https://github.com/sourcegraph/terraform-aws-executors/blob/master/variables.tf).

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ module "aws-executor" {
4545
max_replicas = var.executor_max_replicas
4646
jobs_per_instance_scaling = var.executor_jobs_per_instance_scaling
4747
metrics_environment_label = var.executor_metrics_environment_label
48-
docker_registry_mirror = var.executor_docker_registry_mirror
48+
docker_registry_mirror = "http://${var.docker_mirror_static_ip}:5000"
4949
}

modules/credentials/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Credentials module
2+
3+
This module can be optionally used to create the IAM user policies required to configure auto-scaling and observability of [Sourcegraph executor](https://docs.sourcegraph.com/admin/executors) in AWS.
4+
5+
Auto-scaling requires that the executor compute instances have permissions to emit CloudWatch metrics. As outlined in [how to configure auto scaling](https://docs.sourcegraph.com/admin/deploy_executors#aws), the Sourcegraph `worker` service must set the `EXECUTOR_METRIC_AWS_ACCESS_KEY_ID` and `EXECUTOR_METRIC_AWS_SECRET_ACCESS_KEY` environment variables to be the same as the `metric_writer_access_key_id` and `metric_writer_secret_key` values provided by running this module.
6+
7+
Observability of executor compute resources require that the target Sourcegraph instance's Prometheus have permissions to scrape the executor compute resources. As outlined in [how to configure observability](https://docs.sourcegraph.com/admin/deploy_executors#aws-1), the `instance_scraper_access_key_id` and `instance_scraper_access_secret_key` values provided by running this module must be supplied to the Sourcegraph Prometheus instance.

modules/docker-mirror/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Docker mirror module
2+
3+
This module provides a hosted Docker registry pull-through cache to be used by [Sourcegraph executor](https://docs.sourcegraph.com/admin/executors). It is strongly recommended to deploy a Docker mirror as a cache to reduce rate limiting by the public [Docker Hub registry](https://hub.docker.com/). We have also seen deploying a Docker mirror in the same physical zone as the executors significantly decreased latencies during image pulls.
4+
5+
When using the sibling [executors module](https://registry.terraform.io/modules/sourcegraph/executors/aws/latest/submodules/executors), the `vpc_id` and `subnet_id` values must match and the executor module `docker_registry_mirror` value should match `"http://${static_ip}:5000"`.

modules/executors/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Executors module
2+
3+
This module provides the resources to provision [Sourcegraph executor](https://docs.sourcegraph.com/admin/executors) compute resources on AWS. For a high-level overview of the resources deployed by this module, see the [root module](https://registry.terraform.io/modules/sourcegraph/executors/aws/latest). This module includes the following resources:
4+
5+
- AWS launch template
6+
- AWS autoscaler and autoscaling policy
7+
- CloudWatch log group
8+
- CloudWatch metric alarms
9+
- Security groups and IAM role policy attachments
10+
11+
This module does **not** automatically create networking or Docker mirror resources. The `vpc_id`, `subnet_id`, and `docker_registry_mirror` variables must be supplied explicitly with resources that have been previously created.
12+
13+
This module is often used with the sibling modules that create [networking](https://registry.terraform.io/modules/sourcegraph/executors/aws/latest/submodules/networking) and [Docker mirror](https://registry.terraform.io/modules/sourcegraph/executors/aws/latest/submodules/docker-mirror) resources which can be shared by multiple instances of the executor module (listening to different queues or being deployed in a different environment).

modules/networking/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Networking module
2+
3+
This module provides the networking glue between the sibling [executors](https://registry.terraform.io/modules/sourcegraph/executors/aws/latest/submodules/executors) and [docker-mirror](https://registry.terraform.io/modules/sourcegraph/executors/aws/latest/submodules/docker-mirror) modules.
4+
5+
_(There's very little to talk about in here.)_

variables.tf

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,3 @@ variable "executor_metrics_environment_label" {
164164
type = string
165165
description = "The value for environment by which to filter the custom metrics."
166166
}
167-
168-
variable "executor_docker_registry_mirror" {
169-
type = string
170-
default = ""
171-
description = "A URL to a docker registry mirror to use (falling back to docker.io)."
172-
}

0 commit comments

Comments
 (0)