Skip to content
Draft
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
48 changes: 24 additions & 24 deletions bootstrap-cluster.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -euo pipefail

KEY="$HOME/.ssh/simplyblock-ohio.pem"
KEY="~/.ssh/simplyblock-xata.pem"

print_help() {
echo "Usage: $0 [options]"
Expand Down Expand Up @@ -173,31 +173,31 @@ while [[ $# -gt 0 ]]; do
shift
done

SECRET_VALUE=$(terraform output -raw secret_value)
#SECRET_VALUE=$(terraform output -raw secret_value)
KEY_NAME=$(terraform output -raw key_name)
BASTION_IP=$(terraform output -raw bastion_public_ip)
GRAFANA_ENDPOINT=$(terraform output -raw grafana_invoke_url)

ssh_dir="$HOME/.ssh"

if [ ! -d "$ssh_dir" ]; then
mkdir -p "$ssh_dir"
echo "Directory $ssh_dir created."
else
echo "Directory $ssh_dir already exists."
fi

if [[ -n "$SECRET_VALUE" ]]; then
KEY="$HOME/.ssh/$KEY_NAME"
if [ -f "$HOME/.ssh/$KEY_NAME" ]; then
echo "the ssh key: ${KEY} already exits on local"
else
echo "$SECRET_VALUE" >"$KEY"
chmod 400 "$KEY"
fi
else
echo "Failed to retrieve secret value. Falling back to default key."
fi
# ssh_dir="$HOME/.ssh"

# if [ ! -d "$ssh_dir" ]; then
# mkdir -p "$ssh_dir"
# echo "Directory $ssh_dir created."
# else
# echo "Directory $ssh_dir already exists."
# fi

# if [[ -n "$SECRET_VALUE" ]]; then
# KEY="$HOME/.ssh/$KEY_NAME"
# if [ -f "$HOME/.ssh/$KEY_NAME" ]; then
# echo "the ssh key: ${KEY} already exits on local"
# else
# echo "$SECRET_VALUE" >"$KEY"
# chmod 400 "$KEY"
# fi
# else
# echo "Failed to retrieve secret value. Falling back to default key."
# fi

mnodes=$(terraform output -raw mgmt_private_ips)
echo "mgmt_private_ips: ${mnodes}"
Expand Down Expand Up @@ -316,7 +316,7 @@ for ((i = 1; i < ${#mnodes[@]}; i++)); do
-o ProxyCommand="ssh -o StrictHostKeyChecking=no -i \"$KEY\" -W %h:%p ec2-user@${BASTION_IP}" \
ec2-user@${mnodes[${i}]} "
MANGEMENT_NODE_IP=${mnodes[0]}
${SBCLI_CMD} mgmt add \${MANGEMENT_NODE_IP} ${CLUSTER_ID} eth0
${SBCLI_CMD} mgmt add \${MANGEMENT_NODE_IP} ${CLUSTER_ID} ${CLUSTER_SECRET} eth0
"
done

Expand Down Expand Up @@ -391,7 +391,7 @@ else
-o ProxyCommand="ssh -o StrictHostKeyChecking=no -i \"$KEY\" -W %h:%p ec2-user@${BASTION_IP}" \
ec2-user@${mnodes[0]} "
MANGEMENT_NODE_IP=${mnodes[0]}
${SBCLI_CMD} cluster activate ${CLUSTER_ID}
${SBCLI_CMD} -d cluster activate ${CLUSTER_ID}
"
fi

Expand Down
44 changes: 22 additions & 22 deletions bootstrap-k3s.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

KEY="$HOME/.ssh/simplyblock-ohio.pem"
KEY="~/.ssh/simplyblock-xata.pem"

print_help() {
echo "Usage: $0 [options]"
Expand Down Expand Up @@ -29,29 +29,29 @@ while [[ $# -gt 0 ]]; do
shift
done

SECRET_VALUE=$(terraform output -raw secret_value)
#SECRET_VALUE=$(terraform output -raw secret_value)
KEY_NAME=$(terraform output -raw key_name)

ssh_dir="$HOME/.ssh"

if [ ! -d "$ssh_dir" ]; then
mkdir -p "$ssh_dir"
echo "Directory $ssh_dir created."
else
echo "Directory $ssh_dir already exists."
fi

if [[ -n "$SECRET_VALUE" ]]; then
KEY="$HOME/.ssh/$KEY_NAME"
if [ -f "$HOME/.ssh/$KEY_NAME" ]; then
echo "the ssh key: ${KEY} already exits on local"
else
echo "$SECRET_VALUE" >"$KEY"
chmod 400 "$KEY"
fi
else
echo "Failed to retrieve secret value. Falling back to default key."
fi
# ssh_dir="$HOME/.ssh"

# if [ ! -d "$ssh_dir" ]; then
# mkdir -p "$ssh_dir"
# echo "Directory $ssh_dir created."
# else
# echo "Directory $ssh_dir already exists."
# fi

# if [[ -n "$SECRET_VALUE" ]]; then
# KEY="$HOME/.ssh/$KEY_NAME"
# if [ -f "$HOME/.ssh/$KEY_NAME" ]; then
# echo "the ssh key: ${KEY} already exits on local"
# else
# echo "$SECRET_VALUE" >"$KEY"
# chmod 400 "$KEY"
# fi
# else
# echo "Failed to retrieve secret value. Falling back to default key."
# fi

BASTION_IP=$(terraform output -raw bastion_public_ip)
mnodes=($(terraform output -raw extra_nodes_public_ips))
Expand Down
43 changes: 43 additions & 0 deletions create_cluster.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

# CHANGE THE NAMESPACE NAME!
namespace="change_me"
sbcli_cmd="sbcli-dev"
CONTACT_POINT=<add_slack_webhook>


export TFSTATE_BUCKET=xata-simplyblock-staging-infra
export TFSTATE_KEY=staging/controlplane
export TFSTATE_REGION=us-east-2

terraform init -reconfigure \
-backend-config="bucket=${TFSTATE_BUCKET}" \
-backend-config="key=${TFSTATE_KEY}" \
-backend-config="region=${TFSTATE_REGION}" \
-backend-config="encrypt=true"

### switch to workspace
terraform workspace select -or-create "$namespace"

# terraform apply -var mgmt_nodes=1 -var storage_nodes=0 -var extra_nodes=0 --auto-approve

# Specifying the instance types to use
terraform apply -var mgmt_nodes=1 -var storage_nodes=4 -var extra_nodes=0 -var "storage_nodes_arch=arm64" \
-var mgmt_nodes_instance_type="m6i.xlarge" -var storage_nodes_instance_type="c6gd.2xlarge" \
-var extra_nodes_instance_type="m6i.large" -var sbcli_cmd="$sbcli_cmd" \
-var volumes_per_storage_nodes=0 --auto-approve

# Save terraform output to a file
terraform output -json > tf_outputs.json

# The boostrap-cluster.sh creates the KEY in `.ssh` directory in the home directory

chmod +x ./bootstrap-cluster.sh
# specifying cluster argument to use
./bootstrap-cluster.sh --sbcli-cmd "$sbcli_cmd" --disable-ha-jm \
--distr-ndcs 2 --distr-npcs 1 --cap-crit 99 --cap-warn 94 --prov-cap-crit 500 \
--prov-cap-warn 200 --distr-bs 4096 --distr-chunk-bs 4096 \
--spdk-debug --max-lvol 200 --max-snap 200 --max-prov 10T --number-of-devices 1 \
--partitions 1 --log-del-interval 300m --metrics-retention-period 2h \
--number-of-distribs 2 \
--contact-point $CONTACT_POINT
6 changes: 3 additions & 3 deletions data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ data "aws_availability_zones" "available" {
state = "available"
}

data "aws_secretsmanager_secret_version" "simply" {
secret_id = local.selected_key_name
}
# data "aws_secretsmanager_secret_version" "simply" {
# secret_id = local.selected_key_name
# }
6 changes: 3 additions & 3 deletions locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ locals {

key_name = {
"us-east-1" = "simplyblock-us-east-1.pem"
"us-east-2" = "simplyblock-us-east-2.pem"
"us-east-2" = "simplyblock-xata.pem"
"eu-north-1" = "simplyblock-eu-north-1.pem"
"eu-west-1" = "simplyblock-eu-west-1.pem"
}
Expand All @@ -27,14 +27,14 @@ locals {
# $sudo yum install -y yum-utils xorg-x11-xauth nvme-cli fio
region_ami_map = {
"us-east-1" = "ami-0ff9547ee3e11637a"
"us-east-2" = "ami-00b0bb86a4287f38f"
"us-east-2" = "ami-0aa8fc2422063977a"
"eu-north-1" = "ami-01997ffb7707167a4"
"eu-west-1" = "ami-0a3bac9371ffc12f8"
}

region_ami_map_arm = {
"us-east-1" = "ami-0990e7074b32986af"
"us-east-2" = "ami-0e71db082192a9cf7"
"us-east-2" = "ami-08f9f3bb075432791"
"eu-north-1" = "ami-006af066a79f5190f"
"eu-west-1" = "ami-06028a225ee106d6f"
}
Expand Down
8 changes: 4 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ module "vpc" {
source = "terraform-aws-modules/vpc/aws"

name = "${terraform.workspace}-storage-vpc-sb"
cidr = "10.0.0.0/16"
cidr = "10.0.8.0/21"

azs = [data.aws_availability_zones.available.names[0], data.aws_availability_zones.available.names[1], ]
private_subnets = ["10.0.1.0/24", "10.0.3.0/24"]
public_subnets = ["10.0.2.0/24", "10.0.4.0/24"]
private_subnets = ["10.0.9.0/24", "10.0.11.0/24"]
public_subnets = ["10.0.10.0/24", "10.0.12.0/24"]
map_public_ip_on_launch = true

enable_nat_gateway = true
Expand Down Expand Up @@ -682,7 +682,7 @@ resource "aws_instance" "storage_nodes" {
subnet_id = module.vpc.private_subnets[local.az_index]
iam_instance_profile = aws_iam_instance_profile.inst_profile.name
root_block_device {
volume_size = 45
volume_size = 80
}
tags = {
Name = "${terraform.workspace}-storage-${each.value + 1}"
Expand Down
8 changes: 4 additions & 4 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ output "key_name" {
value = local.selected_key_name
}

output "secret_value" {
sensitive = true
value = data.aws_secretsmanager_secret_version.simply.secret_string
}
# output "secret_value" {
# sensitive = true
# value = data.aws_secretsmanager_secret_version.simply.secret_string
# }

output "mgmt_node_details" {
value = { for i, instance in aws_instance.mgmt_nodes :
Expand Down
42 changes: 42 additions & 0 deletions test/create_cluster_ebs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

# CHANGE THE NAMESPACE NAME!
namespace="changeme"
sbcli_cmd="sbcli-dev"


export TFSTATE_BUCKET=xata-simplyblock-staging-infra
export TFSTATE_KEY=staging/controlplane
export TFSTATE_REGION=us-east-2

terraform init -reconfigure \
-backend-config="bucket=${TFSTATE_BUCKET}" \
-backend-config="key=${TFSTATE_KEY}" \
-backend-config="region=${TFSTATE_REGION}" \
-backend-config="encrypt=true"

# uncomment if you need to destroy existing cluster with the same name
# terraform destroy --auto-approve

### switch to workspace
terraform workspace select -or-create "$namespace"

# terraform apply -var mgmt_nodes=1 -var storage_nodes=0 -var extra_nodes=0 --auto-approve

# Specifying the instance types to use
terraform apply -var mgmt_nodes=1 -var storage_nodes=3 -var extra_nodes=0 \
-var mgmt_nodes_instance_type="m6i.xlarge" -var storage_nodes_instance_type="m6i.2xlarge" \
-var extra_nodes_instance_type="m6i.large" -var sbcli_cmd="$sbcli_cmd" \
-var volumes_per_storage_nodes=3 -var storage_nodes_ebs_size2=100 --auto-approve

# Save terraform output to a file
terraform output -json > tf_outputs.json

# The boostrap-cluster.sh creates the KEY in `.ssh` directory in the home directory

chmod +x ./bootstrap-cluster.sh
# specifying cluster argument to use
./bootstrap-cluster.sh --sbcli-cmd "$sbcli_cmd" --spdk-debug \
--max-lvol 10 --max-snap 10 --max-prov 1200G \
--number-of-devices 3 --log-del-interval 900m --metrics-retention-period 2h \
--distr-ndcs 2 --distr-npcs 1 --distr-bs 4096 --distr-chunk-bs 4096 --partitions 0
Loading