Remove untested setup
This commit is contained in:
parent
bf62ccfd21
commit
099869f0a6
8 changed files with 0 additions and 285 deletions
5
deploy/scripts/.gitignore
vendored
5
deploy/scripts/.gitignore
vendored
|
|
@ -1,5 +0,0 @@
|
|||
# terraform
|
||||
*.tfstate
|
||||
*.tfstate.backup
|
||||
*.tfvars
|
||||
.terraform/
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
|
||||
#! /usr/bin/env sh
|
||||
|
||||
# Exit in case of error
|
||||
set -e
|
||||
|
||||
TAG=${TAG?Variable not set} \
|
||||
FRONTEND_ENV=${FRONTEND_ENV-production} \
|
||||
sh ./scripts/build.sh
|
||||
|
||||
docker-compose -f docker-compose.yml push
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
#! /usr/bin/env sh
|
||||
|
||||
# Exit in case of error
|
||||
set -e
|
||||
|
||||
TAG=${TAG?Variable not set} \
|
||||
FRONTEND_ENV=${FRONTEND_ENV-production} \
|
||||
docker-compose \
|
||||
-f docker-compose.yml \
|
||||
build
|
||||
24
deploy/scripts/terraform/.terraform.lock.hcl
generated
24
deploy/scripts/terraform/.terraform.lock.hcl
generated
|
|
@ -1,24 +0,0 @@
|
|||
# This file is maintained automatically by "terraform init".
|
||||
# Manual edits may be lost in future updates.
|
||||
|
||||
provider "registry.terraform.io/hashicorp/aws" {
|
||||
version = "5.13.1"
|
||||
hashes = [
|
||||
"h1:T/p3Gp8uAvRk3BmBZI/B7JIUpxF+2DygvBsv2UvJK4w=",
|
||||
"zh:0d107e410ecfbd5d2fb5ff9793f88e2ce03ae5b3bda4e3b772b5d146cdd859d8",
|
||||
"zh:1080cf6a402939ec4ad393380f2ab2dfdc0e175903e08ed796aa22eb95868847",
|
||||
"zh:300420d642c3ada48cfe633444eafa7bcd410cd6a8503de2384f14ac54dc3ce3",
|
||||
"zh:4e0121014a8d6ef0b1ab4634877545737bb54e951340f1b67ffea8cd22b2d252",
|
||||
"zh:59b401bbf95dc8c6bea58085ff286543380f176271251193eac09cb7fcf619b7",
|
||||
"zh:5dfaf51e979131710ce8e1572e6012564e68c7c842e3d9caaaeb0fe6af15c351",
|
||||
"zh:84bb75dafca056d7c3783be5185187fdd3294f902e9d72f7655f2efb5e066650",
|
||||
"zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425",
|
||||
"zh:aa4e2b9f699d497041679bc05ca34ac21a5184298eb1813f35455b1883977910",
|
||||
"zh:b51a4f08d84b071128df68a95cfa5114301a50bf8ab8e655dcf7e384e5bc6458",
|
||||
"zh:bce284ac6ebb65053d9b703048e3157bf4175782ea9dbaec9f64dc2b6fcefb0c",
|
||||
"zh:c748f78b79b354794098b06b18a02aefdb49be144dff8876c9204083980f7de0",
|
||||
"zh:ee69d9aef5ca532392cdc26499096f3fa6e55f8622387f78194ebfaadb796aef",
|
||||
"zh:ef561bee58e4976474bc056649095737fa3b2bcb74602032415d770bfc620c1f",
|
||||
"zh:f696d8416c57c31f144d432779ba34764560a95937db3bb3dd2892a791a6d5a7",
|
||||
]
|
||||
}
|
||||
|
|
@ -1,114 +0,0 @@
|
|||
terraform {
|
||||
backend "s3" {
|
||||
bucket = "terraform-5fso81t4tn8z"
|
||||
key = "backend/terraform.tfstate"
|
||||
region = "us-east-1"
|
||||
}
|
||||
}
|
||||
|
||||
provider "aws" {
|
||||
region = var.region # Choose the region as needed
|
||||
}
|
||||
|
||||
module "docker-swarm" {
|
||||
source = "./modules/docker-swarm"
|
||||
key_name = aws_key_pair.swarm-key.key_name
|
||||
vpc_id = aws_vpc.swarm-vpc.id
|
||||
subnet_id = aws_subnet.swarm-public-subnet.id
|
||||
security_group = aws_security_group.swarm-sg.id
|
||||
instance_type = var.instance_type # Choose the instance type as needed
|
||||
manager_count = var.manager_count
|
||||
worker_count = var.worker_count # This is the number of services in the docker-compose.yml file
|
||||
}
|
||||
|
||||
resource "aws_key_pair" "swarm-key" {
|
||||
key_name = "swarm-key"
|
||||
public_key = file("~/.ssh/id_rsa.pub")
|
||||
}
|
||||
|
||||
resource "aws_vpc" "swarm-vpc" {
|
||||
cidr_block = "10.0.0.0/16"
|
||||
enable_dns_support = true
|
||||
enable_dns_hostnames = true
|
||||
}
|
||||
|
||||
resource "aws_subnet" "swarm-private-subnet" {
|
||||
vpc_id = aws_vpc.swarm-vpc.id
|
||||
cidr_block = "10.0.1.0/24"
|
||||
}
|
||||
|
||||
resource "aws_subnet" "swarm-public-subnet" {
|
||||
vpc_id = aws_vpc.swarm-vpc.id
|
||||
cidr_block = "10.0.2.0/24"
|
||||
}
|
||||
|
||||
resource "aws_internet_gateway" "igw" {
|
||||
vpc_id = aws_vpc.swarm-vpc.id
|
||||
}
|
||||
|
||||
resource "aws_route_table" "public_rt" {
|
||||
vpc_id = aws_vpc.swarm-vpc.id
|
||||
|
||||
route {
|
||||
cidr_block = "0.0.0.0/0"
|
||||
gateway_id = aws_internet_gateway.igw.id
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_route_table_association" "public_subnet_asso" {
|
||||
subnet_id = aws_subnet.swarm-public-subnet.id
|
||||
route_table_id = aws_route_table.public_rt.id
|
||||
}
|
||||
|
||||
resource "aws_security_group" "swarm-sg" {
|
||||
vpc_id = aws_vpc.swarm-vpc.id
|
||||
|
||||
ingress {
|
||||
from_port = 22
|
||||
to_port = 22
|
||||
protocol = "tcp"
|
||||
cidr_blocks = ["0.0.0.0/0"]
|
||||
}
|
||||
|
||||
ingress {
|
||||
from_port = 2376
|
||||
to_port = 2377
|
||||
protocol = "tcp"
|
||||
cidr_blocks = ["0.0.0.0/0"]
|
||||
}
|
||||
|
||||
ingress {
|
||||
from_port = 7946
|
||||
to_port = 7946
|
||||
protocol = "tcp"
|
||||
cidr_blocks = ["0.0.0.0/0"]
|
||||
}
|
||||
|
||||
ingress {
|
||||
from_port = 4789
|
||||
to_port = 4789
|
||||
protocol = "udp"
|
||||
cidr_blocks = ["0.0.0.0/0"]
|
||||
}
|
||||
|
||||
egress {
|
||||
from_port = 0
|
||||
to_port = 0
|
||||
protocol = "-1"
|
||||
cidr_blocks = ["0.0.0.0/0"]
|
||||
}
|
||||
|
||||
ingress {
|
||||
from_port = 8080
|
||||
to_port = 8080
|
||||
protocol = "tcp"
|
||||
cidr_blocks = [aws_subnet.swarm-public-subnet.cidr_block]
|
||||
}
|
||||
|
||||
egress {
|
||||
from_port = 8080
|
||||
to_port = 8080
|
||||
protocol = "tcp"
|
||||
cidr_blocks = [aws_subnet.swarm-public-subnet.cidr_block]
|
||||
}
|
||||
}
|
||||
|
|
@ -1,94 +0,0 @@
|
|||
variable "key_name" {}
|
||||
variable "vpc_id" {}
|
||||
variable "subnet_id" {}
|
||||
variable "security_group" {}
|
||||
variable "instance_type" {}
|
||||
variable "manager_count" {}
|
||||
variable "worker_count" {}
|
||||
|
||||
|
||||
resource "aws_instance" "manager" {
|
||||
count = var.manager_count
|
||||
ami = "ami-08a52ddb321b32a8c" # Amazon Linux 2 LTS
|
||||
instance_type = var.instance_type
|
||||
key_name = var.key_name
|
||||
vpc_security_group_ids = [var.security_group]
|
||||
subnet_id = var.subnet_id
|
||||
associate_public_ip_address = true
|
||||
|
||||
user_data = <<-EOT
|
||||
#!/bin/bash
|
||||
sudo yum update -y
|
||||
sudo yum install -y docker
|
||||
sudo yum install -y git
|
||||
sudo yum install -y nc
|
||||
sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
|
||||
sudo chmod +x /usr/local/bin/docker-compose
|
||||
sudo service docker start
|
||||
sudo usermod -a -G docker ec2-user
|
||||
sudo chkconfig docker on
|
||||
|
||||
# Fetch instance metadata with token
|
||||
TOKEN=`curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"`
|
||||
IP_ADDR=$(curl -H "X-aws-ec2-metadata-token: $TOKEN" -v http://169.254.169.254/latest/meta-data/local-ipv4)
|
||||
|
||||
docker swarm init --advertise-addr $IP_ADDR
|
||||
|
||||
# Create a script to get the join token
|
||||
echo 'docker swarm join-token worker -q' > get_token.sh
|
||||
chmod +x get_token.sh
|
||||
timeout 5m bash -c "while true; do { echo -e 'HTTP/1.1 200 OK\r\n'; ./get_token.sh; } | nc -l 8080; done" &
|
||||
sleep 10
|
||||
|
||||
# Clone the repo and start the stack
|
||||
git clone https://github.com/logspace-ai/langflow.git
|
||||
cd /langflow
|
||||
git checkout celery
|
||||
cd /langflow/deploy
|
||||
|
||||
sudo cp .env.example .env
|
||||
|
||||
# Add the label to random worker node to ensure that the data volume is created on the same node
|
||||
docker node update --label-add app-db-data=true $(docker node ls --format '{{.Hostname}}' --filter role=worker | head -n 1)
|
||||
|
||||
env $(cat .env | grep ^[A-Z] | xargs) docker stack deploy --compose-file docker-compose.yml langflow_stack
|
||||
|
||||
EOT
|
||||
|
||||
tags = {
|
||||
Name = "manager-${count.index}"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_instance" "worker" {
|
||||
count = var.worker_count
|
||||
ami = "ami-08a52ddb321b32a8c" # Amazon Linux 2 LTS
|
||||
instance_type = var.instance_type
|
||||
key_name = var.key_name
|
||||
vpc_security_group_ids = [var.security_group]
|
||||
subnet_id = var.subnet_id
|
||||
associate_public_ip_address = true
|
||||
|
||||
user_data = <<-EOT
|
||||
#!/bin/bash
|
||||
MANAGER_IP="${aws_instance.manager.0.private_ip}"
|
||||
sudo yum update -y
|
||||
sudo yum install -y docker
|
||||
sudo service docker start
|
||||
sudo usermod -a -G docker ec2-user
|
||||
sudo chkconfig docker on
|
||||
docker swarm join --token $(curl -s http://$MANAGER_IP:8080/token) $MANAGER_IP:2377
|
||||
EOT
|
||||
|
||||
tags = {
|
||||
Name = "worker-${count.index}"
|
||||
}
|
||||
}
|
||||
|
||||
output "manager_public_ips" {
|
||||
value = aws_instance.manager[*].public_ip
|
||||
}
|
||||
|
||||
output "worker_public_ips" {
|
||||
value = aws_instance.worker[*].public_ip
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
output "manager_public_ips" {
|
||||
value = module.docker-swarm.manager_public_ips
|
||||
}
|
||||
|
||||
output "worker_public_ips" {
|
||||
value = module.docker-swarm.worker_public_ips
|
||||
}
|
||||
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
variable "region" {
|
||||
description = "The AWS region"
|
||||
default = "us-east-1"
|
||||
}
|
||||
|
||||
variable "instance_type" {
|
||||
description = "EC2 instance type"
|
||||
default = "t2.micro"
|
||||
}
|
||||
|
||||
variable "manager_count" {
|
||||
description = "Number of manager nodes"
|
||||
default = 1
|
||||
}
|
||||
|
||||
variable "worker_count" {
|
||||
description = "Number of worker nodes"
|
||||
default = 3
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue