Clusters
Clusters
The example given here deploys a Kubernetes cluster, but the same logic applies to a SLURM cluster.
You must add your SSH key to your SSH agent before using the terraform CLI.
~/projet-cloud $ eval "$(ssh-agent)"
~/projet-cloud $ ssh-addDependencies
env:
OS_CLOUD: 'resinfo-discotech@stratuslab.production.virtualdata'
TF_VAR_VM_PREFIX: 'k3s'
TF_VAR_IMAGE_NAME: 'jammy-server-cloudimg-amd64.img'
TF_VAR_SSH_USER: 'ubuntu'
TF_VAR_FLAVOR_NAME: 'vd.4'
TF_VAR_PUBLIC_NETWORK: 'public-2'
TF_VAR_KEYPAIR: 'mykey'
dependencies:
jq: ^1.7
yq: ^4.25.2
terraform.io: ^1.5
task: ^3.30.1
openssh.com: ^9.5- The name of the entry in the OpenStack client configuration.
- Prefix for all VM names.
- Disk image used for VM deployment.
- The user login for connecting to the VM.
- The VM flavour name (CPU/RAM/DISK).
- The name of the network providing public IPs.
- The name of the SSH key pair to use.
Tasks
version: '3'
tasks:
default:
silent: true
cmds:
- task --list
deploy:
desc: deploy
cmds:
- |
bash <<-'EOS'
source <(pkgx --shellcode)
terraform apply --auto-approve
EOSActivation
~ $ cd projet-cloud
✓ ~/.pkgx/github.com/kkos/oniguruma/v6.9.8
✓ ~/.pkgx/stedolan.github.io/jq/v1.7.0
env +stedolan.github.io/jq^1.7 +github.com/mikefarah/yq^4.35.2 +terraform.io^1.5 +taskfile.dev^3.30.1 +gnu.org/coreutils^9.4
~/projet-cloud/ $Terraform
Variables
variable VM_PREFIX {
type = string
}
variable IMAGE_NAME {
type = string
}
variable SSH_USER {
type = string
}
variable COMPUTE_COUNT {
type = number
default = 3
}
variable FLAVOR_NAME {
type = string
}
variable PUBLIC_NETWORK {
type = string
}
variable KEYPAIR {
type = string
}Resources
resource openstack_compute_instance_v2 bootstrap {
name = "manager-1"
image_name = var.IMAGE_NAME
flavor_name = var.FLAVOR_NAME
key_pair = var.KEYPAIR
network {
name = var.PUBLIC_NETWORK
}
}
resource openstack_compute_instance_v2 compute {
count = var.COMPUTE_COUNT
name = "compute-${count.index+1}"
image_name = var.IMAGE_NAME
flavor_name = var.FLAVOR_NAME
key_pair = var.KEYPAIR
network {
name = var.PUBLIC_NETWORK
}
}Outputs
output bootstrap_user {
value = var.SSH_USER
}
output bootstrap_ip {
value = openstack_compute_instance_v2.bootstrap.access_ip_v4
}
output compute_ip {
value = openstack_compute_instance_v2.compute.*.access_ip_v4
}Execution
~/projet-cloud/ $ task list~/projet-cloud/ $ task deploy