Open rawdaGastan opened 3 months ago
terraform {
required_providers {
grid = {
source = "threefoldtech/grid"
}
}
}
provider "grid" {
}
locals {
name = "multinodedeployment"
}
resource "grid_scheduler" "sched" {
requests {
name = "node1"
cru = 2
sru = 1024 * 2
mru = 1024 * 2
public_ips_count = 2
public_config = true
}
requests {
name = "node2"
cru = 2
sru = 1024 * 10
mru = 1024 * 10
}
}
resource "grid_network" "net1" {
nodes = [grid_scheduler.sched.nodes["node1"], grid_scheduler.sched.nodes["node2"]]
ip_range = "172.20.0.0/16"
name = local.name
description = "new network"
}
resource "grid_deployment" "d1" {
name = local.name
node = grid_scheduler.sched.nodes["node1"]
network_name = grid_network.net1.name
vms {
name = "vm1"
flist = "https://hub.grid.tf/tf-official-apps/base:latest.flist"
cpu = 2
memory = 1024
publicip = true
entrypoint = "/sbin/zinit init"
env_vars = {
SSH_KEY = file("~/.ssh/id_rsa.pub")
}
}
vms {
name = "vm2"
flist = "https://hub.grid.tf/tf-official-apps/base:latest.flist"
cpu = 2
memory = 1024
publicip = true
entrypoint = "/sbin/zinit init"
env_vars = {
SSH_KEY = file("~/.ssh/id_rsa.pub")
}
}
}
resource "grid_deployment" "d2" {
node = grid_scheduler.sched.nodes["node2"]
network_name = grid_network.net1.name
vms {
name = "vm3"
flist = "https://hub.grid.tf/tf-official-apps/base:latest.flist"
cpu = 1
memory = 1024
entrypoint = "/sbin/zinit init"
env_vars = {
SSH_KEY = file("~/.ssh/id_rsa.pub")
}
}
vms {
name = "vm4"
flist = "https://hub.grid.tf/tf-official-apps/base:latest.flist"
cpu = 1
memory = 1024
entrypoint = "/sbin/zinit init"
env_vars = {
SSH_KEY = file("~/.ssh/id_rsa.pub")
}
}
vms {
name = "vm5"
flist = "https://hub.grid.tf/tf-official-apps/base:latest.flist"
cpu = 1
memory = 1024
entrypoint = "/sbin/zinit init"
env_vars = {
SSH_KEY = file("~/.ssh/id_rsa.pub")
}
}
vms {
name = "vm6"
flist = "https://hub.grid.tf/tf-official-apps/base:latest.flist"
cpu = 1
memory = 1024
entrypoint = "/sbin/zinit init"
env_vars = {
SSH_KEY = file("~/.ssh/id_rsa.pub")
}
}
}
resource "grid_deployment" "d3" {
node = grid_scheduler.sched.nodes["node2"]
network_name = grid_network.net1.name
vms {
name = "vm7"
flist = "https://hub.grid.tf/tf-official-apps/base:latest.flist"
cpu = 1
memory = 1024
entrypoint = "/sbin/zinit init"
env_vars = {
SSH_KEY = file("~/.ssh/id_rsa.pub")
}
}
vms {
name = "vm8"
flist = "https://hub.grid.tf/tf-official-apps/base:latest.flist"
cpu = 1
memory = 1024
entrypoint = "/sbin/zinit init"
env_vars = {
SSH_KEY = file("~/.ssh/id_rsa.pub")
}
}
vms {
name = "vm9"
flist = "https://hub.grid.tf/tf-official-apps/base:latest.flist"
cpu = 1
memory = 1024
entrypoint = "/sbin/zinit init"
env_vars = {
SSH_KEY = file("~/.ssh/id_rsa.pub")
}
}
vms {
name = "vm10"
flist = "https://hub.grid.tf/tf-official-apps/base:latest.flist"
cpu = 1
memory = 1024
entrypoint = "/sbin/zinit init"
env_vars = {
SSH_KEY = file("~/.ssh/id_rsa.pub")
}
}
}
output "node1_zmachine1_ip" {
value = grid_deployment.d1.vms[0].ip
}
output "node1_zmachine_computed_public_ip" {
value = grid_deployment.d1.vms[0].computedip
}
output "node2_zmachine1_ip" {
value = grid_deployment.d2.vms[0].ip
}
output "node2_zmachine_computed_public_ip" {
value = grid_deployment.d2.vms[0].computedip
}
Apply complete! Resources: 5 added, 0 changed, 0 destroyed.
Outputs:
node1_zmachine1_ip = "172.20.2.2"
node1_zmachine_computed_public_ip = "185.206.122.34/24"
node2_zmachine1_ip = "172.20.2.2"
node2_zmachine_computed_public_ip = ""
Tests need to be fixed
"Bad Gateway" does not contain "Directory listing for"
dial tcp [300:170b:469a:2ed8:6f7e:59d0:e50:e41d]:22: connect: connection timed out
couldn't schedule request gateway: couldn't find a node satisfying the given requirements
dial tcp [300:164c:759a:efe6:1655:fb4b:6652:377e]:22: connect: connection timed out
could not start ssh connection
couldn't schedule request gateway: couldn't find a node satisfying the given requirements
could not deploy network networkk: error sending deployment to node 2: global workload with the same name 'networkk' exists: conflict
couldn't schedule request gateway: couldn't find a node satisfying the given requirements
trace error
Error: couldn't deploy deployment with error: error waiting deployment: workload meta1 within deployment 531958 failed with error: failed to create zdb namespace: failed to connect to 0-db: a5b6bd02-***: dial unix /var/run/zdb_a5b6bd02-***/zdb.sock: connect: connection refused
couldn't schedule request gateway: couldn't find a node satisfying the given requirements
order issue
workers should be found
couldn't deploy k8s cluster with error: k8s workers and master must have unique names: w0 occurred more than once
tests timeout