Move CloudFormation template to contrib

Signed-off-by: Maksym Pavlenko <makpav@amazon.com>
This commit is contained in:
Maksym Pavlenko
2019-04-01 13:34:48 -07:00
parent 515be73c82
commit d9526f5c4f
2 changed files with 0 additions and 0 deletions

View File

@@ -1,144 +0,0 @@
AWSTemplateFormatVersion: "2010-09-09"
Description: >
This templates spin ups an EC2 instance with EBS volumes suitable for containerd snapshotters benchmarking.
The template will create EBS volumes for benchmarking (/dev/sdb, /dev/sdc, and /dev/sdd) with same performance characteristics.
/dev/sde volume will be created and used for device mapper thin-pool device.
Parameters:
Key:
Type: AWS::EC2::KeyPair::KeyName
Description: SSH key to use
AMI:
Type: AWS::EC2::Image::Id
Description: AMI ID to use for the EC2 instance. Must be Amazon Linux 2.
Default: "ami-032509850cf9ee54e"
SecurityGroups:
Type: List<AWS::EC2::SecurityGroup::Id>
Description: List of security groups to add to EC2 instance
InstanceType:
Type: String
Default: m4.xlarge
Description: EC2 instance type to use
VolumesIOPS:
Type: Number
Default: 1000
MinValue: 100
MaxValue: 20000
Description: The number of I/O operations per second (IOPS) to reserve for EBS volumes.
VolumesSize:
Type: Number
Default: 20
MinValue: 4
MaxValue: 16384
Description: EBS volumes size, in gibibytes (GiB)
VolumeType:
Type: String
Default: io1
AllowedValues:
- io1
- gp2
- sc1
- st1
Description: >
Volume type to use for EBS volumes (io1 is recommended).
More information on volume types https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSVolumeTypes.html
ContainerStorageSetup:
Type: String
Default: https://github.com/projectatomic/container-storage-setup/archive/v0.6.0.tar.gz
Description: container-storage-setup tool version to install (more details at https://github.com/projectatomic/container-storage-setup)
Resources:
Instance:
Type: AWS::EC2::Instance
Properties:
EbsOptimized: true
InstanceType: !Ref InstanceType
KeyName: !Ref Key
ImageId: !Ref AMI
SecurityGroupIds: !Ref SecurityGroups
BlockDeviceMappings:
- DeviceName: "/dev/xvda" # Root volume
Ebs:
VolumeSize: 64
VolumeType: io1
Iops: 1000
DeleteOnTermination: true
- DeviceName: "/dev/sdb"
Ebs:
VolumeSize: !Ref VolumesSize
VolumeType: !Ref VolumeType
Iops: !Ref VolumesIOPS
DeleteOnTermination: true
- DeviceName: "/dev/sdc"
Ebs:
VolumeSize: !Ref VolumesSize
VolumeType: !Ref VolumeType
Iops: !Ref VolumesIOPS
DeleteOnTermination: true
- DeviceName: "/dev/sdd"
Ebs:
VolumeSize: !Ref VolumesSize
VolumeType: !Ref VolumeType
Iops: !Ref VolumesIOPS
DeleteOnTermination: true
- DeviceName: "/dev/sde"
Ebs:
VolumeSize: !Ref VolumesSize
VolumeType: !Ref VolumeType
Iops: !Ref VolumesIOPS
DeleteOnTermination: true
UserData:
Fn::Base64:
!Sub |
#!/bin/bash
set -ex
yum install -y \
gcc \
git \
btrfs-progs-devel \
libseccomp-devel
amazon-linux-extras install -y golang1.11
# Install container-storage-setup
mkdir -p /tmp/container-storage-setup/unpacked/
cd /tmp/container-storage-setup/
curl -sL ${ContainerStorageSetup} -o archive.tar.gz
tar -xzf archive.tar.gz -C unpacked --strip 1
cd unpacked/
make install-core
rm -rf /tmp/container-storage-setup/
# Prepare EBS volumes
mkdir -p /mnt/{disk1,disk2,disk3}
mkfs.ext4 /dev/sdb
mount /dev/sdb /mnt/disk1/
mkfs.ext4 /dev/sdc
mount /dev/sdc /mnt/disk2/
mkfs.ext4 /dev/sdd
mount /dev/sdd /mnt/disk3
chgrp -R wheel /mnt/disk1/ /mnt/disk2/ /mnt/disk3/
chmod -R 2775 /mnt/disk1/ /mnt/disk2/ /mnt/disk3/
# Prepare thin-pool device
touch /etc/sysconfig/docker-storage-setup
echo DEVS=/dev/sde >> /etc/sysconfig/docker-storage-setup
echo VG=bench >> /etc/sysconfig/docker-storage-setup
container-storage-setup
echo "Done"

View File

@@ -1,83 +0,0 @@
## Requirements
### Running
Due to its dependency on `dmsetup`, executing the snapshotter process in an environment where a udev
daemon is not accessible (such as a container) may result in unexpected behavior. In this case, try executing the
snapshotter with the `DM_DISABLE_UDEV=1` environment variable, which tells `dmsetup` to ignore udev and manage devices
itself. See [lvm(8)](http://man7.org/linux/man-pages/man8/lvm.8.html) and
[dmsetup(8)](http://man7.org/linux/man-pages/man8/dmsetup.8.html) for more information.
## How to run snapshotters benchmark
- `containerd` project contains AWS CloudFormation template to run an EC2 instance suitable for benchmarking.
It installs dependencies, prepares EBS volumes with same performance characteristics, and creates thin-pool device.
You can make stack with the following command (note: there is a charge for using AWS resources):
```bash
aws cloudformation create-stack \
--stack-name benchmark-instance \
--template-body file://benchmark_aws.yml \
--parameters \
ParameterKey=Key,ParameterValue=SSH_KEY \
ParameterKey=SecurityGroups,ParameterValue=sg-XXXXXXXX \
ParameterKey=VolumesSize,ParameterValue=20 \
ParameterKey=VolumesIOPS,ParameterValue=1000
```
- You can find an IP address of newly created EC2 instance in AWS Console or via AWS CLI:
```bash
$ aws ec2 describe-instances \
--instance-ids $(aws cloudformation describe-stack-resources --stack-name benchmark-instance --query 'StackResources[*].PhysicalResourceId' --output text) \
--query 'Reservations[*].Instances[*].PublicIpAddress' \
--output text
```
- SSH to an instance and prepare `containerd`:
```bash
ssh -i SSH_KEY ec2-user@IP
mkdir /mnt/disk1/data /mnt/disk2/data /mnt/disk3/data
go get github.com/containerd/containerd
cd $(go env GOPATH)/src/github.com/containerd/containerd
make
```
- Now you're ready to run the benchmark:
```bash
sudo su -
cd snapshots/testsuite/
go test -bench . \
-dm.thinPoolDev=bench-docker--pool \
-dm.rootPath=/mnt/disk1/data \
-overlay.rootPath=/mnt/disk2/data \
-native.rootPath=/mnt/disk3/data
```
- The output will look like:
```bash
goos: linux
goarch: amd64
pkg: github.com/containerd/containerd/snapshots/testsuite
BenchmarkOverlay/run-4 1 1019730210 ns/op 164.53 MB/s
BenchmarkOverlay/prepare 1 26799447 ns/op
BenchmarkOverlay/write 1 968200363 ns/op
BenchmarkOverlay/commit 1 24582560 ns/op
BenchmarkDeviceMapper/run-4 1 3139232730 ns/op 53.44 MB/s
BenchmarkDeviceMapper/prepare 1 1758640440 ns/op
BenchmarkDeviceMapper/write 1 1356705388 ns/op
BenchmarkDeviceMapper/commit 1 23720367 ns/op
PASS
ok github.com/containerd/containerd/snapshots/testsuite 185.204s
```
- Don't forget to tear down the stack so it does not continue to incur charges:
```bash
aws cloudformation delete-stack --stack-name benchmark-instance
```