Skip to content

Commit 7231c70

Browse files
Added 4 and 8 m7a setups (#114)
* Added default key to rts deployments * Added default key to rts deployments * Removed hcl spurious lock file * Removed hcl spurious lock file * Added simple 2 nodes setup (1DB with HA enabled) * Updated base image from redis 7.1 to 7.4.0 * RediSearch spot instance should also use it * Increased volume size of spot instance * Added 4 and 8 m7a setups --------- Co-authored-by: filipecosta90 <[email protected]>
1 parent 8217249 commit 7231c70

File tree

12 files changed

+580
-0
lines changed

12 files changed

+580
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
################################################################################
3+
# This is the bucket holding this specific setup tfstate
4+
################################################################################
5+
terraform {
6+
backend "s3" {
7+
bucket = "performance-cto-group"
8+
region = "us-east-1"
9+
key = "benchmarks/infrastructure/jammy-22.04-amd64-server-20250305-m7a.2xlarge.tfstate"
10+
}
11+
}
12+
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
2+
resource "aws_instance" "server_2a" {
3+
count = var.instance_count
4+
ami = var.instance_ami
5+
instance_type = var.server_instance_type
6+
subnet_id = data.terraform_remote_state.shared_resources.outputs.subnet_public_id
7+
vpc_security_group_ids = ["${data.terraform_remote_state.shared_resources.outputs.performance_cto_sg_id}"]
8+
key_name = var.key_name
9+
availability_zone = "us-east-2a"
10+
placement_group = "perf-cto-pg"
11+
12+
root_block_device {
13+
volume_size = var.instance_volume_size
14+
volume_type = var.instance_volume_type
15+
encrypted = var.instance_volume_encrypted
16+
delete_on_termination = true
17+
}
18+
19+
volume_tags = {
20+
Environment = "${var.environment}"
21+
Project = "${var.environment}"
22+
Name = "ebs_block_device-${var.setup_name}-DB-us-east-2a-${count.index + 1}"
23+
setup = "${var.setup_name}"
24+
triggering_env = "${var.triggering_env}"
25+
github_actor = "${var.github_actor}"
26+
github_org = "${var.github_org}"
27+
github_repo = "${var.github_repo}"
28+
github_sha = "${var.github_sha}"
29+
}
30+
31+
tags = {
32+
Environment = "${var.environment}"
33+
Project = "${var.environment}"
34+
Name = "${var.setup_name}-DB-us-east-2a-${count.index + 1}"
35+
setup = "${var.setup_name}"
36+
triggering_env = "${var.triggering_env}"
37+
github_actor = "${var.github_actor}"
38+
github_org = "${var.github_org}"
39+
github_repo = "${var.github_repo}"
40+
github_sha = "${var.github_sha}"
41+
}
42+
43+
################################################################################
44+
# This will ensure we wait here until the instance is ready to receive the ssh connection
45+
################################################################################
46+
provisioner "remote-exec" {
47+
script = "./../scripts/wait_for_instance.sh"
48+
connection {
49+
host = self.public_ip # The `self` variable is like `this` in many programming languages
50+
type = "ssh" # in this case, `self` is the resource (the server).
51+
user = var.ssh_user
52+
private_key = file(var.private_key)
53+
#need to increase timeout to larger then 5m for metal instances
54+
timeout = "5m"
55+
agent = "false"
56+
}
57+
}
58+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
output "server_public_ip" {
2+
value = aws_instance.server_2a[*].public_ip
3+
}
4+
5+
output "server_private_ip" {
6+
value = aws_instance.server_2a[*].private_ip
7+
}
8+
9+
output "server_instance_type" {
10+
value = var.server_instance_type
11+
}
12+
13+
14+
output "pem" {
15+
value = var.private_key
16+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import subprocess
2+
import json
3+
4+
# Run the "terraform output json" command
5+
output = subprocess.run(["terraform", "output", "-json"], stdout=subprocess.PIPE)
6+
7+
output_json = json.loads(output.stdout.decode())
8+
total_nodes = len(output_json["server_private_ip"]["value"])
9+
server_instance_type = output_json["server_instance_type"]["value"].replace(".", "-")
10+
pem = output_json["pem"]["value"]
11+
12+
13+
print("#!/bin/bash\n")
14+
print("TOTAL_NODES={}\n".format(total_nodes))
15+
print("PEM={}\n".format(pem))
16+
17+
print(f'CLUSTER_NAME="{server_instance_type}-{total_nodes}nodes"\n')
18+
19+
print("\n#internal IP addresses")
20+
cleaned_json = {}
21+
for keyn, v in enumerate(output_json["server_private_ip"]["value"], start=1):
22+
print("B_M{}_I={}".format(keyn, v))
23+
24+
print("\n#external IP addresses")
25+
for keyn, v in enumerate(output_json["server_public_ip"]["value"], start=1):
26+
print("B_M{}_E={}".format(keyn, v))
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# provider
2+
provider "aws" {
3+
region = var.region
4+
}
5+
6+
################################################################################
7+
# This is the shared resources bucket key -- you will need it across environments like security rules,etc...
8+
# !! do not change this !!
9+
################################################################################
10+
data "terraform_remote_state" "shared_resources" {
11+
backend = "s3"
12+
config = {
13+
bucket = "performance-cto-group"
14+
key = "benchmarks/infrastructure/shared_resources.tfstate"
15+
region = "us-east-1"
16+
}
17+
}
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
################################################################################
2+
# Variables used for deployment tag
3+
################################################################################
4+
5+
variable "setup_name" {
6+
description = "setup name"
7+
default = "jammy-22.04-amd64-server-20250305-m7a.2xlarge"
8+
}
9+
10+
variable "github_actor" {
11+
description = "The name of the person or app that initiated the deployment."
12+
default = "N/A"
13+
}
14+
15+
variable "github_repo" {
16+
description = " The owner and repository name. For example, testing-infrastructure."
17+
default = "N/A"
18+
}
19+
20+
variable "triggering_env" {
21+
description = " The triggering environment. For example circleci."
22+
default = "N/A"
23+
}
24+
25+
variable "environment" {
26+
description = " The cost tag."
27+
default = "small-instances"
28+
}
29+
30+
variable "github_org" {
31+
description = " The owner name. For example, RedisModules."
32+
default = "N/A"
33+
}
34+
35+
variable "github_sha" {
36+
description = "The commit SHA that triggered the deployment."
37+
default = "N/A"
38+
}
39+
40+
variable "timeout_secs" {
41+
description = "The maximum time to wait prior destroying the VM via the watchdog."
42+
default = "3600"
43+
}
44+
45+
46+
47+
################################################################################
48+
# Access keys
49+
################################################################################
50+
variable "private_key" {
51+
description = "private key"
52+
default = "/tmp/benchmarks.redislabs.pem"
53+
}
54+
55+
variable "key_name" {
56+
description = "key name"
57+
default = "perf-cto-us-east-2"
58+
}
59+
60+
variable "region" {
61+
default = "us-east-2"
62+
}
63+
64+
# Canonical, Ubuntu, 22.04 LTS, amd64 focal image build on 20250305
65+
variable "instance_ami" {
66+
description = "AMI for aws EC2 instance - us-east-2 Ubuntu 22.04 - amd64"
67+
default = "ami-0c3b809fcf2445b6a"
68+
}
69+
70+
variable "instance_device_name" {
71+
description = "EC2 instance device name"
72+
default = "/dev/sda1"
73+
}
74+
75+
variable "redis_module" {
76+
description = "redis_module"
77+
default = "N/A"
78+
}
79+
80+
variable "instance_volume_size" {
81+
description = "EC2 instance volume_size"
82+
default = "256"
83+
}
84+
85+
variable "instance_volume_type" {
86+
description = "EC2 instance volume_type"
87+
default = "gp3"
88+
}
89+
90+
91+
variable "instance_volume_iops" {
92+
description = "EC2 instance volume_iops"
93+
default = "3000"
94+
}
95+
96+
variable "client_instance_volume_size" {
97+
description = "EC2 instance volume_size"
98+
default = "256"
99+
}
100+
101+
variable "client_instance_volume_type" {
102+
description = "EC2 instance volume_type"
103+
default = "gp3"
104+
}
105+
106+
107+
variable "instance_volume_encrypted" {
108+
description = "EC2 instance instance_volume_encrypted"
109+
default = "false"
110+
}
111+
112+
variable "instance_root_block_device_encrypted" {
113+
description = "EC2 instance instance_root_block_device_encrypted"
114+
default = "false"
115+
}
116+
117+
118+
variable "instance_count" {
119+
description = ""
120+
default = 2
121+
}
122+
123+
124+
variable "instance_cpu_threads_per_core" {
125+
description = "CPU threads per core for aws EC2 instance"
126+
default = 1
127+
}
128+
129+
variable "instance_cpu_threads_per_core_hyperthreading" {
130+
description = "CPU threads per core when hyperthreading is enabled for aws EC2 instance"
131+
default = 2
132+
}
133+
134+
variable "instance_network_interface_plus_count" {
135+
description = "number of additional network interfaces to add to aws EC2 instance"
136+
default = 0
137+
}
138+
139+
variable "os" {
140+
description = "os"
141+
default = "ubuntu22.04"
142+
}
143+
144+
variable "ssh_user" {
145+
description = "ssh_user"
146+
default = "ubuntu"
147+
}
148+
149+
################################################################################
150+
# Specific DB machine variables
151+
################################################################################
152+
# m7i.large 2 VCPUs 8 GB MEM
153+
variable "server_instance_type" {
154+
description = "type for aws EC2 instance"
155+
default = "m7a.2xlarge"
156+
}
157+
158+
variable "server_instance_cpu_core_count" {
159+
description = "CPU core count for aws EC2 instance"
160+
default = 2
161+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
################################################################################
3+
# This is the bucket holding this specific setup tfstate
4+
################################################################################
5+
terraform {
6+
backend "s3" {
7+
bucket = "performance-cto-group"
8+
region = "us-east-1"
9+
key = "benchmarks/infrastructure/jammy-22.04-amd64-server-20250305-m7a.xlarge.tfstate"
10+
}
11+
}
12+
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
2+
resource "aws_instance" "server_2a" {
3+
count = var.instance_count
4+
ami = var.instance_ami
5+
instance_type = var.server_instance_type
6+
subnet_id = data.terraform_remote_state.shared_resources.outputs.subnet_public_id
7+
vpc_security_group_ids = ["${data.terraform_remote_state.shared_resources.outputs.performance_cto_sg_id}"]
8+
key_name = var.key_name
9+
availability_zone = "us-east-2a"
10+
placement_group = "perf-cto-pg"
11+
12+
root_block_device {
13+
volume_size = var.instance_volume_size
14+
volume_type = var.instance_volume_type
15+
encrypted = var.instance_volume_encrypted
16+
delete_on_termination = true
17+
}
18+
19+
volume_tags = {
20+
Environment = "${var.environment}"
21+
Project = "${var.environment}"
22+
Name = "ebs_block_device-${var.setup_name}-DB-us-east-2a-${count.index + 1}"
23+
setup = "${var.setup_name}"
24+
triggering_env = "${var.triggering_env}"
25+
github_actor = "${var.github_actor}"
26+
github_org = "${var.github_org}"
27+
github_repo = "${var.github_repo}"
28+
github_sha = "${var.github_sha}"
29+
}
30+
31+
tags = {
32+
Environment = "${var.environment}"
33+
Project = "${var.environment}"
34+
Name = "${var.setup_name}-DB-us-east-2a-${count.index + 1}"
35+
setup = "${var.setup_name}"
36+
triggering_env = "${var.triggering_env}"
37+
github_actor = "${var.github_actor}"
38+
github_org = "${var.github_org}"
39+
github_repo = "${var.github_repo}"
40+
github_sha = "${var.github_sha}"
41+
}
42+
43+
################################################################################
44+
# This will ensure we wait here until the instance is ready to receive the ssh connection
45+
################################################################################
46+
provisioner "remote-exec" {
47+
script = "./../scripts/wait_for_instance.sh"
48+
connection {
49+
host = self.public_ip # The `self` variable is like `this` in many programming languages
50+
type = "ssh" # in this case, `self` is the resource (the server).
51+
user = var.ssh_user
52+
private_key = file(var.private_key)
53+
#need to increase timeout to larger then 5m for metal instances
54+
timeout = "5m"
55+
agent = "false"
56+
}
57+
}
58+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
output "server_public_ip" {
2+
value = aws_instance.server_2a[*].public_ip
3+
}
4+
5+
output "server_private_ip" {
6+
value = aws_instance.server_2a[*].private_ip
7+
}
8+
9+
output "server_instance_type" {
10+
value = var.server_instance_type
11+
}
12+
13+
14+
output "pem" {
15+
value = var.private_key
16+
}

0 commit comments

Comments
 (0)