Deploy the Automations
Each automation has two bundles in massdriver-automations:
| Bundle | Runs on | Dependencies |
|---|---|---|
massdriver-<automation> | A Kubernetes cluster with an ingress controller | massdriver-kubernetes-cluster, massdriver-service-account |
massdriver-<automation>-ecs | Amazon ECS with Fargate, behind an Application Load Balancer | aws-iam-role, aws-ecs-cluster, massdriver-service-account |
Each bundle runs one automation and creates the event destination that sends it only the events it uses. Deploy one instance per automation, each with its own service account that has only that automation's permissions.
The bundles are generated by scripts/bundles.py. Each -ecs bundle has an operator guide, operator.md, with the instance's host, logs, and troubleshooting steps.
Get the bundles​
From the AWS catalog​
The AWS catalog vendors every -ecs bundle with scripts/sync-automation-bundles.sh. Publishing the catalog publishes them. The catalog's copies differ from upstream:
- The dependencies are pinned to the catalog's types:
aws-iam-role@0.0.0,aws-ecs-cluster@0.0.0,massdriver-service-account@~0.1, andwebsite@~0.1. - Checkov halts deployments to instances whose environment is
prodorproduction. - The Development and Production presets use the image tag
latest.
From massdriver-automations​
Publish the resource types a bundle uses before you publish the bundle:
| Type | Used by | Source |
|---|---|---|
massdriver-service-account | Every bundle | Official, in massdriver-resource-types |
massdriver-kubernetes-cluster | Kubernetes bundles | Official, in massdriver-resource-types |
aws-iam-role | -ecs bundles | The AWS credential type of the AWS catalog or massdriver-catalog, or your own |
aws-ecs-cluster | -ecs bundles | Example in examples/resource-types/aws-ecs-cluster |
website | statuspage and cost-explorer bundles | Example in examples/resource-types/website |
Install the official types. The example types are not official. Publish them as they are, or change them and the bundles to match your organization:
git clone https://github.com/massdriver-cloud/massdriver-automations.git
cd massdriver-automations
for type in website aws-ecs-cluster; do
mass resource-type create "$type"
mass resource-type publish "examples/resource-types/$type"
done
Then build and publish each automation's bundle:
cd bundles/massdriver-drift # massdriver-drift-ecs for ECS
mass bundle build
mass bundle publish
Service account​
A deployment cannot create event destinations, so each bundle depends on a massdriver-service-account resource. The bundle creates the event destination with it, and the automation calls the Massdriver API with it as MASSDRIVER_URL, MASSDRIVER_ORGANIZATION_ID, and MASSDRIVER_API_KEY.
Create one service account per automation. Each needs organization:manageEventDestinations, plus the permissions on its automation's page. Automations that write results to the stash also need stash:write. Refer to Access control for each action.
Connect the service account to the one instance with a remote reference, so no other instance in the environment resolves it:
mass resource grant create <service-account-resource-id> --condition md-project=automations
mass instance remote-reference set automations-main-drift service_account <service-account-resource-id>
Requirements​
Every bundle needs TLS on its host. Massdriver and Slack send requests to https:// URLs only.
Kubernetes​
- A
massdriver-kubernetes-clusterresource. The bundle deploys into the namespace of that resource, ordefaultwhen it has none. It does not create the namespace. - An ingress controller, and a DNS record for the host that points at it.
- A cert-manager ClusterIssuer, a TLS secret with a certificate for the host, or TLS that ends in front of the ingress controller.
Amazon ECS​
- An
aws-iam-roleresource. Witharnand an optionalexternal_id, the role trusts Massdriver's AWS account. Witharnandtoken_level, the role trusts the deployment's identity token of that level. - An
aws-ecs-clusterresource: the cluster, its load balancer and listener, the VPC with private subnets, and an optional DNS zone. - An HTTPS listener with a certificate for the host.
- Private subnets that reach the internet, so tasks can pull images and call the Massdriver API, Slack, GitHub, and the other services in their settings.
Params​
| Param | Default | |
|---|---|---|
| Image > Repository | ghcr.io/massdriver-cloud/massdriver-automations | bundle-scanner adds -scanner to the tag, and router adds -scripts when it runs commands. |
| Image > Tag | 0.3 | A moving tag, such as 0.3 or latest, restarts the automation on the image the tag names at each deploy. Pin a version, such as 0.3.0, to run the same code on every deploy. |
| Ingress > Host | Kubernetes: required. ECS: <automation>.<domain of the cluster's DNS zone>. | Massdriver sends events to https://<host>/hooks/massdriver. |
| Ingress > Ingress class | The cluster's default | Kubernetes only. |
| Ingress > cert-manager ClusterIssuer | Kubernetes only. Issues a certificate for the host. | |
| Ingress > TLS secret | Kubernetes only. A Secret in the namespace with a certificate for the host. Ignored when a ClusterIssuer is set. | |
| Ingress > Create a DNS record | On | ECS only. Creates a CNAME to the load balancer when the host is in the cluster's DNS zone. |
| Logs > Retention (days) | 90 | ECS only. The Development preset sets 7 and the Production preset 365. |
| Settings | The automation's config file. A setting left empty uses the automation's default. | |
| Event attributes | On automations whose events carry attributes. Adds an attribute filter to the event destination, such as md-environment = prod. | |
| State storage (GiB) | 1 | Kubernetes only, for cost-explorer, drift, freeze-guard, statuspage, and upgrade-train. Cannot change after the first deploy. |
| Tracing > OTLP endpoint | The OTLP/HTTP base URL of a collector. Empty turns tracing off. Set the OTEL_EXPORTER_OTLP_HEADERS secret when the collector needs credentials. |
An attribute value with commas, such as api, web, matches any of its values wherever the config file accepts a list.
Set each automation's secrets on its instance. The secrets are on the automation's page.
What the bundle creates​
| Kubernetes | Amazon ECS | |
|---|---|---|
| Workload | A Deployment with one replica | An ECS service with one Fargate task (ARM64). An init container writes the config file, and router's Scripts, to task volumes. |
| Settings | A ConfigMap with the config file, and a Secret with the environment variables | A Secrets Manager secret with the secret environment variables |
| Routing | A Service, and an Ingress for the host that sends every path to the automation | A target group with a health check on /healthz, a rule for the host on the cluster's HTTPS listener, and, with Create a DNS record, a CNAME record |
| State, for cost-explorer, drift, freeze-guard, statuspage, and upgrade-train | A PersistentVolumeClaim for STATE_DIR | An EFS file system and an access point for STATE_DIR, with a task role that can mount only that access point |
| Logs | Container logs | A CloudWatch log group |
| Event destination | Named for the instance, sending to https://<host>/hooks/massdriver | The same |
The destination's signing secret goes to the automation as MASSDRIVER_SIGNING_SECRET.
On Kubernetes, statuspage with an output directory gets a second claim, <instance>-site, mounted at that directory, and router gets a ConfigMap with its Scripts, mounted as executables in /scripts.
On ECS, the instance also gets a KMS key for the secret and the logs. The task execution role can read only that secret and write only that log group. audit-archiver with an S3 bucket and no AWS key secrets gets a task role that can write to the bucket. stash-sync with CloudWatch rules or presets and no AWS key secrets gets a task role that can call cloudwatch:GetMetricData and cloudwatch:DescribeAlarms. On Kubernetes, both read AWS credentials from the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY secrets.
statuspage and cost-explorer produce a website resource with the URL to open. The other bundles produce no resources.
Limits​
- Each automation runs one replica and restarts on every change of its settings. It keeps its queues and repeated event ids in memory, and a restart loses them. Massdriver sends the events that fail during a restart again.
- router runs the
<tag>-scriptsimage when a route has anexecstep or Scripts has a file. That image hassh,jq,curl, andpython3. For other tools, build an image from it, push it with the same-scriptstag to your own registry, and set Image > Repository. On ECS, the image needs an ARM64 variant. - On ECS, a task definition holds at most 64 KiB, which includes the config file and router's Scripts.
- Resource sizes are fixed. Kubernetes: requests of 25m CPU and 64Mi memory, limits of 500m and 256Mi; bundle-scanner 250m and 512Mi, up to 2 CPUs and 2Gi. ECS: 0.25 vCPU and 512 MiB; bundle-scanner 1 vCPU and 2 GiB.