-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(examples): Added examples for Spot Event Plugin Deployment
Adds python and TS examples that create a farm that has the requirements to use Deadline's Spot Event Plugin.
- Loading branch information
Showing
30 changed files
with
1,923 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
examples/deadline/All-In-AWS-Infrastructure-SEP/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
# RFDK Sample Application - Deadline Spot Event Plugin | ||
|
||
This is a sample RFDK application that deploys the basic infrastructure for a Deadline render farm. This application is structured in tiers, each representing a CloudFormation stack. The tiers are: | ||
|
||
1. **Network Tier** - Foundational networking required by all components. | ||
1. **Security Tier** - Contains resources that keep the render farm secure (e.g. certificates). | ||
1. **Storage Tier** - Persistent storage (e.g. database, file system). | ||
1. **Service Tier** - Business logic (e.g. central server, licensing). | ||
|
||
Each deployment tier is deployed as a separate CloudFormation Stack, and is dependent upon the ones before it. | ||
The main benefit of this deployment structure is that the later tiers can be brought down (i.e. stacks destroyed) | ||
to save costs while keeping the earlier tiers. For instance, we could destroy the Service & Compute tiers to | ||
reduce the cost to maintain the farm when we know it will be idle while retaining all of our data; | ||
we could re-deploy the Service tierat a later date to restore service to exactly the same state we left it in. | ||
|
||
--- | ||
|
||
_**Note:** This application is an illustrative example to showcase some of the capabilities of the RFDK. **It is not intended to be used for production render farms**, which should be built with more consideration of the security and operational needs of the system._ | ||
|
||
--- | ||
|
||
## Architecture | ||
|
||
This sample application deploys a basic Deadline Render farm that is configured to use Deadlines [Spot Event Plugin](https://docs.thinkboxsoftware.com/products/deadline/10.1/1_User%20Manual/manual/event-spot.html). Below is a diagram of the architecture. | ||
|
||
``` | ||
+-----------------------------------------------------------------------------+ | ||
| | | ||
| Private Hosted Zone | | ||
| | | ||
| +-------------------------------------------------------------------------+ | | ||
| | | | | ||
| | VPC | | | ||
| | | | | ||
| | +------------------------------+ +-----------------------+ | | | ||
| | | | | | | | | ||
| | | Repository | | Render Queue | | | | ||
| | | +--------------> | | | | ||
| | | +----------+ +-------------+ | Backend | +-------------------+ | | | | ||
| | | | | | | | API | | | | | | | ||
| | | | Database | | File System | <--------------+ | RCS Fleet | | | | | ||
| | | | | | | | | | | | | | | ||
| | | +----------+ +-----+-------+ | | | +-------+ | | | | | ||
| | | | | | | | ALB | | | | | | ||
| | +------------------------------+ | | +---+---+ | | | | | ||
| | | | | | | | | | | ||
| | | | | +-----------+ | | | | | ||
| | |Mounts | | | | | | | | | | ||
| | |onto | | v v v | | | | | ||
| | | | | +-++ ++-+ | | | | | ||
| | +--------------+ | | | | ... | | | | | | | ||
| | | - | | +--+ +--+ | | | | | ||
| | | Bastion Host +---------------------> | | | | | | ||
| | | | Can connect to | +-------------------+ | | | | ||
| | +--------------+ +-----------------------+ | | | ||
| +-------------------------------------------------------------------------+ | | ||
+-----------------------------------------------------------------------------+ | ||
``` | ||
|
||
### Components | ||
|
||
All components in the render farm live within a [VPC](https://aws.amazon.com/vpc/), which is within a [Private Hosted Zone](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/hosted-zones-private.html). | ||
|
||
#### Repository | ||
|
||
The Repository component contains the database and file system that store persistent data used by Deadline. These resources are initialized by the Deadline Repository installer. The database can either be [MongoDB](https://www.mongodb.com/) or [Amazon DocumentDB](https://aws.amazon.com/documentdb/). | ||
|
||
#### Render Queue | ||
|
||
The Render Queue component contains the fleet of [Deadline Remote Connection Server](https://docs.thinkboxsoftware.com/products/deadline/10.1/1_User%20Manual/manual/remote-connection-server.html) instances behind an [Application Load Balancer](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/introduction.html). This acts as the central service for Deadline applications and is the only component that interacts with the Repository. When comparing this component to the "All in AWS Infrastructure - Basic" example it has been granted additional permissions in order to use the Spot Event Plugin. | ||
|
||
#### Bastion Host | ||
|
||
The Bastion Host is a `BastionHostLinux` construct that allows you to connect to the Render Queue if you would like to take a look at its state. It is not an essential component to the render farm, so it can be omitted without side effects, if desired. To connect to it, please refer to [Bastion Hosts CDK documentation](https://docs.aws.amazon.com/cdk/api/latest/docs/aws-ec2-readme.html#bastion-hosts). | ||
|
||
#### Spot Event Plugin Configurations | ||
|
||
The Spot Event plugin requires additional Roles for both Deadline's Resource Tracker and the Spot Workers that are created and a Security Group to allow your Spot workers the ability to access the Render Queue. | ||
|
||
## Best Practices | ||
|
||
### VPC Flow Logs | ||
We recommend enabling VPC Flow Logs for networks containing sensitive information. For example, in this application, we have enabled flow logs on the VPC created in the Network Tier. These logs capture information about the IP traffic going in and out of your VPC, which can be useful to detect malicious activity. For more information, see [VPC Flow Logs documentation](https://docs.aws.amazon.com/vpc/latest/userguide/flow-logs.html). | ||
|
||
### VPC Network ACLs | ||
|
||
Network ACLs act as a firewall for controlling traffic in or out of your VPC subnets. We recommend creating custom network ACLs on your VPC to restrict traffic so that only necessary traffic is allowed. The default network ACLs that are created with a new VPC allow all inbound and outbound traffic, whereas custom network ACLs deny all inbound and outbound traffic by default, unless rules are added that explicitly allow traffic. This is a security best-practice to help defend against malicious actions against your render farm. For more information, see [Network ACLs documentation](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-network-acls.html). | ||
|
||
## Prerequisites | ||
|
||
- The Spot Fleet Configuration requires an [Amazon Machine Image (AMI)](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AMIs.html) with the Deadline Worker application installed. This AMI must have Deadline Installed and should be configured to connect to your repository. For additional information on setting up your AMI please see the [Spot Event Plugin Documentation](https://docs.thinkboxsoftware.com/products/deadline/10.1/1_User%20Manual/manual/event-spot.html). | ||
- You have setup and configured the AWS CLI | ||
- Your AWS account already has CDK bootstrapped in the desired region by running `cdk bootstrap` | ||
- You must have NodeJS installed on your system | ||
- You must have Docker installed on your system | ||
- You must have Python 3.7+ installed on your system (Python app only) | ||
|
||
## Typescript | ||
|
||
[Continue to Typescript specific documentation.](ts/README.md) | ||
|
||
## Python | ||
|
||
[Continue to Python specific documentation.](python/README.md) |
12 changes: 12 additions & 0 deletions
12
examples/deadline/All-In-AWS-Infrastructure-SEP/python/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
*.swp | ||
package-lock.json | ||
__pycache__ | ||
.pytest_cache | ||
.env | ||
*.egg-info | ||
|
||
# CDK asset staging directory | ||
.cdk.staging | ||
cdk.out | ||
cdk.context.json | ||
stage |
79 changes: 79 additions & 0 deletions
79
examples/deadline/All-In-AWS-Infrastructure-SEP/python/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# RFDK Sample Application - Deadline Spot Event Plugin - Python | ||
|
||
## Overview | ||
[Back to overview](../README.md) | ||
|
||
## Instructions | ||
|
||
--- | ||
**NOTE** | ||
|
||
These instructions assume that your working directory is `examples/deadline/All-In-AWS-Infrastructure-SEP/python/` relative to the root of the AWS-RFDK package. | ||
|
||
--- | ||
|
||
1. Install the dependencies of the sample app: | ||
|
||
```bash | ||
pip install -r requirements.txt | ||
``` | ||
2. Create an EC2 key pair to give you SSH access to the render farm: | ||
|
||
```bash | ||
aws ec2 create-key-pair --key-name <key-name> | ||
``` | ||
3. Change the value of the `key_pair_name` variable in `package/config.py` to your value for `<key-name>` in the previous step: | ||
|
||
**Note:** Save the value of the `"KeyMaterial"` field as a file in a secure location. This is your private key that you can use to SSH into the render farm. | ||
|
||
```python | ||
self.key_pair_name: Optional[str] = '<your key pair name>' | ||
``` | ||
4. Choose the type of database you would like to deploy (AWS DocumentDB or MongoDB). | ||
If you would like to use MongoDB, you will need to accept the Mongo SSPL (see next step). | ||
Once you've decided on a database type, change the value of the `deploy_mongo_db` variable in `package/config.py` accordingly: | ||
```python | ||
# True = MongoDB, False = Amazon DocumentDB | ||
self.deploy_mongo_db: bool = False | ||
``` | ||
5. If you set `deploy_mongo_db` to `True`, then you must accept the [SSPL license](https://www.mongodb.com/licensing/server-side-public-license) to successfully deploy MongoDB. To do so, change the value of `accept_sspl_license` in `package/config.py`: | ||
```python | ||
# To accept the MongoDB SSPL, change from USER_REJECTS_SSPL to USER_ACCEPTS_SSPL | ||
self.accept_sspl_license: MongoDbSsplLicenseAcceptance = MongoDbSsplLicenseAcceptance.USER_REJECTS_SSPL | ||
``` | ||
6. Stage the Docker recipes for `RenderQueue`: | ||
```bash | ||
# Set this value to the version of RFDK your application targets | ||
RFDK_VERSION=<version_of_RFDK> | ||
# Set this value to the version of AWS Thinkbox Deadline you'd like to deploy to your farm. Deadline 10.1.9 and up are supported. | ||
RFDK_DEADLINE_VERSION=<version_of_deadline> | ||
|
||
npx --package=aws-rfdk@${RFDK_VERSION} stage-deadline \ | ||
--deadlineInstallerURI s3://thinkbox-installers/Deadline/${RFDK_DEADLINE_VERSION}/Linux/DeadlineClient-${RFDK_DEADLINE_VERSION}-linux-x64-installer.run \ | ||
--dockerRecipesURI s3://thinkbox-installers/DeadlineDocker/${RFDK_DEADLINE_VERSION}/DeadlineDocker-${RFDK_DEADLINE_VERSION}.tar.gz \ | ||
--output stage | ||
``` | ||
7. Deploy all the stacks in the sample app: | ||
```bash | ||
cdk deploy "*" | ||
``` | ||
8. Connect to your Render Farm and open up the Deadline Monitor. | ||
9. Configure the Spot event plugin by following the directions in the [Spot Event Plugin documentation](https://docs.thinkboxsoftware.com/products/deadline/10.1/1_User%20Manual/manual/event-spot.html) with the following considerations: | ||
Use the default security credentials by using turning "Use Local Credentials" to False and leaving both "Access Key ID" and "Secret Access Key" blank. | ||
Ensure that the Region your Spot workers will be launched in is the same region as your CDK application. | ||
When Creating your Spot Fleet Requests, set the IAM instance profile to "DeadlineSpotWorkerRole" and set the security group to "DeadlineSpotSecurityGroup". | ||
Configure your instances to connect to the Render Queue by either creating your AMI after launching your app and preconfiguring the AMI or by setting up a userdata in the Spot Fleet Request. (see the Spot Event Plugin documentation for additional information on configuring this connection.) | ||
10. Once you are finished with the sample app, you can tear it down by running: | ||
```bash | ||
cdk destroy "*" | ||
``` |
3 changes: 3 additions & 0 deletions
3
examples/deadline/All-In-AWS-Infrastructure-SEP/python/cdk.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"app": "python -m package.app" | ||
} |
Empty file.
105 changes: 105 additions & 0 deletions
105
examples/deadline/All-In-AWS-Infrastructure-SEP/python/package/app.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import os | ||
|
||
from aws_cdk.core import ( | ||
App, | ||
Environment | ||
) | ||
from aws_cdk.aws_ec2 import ( | ||
InstanceClass, | ||
InstanceSize, | ||
InstanceType, | ||
MachineImage | ||
) | ||
|
||
from .lib import ( | ||
network_tier, | ||
security_tier, | ||
storage_tier, | ||
service_tier | ||
) | ||
|
||
from .config import config | ||
|
||
|
||
def main(): | ||
# ------------------------------ | ||
# Validate Config Values | ||
# ------------------------------ | ||
|
||
if not config.key_pair_name: | ||
print('EC2 key pair name not specified. You will not have SSH access to the render farm.') | ||
|
||
# ------------------------------ | ||
# Application | ||
# ------------------------------ | ||
app = App() | ||
|
||
if 'CDK_DEPLOY_ACCOUNT' not in os.environ and 'CDK_DEFAULT_ACCOUNT' not in os.environ: | ||
raise ValueError('You must define either CDK_DEPLOY_ACCOUNT or CDK_DEFAULT_ACCOUNT in the environment.') | ||
if 'CDK_DEPLOY_REGION' not in os.environ and 'CDK_DEFAULT_REGION' not in os.environ: | ||
raise ValueError('You must define either CDK_DEPLOY_REGION or CDK_DEFAULT_REGION in the environment.') | ||
env = Environment( | ||
account=os.environ.get('CDK_DEPLOY_ACCOUNT', os.environ.get('CDK_DEFAULT_ACCOUNT')), | ||
region=os.environ.get('CDK_DEPLOY_REGION', os.environ.get('CDK_DEFAULT_REGION')) | ||
) | ||
|
||
# ------------------------------ | ||
# Network Tier | ||
# ------------------------------ | ||
network = network_tier.NetworkTier( | ||
app, | ||
'NetworkTier', | ||
env=env | ||
) | ||
|
||
# ------------------------------ | ||
# Security Tier | ||
# ------------------------------ | ||
security = security_tier.SecurityTier( | ||
app, | ||
'SecurityTier', | ||
env=env | ||
) | ||
|
||
# ------------------------------ | ||
# Storage Tier | ||
# ------------------------------ | ||
if config.deploy_mongo_db: | ||
storage_props = storage_tier.StorageTierMongoDBProps( | ||
vpc=network.vpc, | ||
database_instance_type=InstanceType.of(InstanceClass.MEMORY5, InstanceSize.LARGE), | ||
root_ca=security.root_ca, | ||
dns_zone=network.dns_zone, | ||
accept_sspl_license=config.accept_sspl_license, | ||
key_pair_name=config.key_pair_name | ||
) | ||
storage = storage_tier.StorageTierMongoDB(app, 'StorageTier', props=storage_props, env=env) | ||
else: | ||
storage_props = storage_tier.StorageTierDocDBProps( | ||
vpc=network.vpc, | ||
database_instance_type=InstanceType.of(InstanceClass.MEMORY5, InstanceSize.LARGE), | ||
) | ||
storage = storage_tier.StorageTierDocDB(app, 'StorageTier', props=storage_props, env=env) | ||
|
||
# ------------------------------ | ||
# Service Tier | ||
# ------------------------------ | ||
service_props = service_tier.ServiceTierProps( | ||
database=storage.database, | ||
file_system=storage.file_system, | ||
vpc=network.vpc, | ||
docker_recipes_stage_path=os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir, 'stage'), | ||
dns_zone=network.dns_zone | ||
) | ||
service = service_tier.ServiceTier(app, 'ServiceTier', props=service_props, env=env) | ||
|
||
app.synth() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
32 changes: 32 additions & 0 deletions
32
examples/deadline/All-In-AWS-Infrastructure-SEP/python/package/config.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from typing import ( | ||
Optional | ||
) | ||
|
||
from aws_rfdk import MongoDbSsplLicenseAcceptance | ||
|
||
class AppConfig: | ||
""" | ||
Configuration values for the sample app. | ||
TODO: Fill these in with your own values. | ||
""" | ||
def __init__(self): | ||
|
||
# (Optional) The name of the EC2 keypair to associate with the instances. | ||
self.key_pair_name: Optional[str] = None | ||
|
||
# Whether to use MongoDB to back the render farm. | ||
# If false, then we use Amazon DocumentDB to back the render farm. | ||
self.deploy_mongo_db: bool = False | ||
|
||
# This is only relevant if deploy_mongo_db is True. | ||
# | ||
# Change this value to MongoDbSsplLicenseAcceptance.USER_ACCEPTS_SSPL | ||
# if you wish to accept the SSPL and proceed with MongoDB deployment. | ||
self.accept_sspl_license: MongoDbSsplLicenseAcceptance = MongoDbSsplLicenseAcceptance.USER_REJECTS_SSPL | ||
|
||
|
||
config: AppConfig = AppConfig() |
Empty file.
Oops, something went wrong.