Clusters
Clusters
L’exemple donné ici permet de déployer un cluster Kubernetes mais la même logique
s’applique pour un cluster SLURM.
Il faut ajouter sa clef SSH dans son agent SSH avant d’utiliser la cli terraform.
~/projet-cloud $ eval "$(ssh-agent)"
~/projet-cloud $ ssh-addDépendances
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- Le nom de l’entrée dans la config client OpenStack.
- Prefixe le nom de toutes les VMs.
- Image disque utilisée pour le déploiement des VMs.
- Le login utilisateur sous lequel se connecter à la VM.
- Le nom du gabarit (CPU/RAM/DISK) de VM à déployer.
- Le nom du réseau fournissant des IPs publiques.
- Le nom de la clef SSH à utiliser pour se connecter.
Tâches
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
}
}Sorties
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