Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added simple 2 nodes setup (1DB with HA enabled) #111

Merged
merged 7 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 0 additions & 53 deletions terraform/oss-standalone-redisearch-m5/README.md

This file was deleted.

7 changes: 4 additions & 3 deletions terraform/oss-standalone-redisearch-m5/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ variable "region" {
}

# (Ubuntu 20.04)
# ubuntu-bionic-20.04-amd64-server
# ubuntu-bionic-20.04-amd64-server with redis 7.4.0 and memtier 2.1.1
# https://us-east-2.console.aws.amazon.com/ec2/home?region=us-east-2#ImageDetails:imageId=ami-0cfbc88a79665b192
variable "instance_ami" {
description = "AMI for aws EC2 instance - us-east-2 Ubuntu 20.04 - perf-cto-base-image-ubuntu20.04-redis-7.1.241-tuned-latency"
default = "ami-0e64e0b751414b32e"
description = "AMI for aws EC2 instance - us-east-2 Ubuntu 20.04 - perf-cto-base-image-ubuntu20.04-redis-7.4.0-tuned-latency"
default = "ami-0cfbc88a79665b192"
}

variable "instance_device_name" {
Expand Down
20 changes: 0 additions & 20 deletions terraform/oss-standalone-redistimeseries-m5/.terraform.lock.hcl

This file was deleted.

1 change: 0 additions & 1 deletion terraform/oss-standalone-redistimeseries-m5/common.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ terraform {
backend "s3" {
bucket = "performance-cto-group"
region = "us-east-1"
key = "benchmarks/infrastructure/oss-standalone-redistimeseries-m5.tfstate"
}
}

12 changes: 12 additions & 0 deletions terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/common.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

################################################################################
# This is the bucket holding this specific setup tfstate
################################################################################
terraform {
backend "s3" {
bucket = "performance-cto-group"
region = "us-east-1"
key = "testing-infrastructure/terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge.tfstate"
}
}

76 changes: 76 additions & 0 deletions terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/db-resources.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@

resource "aws_instance" "server" {
count = var.server_instance_count
ami = var.instance_ami
instance_type = var.server_instance_type
subnet_id = data.terraform_remote_state.shared_resources.outputs.subnet_public_id
vpc_security_group_ids = ["${data.terraform_remote_state.shared_resources.outputs.performance_cto_sg_id}"]
key_name = var.key_name

root_block_device {
volume_size = var.instance_volume_size
volume_type = var.instance_volume_type
iops = var.instance_volume_iops
encrypted = var.instance_volume_encrypted
delete_on_termination = true
}

volume_tags = {
Environment = "${var.environment}"
Project = "${var.environment}"
Name = "ebs_block_device-${var.setup_name}-DB-${count.index + 1}"
setup = "${var.setup_name}"
triggering_env = "${var.triggering_env}"
github_actor = "${var.github_actor}"
github_org = "${var.github_org}"
github_repo = "${var.github_repo}"
github_sha = "${var.github_sha}"
}

tags = {
Environment = "${var.environment}"
Project = "${var.environment}"
Name = "${var.setup_name}-DB-${count.index + 1}"
setup = "${var.setup_name}"
triggering_env = "${var.triggering_env}"
github_actor = "${var.github_actor}"
github_org = "${var.github_org}"
github_repo = "${var.github_repo}"
github_sha = "${var.github_sha}"
}

################################################################################
# This will ensure we wait here until the instance is ready to receive the ssh connection
################################################################################
provisioner "remote-exec" {
script = "./../scripts/wait_for_instance.sh"
connection {
host = self.public_ip # The `self` variable is like `this` in many programming languages
type = "ssh" # in this case, `self` is the resource (the server).
user = var.ssh_user
private_key = file(var.private_key)
#need to increase timeout to larger then 5m for metal instances
timeout = "5m"
agent = "false"
}
}
################################################################################
# Deployment related
################################################################################

################################################################################
# Install RE
################################################################################
provisioner "remote-exec" {
script = "./install-re-7.4.sh"
connection {
host = self.public_ip # The `self` variable is like `this` in many programming languages
type = "ssh" # in this case, `self` is the resource (the server).
user = var.ssh_user
private_key = file(var.private_key)
#need to increase timeout to larger then 5m for metal instances
timeout = "10m"
agent = "false"
}
}
}
22 changes: 22 additions & 0 deletions terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/install-re-7.4.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

# exit the script if any command fails.
set -e

V=7.4.2
FULL=$V-216
FILENAME=/tmp/re.tar
OS="focal"

wget -O $FILENAME https://s3.amazonaws.com/redis-enterprise-software-downloads/${V}/redislabs-${FULL}-${OS}-amd64.tar

cd /tmp
tar vxf /tmp/re.tar
echo "DNSStubListener=no" | sudo tee -a /etc/systemd/resolved.conf
sudo mv /etc/resolv.conf /etc/resolv.conf.orig
sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
sudo service systemd-resolved restart
sudo /tmp/install.sh -y

# Cleanup
rm -f $FILENAME
15 changes: 15 additions & 0 deletions terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
output "server_public_ip" {
value = aws_instance.server[*].public_ip
}

output "server_private_ip" {
value = aws_instance.server[*].private_ip
}

output "server_instance_type" {
value = var.server_instance_type
}

output "setup_name" {
value = var.setup_name
}
25 changes: 25 additions & 0 deletions terraform/re-2nodes-1dbs-25gb-7.4.0-r6id.2xlarge/prepare_ips.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import subprocess
import json

# Run the "terraform output json" command
output = subprocess.run(["terraform", "output", "-json"], stdout=subprocess.PIPE)

output_json = json.loads(output.stdout.decode())
total_nodes = len(output_json["server_private_ip"]["value"])

print("#!/bin/bash\n")
print("TOTAL_NODES={}\n".format(total_nodes))
suffix_len = len("perf-cto-RE-")
setup_name = output_json["setup_name"]["value"].replace(".", "_").replace("-", "_")
setup_name = setup_name[suffix_len:]
server_instance_type = output_json["server_instance_type"]["value"].replace(".", "_")

print('CLUSTER_NAME="{}"\n'.format(setup_name))
print("\n#internal IP addresses")
cleaned_json = {}
for keyn, v in enumerate(output_json["server_private_ip"]["value"], start=1):
print("B_M{}_I={}".format(keyn, v))

print("\n#external IP addresses")
for keyn, v in enumerate(output_json["server_public_ip"]["value"], start=1):
print("B_M{}_E={}".format(keyn, v))
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# provider
provider "aws" {
region = var.region
}

################################################################################
# This is the shared resources bucket key -- you will need it across environments like security rules,etc...
# !! do not change this !!
################################################################################
data "terraform_remote_state" "shared_resources" {
backend = "s3"
config = {
bucket = "performance-cto-group"
key = "benchmarks/infrastructure/shared_resources.tfstate"
region = "us-east-1"
}
}
Loading