Skip to content

Commit 718c241

Browse files
Added Rocky Linux 8 re setups (#136)
* Added comparable deployments for EC 7.1 and Redis Cloud * Added password output * Added Rocky Linux 8 re setups --------- Co-authored-by: filipecosta90 <filipecosta.90@gmail.com>
1 parent f0cfb76 commit 718c241

File tree

12 files changed

+548
-0
lines changed

12 files changed

+548
-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 = "re-3nodes-r7i.16xlarge-rockylinux8-redislabs-6.4.2-81.tfstate"
10+
}
11+
}
12+
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
2+
resource "aws_instance" "server" {
3+
count = var.server_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+
10+
root_block_device {
11+
volume_size = var.instance_volume_size
12+
volume_type = var.instance_volume_type
13+
iops = var.instance_volume_iops
14+
encrypted = var.instance_volume_encrypted
15+
delete_on_termination = true
16+
}
17+
18+
volume_tags = {
19+
Environment = "${var.environment}"
20+
Project = "${var.environment}"
21+
Name = "ebs_block_device-${var.setup_name}-DB-${count.index + 1}"
22+
setup = "${var.setup_name}"
23+
triggering_env = "${var.triggering_env}"
24+
github_actor = "${var.github_actor}"
25+
github_org = "${var.github_org}"
26+
github_repo = "${var.github_repo}"
27+
github_sha = "${var.github_sha}"
28+
}
29+
30+
tags = {
31+
Environment = "${var.environment}"
32+
Project = "${var.environment}"
33+
Name = "${var.setup_name}-DB-${count.index + 1}"
34+
setup = "${var.setup_name}"
35+
triggering_env = "${var.triggering_env}"
36+
github_actor = "${var.github_actor}"
37+
github_org = "${var.github_org}"
38+
github_repo = "${var.github_repo}"
39+
github_sha = "${var.github_sha}"
40+
}
41+
42+
################################################################################
43+
# Deployment related
44+
################################################################################
45+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
output "server_public_ip" {
2+
value = aws_instance.server[*].public_ip
3+
}
4+
5+
output "server_private_ip" {
6+
value = aws_instance.server[*].private_ip
7+
}
8+
9+
output "server_instance_type" {
10+
value = var.server_instance_type
11+
}
12+
13+
output "setup_name" {
14+
value = var.setup_name
15+
}
16+
17+
output "ssh_user" {
18+
value = var.ssh_user
19+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
10+
print("#!/bin/bash\n")
11+
print("TOTAL_NODES={}\n".format(total_nodes))
12+
suffix_len = len("perf-cto-RE-")
13+
setup_name = output_json["setup_name"]["value"].replace(".", "-").replace("-", "-")
14+
setup_name = setup_name[suffix_len:]
15+
server_instance_type = output_json["server_instance_type"]["value"].replace(".", "-")
16+
ssh_user = output_json["ssh_user"]["value"]
17+
18+
19+
print('USER="{}"\n'.format(ssh_user))
20+
print("PEM=/tmp/benchmarks.redislabs.pem\n")
21+
print('CLUSTER_NAME="{}"\n'.format(setup_name))
22+
23+
print("\n#internal IP addresses")
24+
cleaned_json = {}
25+
for keyn, v in enumerate(output_json["server_private_ip"]["value"], start=1):
26+
print("B_M{}_I={}".format(keyn, v))
27+
28+
print("\n#external IP addresses")
29+
for keyn, v in enumerate(output_json["server_public_ip"]["value"], start=1):
30+
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: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
################################################################################
2+
# Variables used for deployment tag
3+
################################################################################
4+
5+
variable "setup_name" {
6+
description = "setup name"
7+
default = "perf-cto-RE-3nodes-r7i.16xlarge-rockylinux8-RS-6.4.2-81"
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 = "RED-158033"
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+
# Rocky Linux 8 (Official)Rocky Linux 8 (Official)
65+
# https://aws.amazon.com/marketplace/server/configuration?productId=d6577ceb-8ea8-4e0e-84c6-f098fc302e82&ref_=psb_cfg_continue
66+
# Ami Id: ami-02391db2758465a87
67+
variable "instance_ami" {
68+
description = "AMI for aws EC2 instance - us-east-2 Rocky Linux 8"
69+
default = "ami-02391db2758465a87"
70+
}
71+
72+
variable "instance_device_name" {
73+
description = "EC2 instance device name"
74+
default = "/dev/sda1"
75+
}
76+
77+
variable "redis_module" {
78+
description = "redis_module"
79+
default = "N/A"
80+
}
81+
82+
variable "instance_volume_size" {
83+
description = "EC2 instance volume_size"
84+
default = "1024"
85+
}
86+
87+
variable "instance_volume_type" {
88+
description = "EC2 instance volume_type"
89+
default = "gp3"
90+
}
91+
92+
93+
variable "instance_volume_iops" {
94+
description = "EC2 instance volume_iops"
95+
default = "3000"
96+
}
97+
98+
99+
variable "instance_volume_encrypted" {
100+
description = "EC2 instance instance_volume_encrypted"
101+
default = "false"
102+
}
103+
104+
variable "instance_root_block_device_encrypted" {
105+
description = "EC2 instance instance_root_block_device_encrypted"
106+
default = "false"
107+
}
108+
109+
variable "instance_cpu_threads_per_core" {
110+
description = "CPU threads per core for aws EC2 instance"
111+
default = 1
112+
}
113+
114+
variable "instance_cpu_threads_per_core_hyperthreading" {
115+
description = "CPU threads per core when hyperthreading is enabled for aws EC2 instance"
116+
default = 2
117+
}
118+
119+
variable "instance_network_interface_plus_count" {
120+
description = "number of additional network interfaces to add to aws EC2 instance"
121+
default = 0
122+
}
123+
124+
variable "os" {
125+
description = "os"
126+
default = "rockylinux8"
127+
}
128+
129+
variable "ssh_user" {
130+
description = "ssh_user"
131+
default = "rocky"
132+
}
133+
134+
################################################################################
135+
# Specific DB machine variables
136+
################################################################################
137+
# r7i.16xlarge 64 VCPUs 512 GB
138+
variable "server_instance_type" {
139+
description = "type for aws EC2 instance"
140+
default = "r7i.16xlarge"
141+
}
142+
143+
144+
variable "server_instance_count" {
145+
default = "3"
146+
}
147+
148+
variable "server_instance_cpu_core_count" {
149+
description = "CPU core count for aws EC2 instance"
150+
default = 32
151+
}
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 = "re-3nodes-r7i.16xlarge-rockylinux8-redislabs-7.8.6-36.tfstate"
10+
}
11+
}
12+
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
2+
resource "aws_instance" "server" {
3+
count = var.server_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+
10+
root_block_device {
11+
volume_size = var.instance_volume_size
12+
volume_type = var.instance_volume_type
13+
iops = var.instance_volume_iops
14+
encrypted = var.instance_volume_encrypted
15+
delete_on_termination = true
16+
}
17+
18+
volume_tags = {
19+
Environment = "${var.environment}"
20+
Project = "${var.environment}"
21+
Name = "ebs_block_device-${var.setup_name}-DB-${count.index + 1}"
22+
setup = "${var.setup_name}"
23+
triggering_env = "${var.triggering_env}"
24+
github_actor = "${var.github_actor}"
25+
github_org = "${var.github_org}"
26+
github_repo = "${var.github_repo}"
27+
github_sha = "${var.github_sha}"
28+
}
29+
30+
tags = {
31+
Environment = "${var.environment}"
32+
Project = "${var.environment}"
33+
Name = "${var.setup_name}-DB-${count.index + 1}"
34+
setup = "${var.setup_name}"
35+
triggering_env = "${var.triggering_env}"
36+
github_actor = "${var.github_actor}"
37+
github_org = "${var.github_org}"
38+
github_repo = "${var.github_repo}"
39+
github_sha = "${var.github_sha}"
40+
}
41+
42+
################################################################################
43+
# Deployment related
44+
################################################################################
45+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
output "server_public_ip" {
2+
value = aws_instance.server[*].public_ip
3+
}
4+
5+
output "server_private_ip" {
6+
value = aws_instance.server[*].private_ip
7+
}
8+
9+
output "server_instance_type" {
10+
value = var.server_instance_type
11+
}
12+
13+
output "setup_name" {
14+
value = var.setup_name
15+
}
16+
17+
output "ssh_user" {
18+
value = var.ssh_user
19+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
10+
print("#!/bin/bash\n")
11+
print("TOTAL_NODES={}\n".format(total_nodes))
12+
suffix_len = len("perf-cto-RE-")
13+
setup_name = output_json["setup_name"]["value"].replace(".", "-").replace("-", "-")
14+
setup_name = setup_name[suffix_len:]
15+
server_instance_type = output_json["server_instance_type"]["value"].replace(".", "-")
16+
ssh_user = output_json["ssh_user"]["value"]
17+
18+
19+
print('USER="{}"\n'.format(ssh_user))
20+
print("PEM=/tmp/benchmarks.redislabs.pem\n")
21+
print('CLUSTER_NAME="{}"\n'.format(setup_name))
22+
23+
print("\n#internal IP addresses")
24+
cleaned_json = {}
25+
for keyn, v in enumerate(output_json["server_private_ip"]["value"], start=1):
26+
print("B_M{}_I={}".format(keyn, v))
27+
28+
print("\n#external IP addresses")
29+
for keyn, v in enumerate(output_json["server_public_ip"]["value"], start=1):
30+
print("B_M{}_E={}".format(keyn, v))

0 commit comments

Comments
 (0)