diff --git a/README.md b/README.md index 81b2452..ac0fed1 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,47 @@ # RVN - TP2.2 : Ordonnancement de services sur une grappe 1. Provisionner des VMs **sur notre WAN** avec [Vagrant](https://developer.hashicorp.com/vagrant/docs) -2. Déployer un cluster [Consul](https://developer.hashicorp.com/consul/docs) -3. Déployer un service avec Docker et le surveiller avec Consul -4. Déployer des services avec [Nomad](https://developer.hashicorp.com/nomad/docs) - +2. Déployer [Consul](https://developer.hashicorp.com/consul/docs) et [Nomad](https://developer.hashicorp.com/nomad/docs) +3. Déployer des services ## 1. Provisionner des VMs +1. Vérifiez le bon fonctionnement de notre WAN +2. Écrivez chacun un [Vagrantfile](./Vagrantfile) pour lancer une VM sur le WAN, en suivant le schéma d'adressage suivant : + | Continent| IP sur continent | IP VM | |--------- | ------------------ | ---------------- | | Amerique | `10.13.1.3/24` | `10.13.1.31/24` | | Europe | `10.13.2.1/24` | `10.13.2.11/24` | | Asie | `10.13.3.4/24` | `10.13.3.41/24` | -Vous pouvez vous inspirer de : +3. Vérifiez que les machines puissent discuter entre elles. -* [./Vagrantfile](./Vagrantfile) -* [./install_nomad_consul.sh](./install_nomad_consul.sh) +## 2. Déployer Consul et Nomad + +1. Modifiez votre `Vagrantfile` pour qu'il provisionne votre VM avec [Consul](https://developer.hashicorp.com/consul/docs) et [Nomad](https://developer.hashicorp.com/nomad/docs) + + Vous pouvez aussi lancer des scripts sur les VMs sans rebooter, par exemple avec : + + ssh ... ENV=xxx 'bash -s' < script.sh + +Inspiration : [./install_nomad_consul.sh](./install_nomad_consul.sh) + +Chaque continent est un "datacenter" : `am`, `eu`, `as`. Il nous faut un Consul/Nomad serveur par zone géographique, les autres sont clients (configuration manuelle dans les `.hcl`). + +## Docs + +### Consul + +* Follow this guide to provision a Vagrant VM with Consul: https://developer.hashicorp.com/consul/tutorials/certification-associate-tutorials/get-started-create-datacenter + +* Vagrant can auto-install Docker if you ask it to run containers: https://developer.hashicorp.com/vagrant/docs/provisioning/docker + +* Deployment guide: https://developer.hashicorp.com/consul/tutorials/production-deploy/deployment-guide + +* Register services to Consul: https://developer.hashicorp.com/consul/tutorials/get-started-vms/virtual-machine-gs-service-discovery + +### Nomad + +* Deployment guide: https://developer.hashicorp.com/nomad/tutorials/enterprise/production-deployment-guide-vm-with-consul diff --git a/Vagrantfile b/Vagrantfile index c1ac7ed..2146e04 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,6 +1,13 @@ # -*- mode: ruby -*- # vi: set ft=ruby : +# Script de configuration Nomad +# Fait par A. Luxey-Bitri en décembre 2023 +# Inspiré des docs Hashcorp +# Licence : Domaine public + +# ÉTUDIANTS : Ça peut vous donner quelques idées, mais le script est périmé, inspirez-vous plutôt `install_nomad_consul.sh` + # Provisioning $script = <<-'SCRIPT' echo "## Provisioning VM ##" @@ -60,60 +67,4 @@ Vagrant.configure("2") do |config| env: {'CONSUL_VERSION' => CONSUL_VERSION} config.vm.box_check_update = false - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine. In the example below, - # accessing "localhost:8080" will access port 80 on the guest machine. - # NOTE: This will enable public access to the opened port - # config.vm.network "forwarded_port", guest: 80, host: 8080 - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine and only allow access - # via 127.0.0.1 to disable public access - # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" - - # Create a private network, which allows host-only access to the machine - # using a specific IP. - # config.vm.network "private_network", ip: "192.168.33.10" - - # Create a public network, which generally matched to bridged network. - # Bridged networks make the machine appear as another physical device on - # your network. - # config.vm.network "public_network" - - # Share an additional folder to the guest VM. The first argument is - # the path on the host to the actual folder. The second argument is - # the path on the guest to mount the folder. And the optional third - # argument is a set of non-required options. - # config.vm.synced_folder "../data", "/vagrant_data" - - # Disable the default share of the current code directory. Doing this - # provides improved isolation between the vagrant box and your host - # by making sure your Vagrantfile isn't accessable to the vagrant box. - # If you use this you may want to enable additional shared subfolders as - # shown above. - # config.vm.synced_folder ".", "/vagrant", disabled: true - - # Provider-specific configuration so you can fine-tune various - # backing providers for Vagrant. These expose provider-specific options. - # Example for VirtualBox: - # - # config.vm.provider "virtualbox" do |vb| - # # Display the VirtualBox GUI when booting the machine - # vb.gui = true - # - # # Customize the amount of memory on the VM: - # vb.memory = "1024" - # end - # - # View the documentation for the provider you are using for more - # information on available options. - - # Enable provisioning with a shell script. Additional provisioners such as - # Ansible, Chef, Docker, Puppet and Salt are also available. Please see the - # documentation for more information about their specific syntax and use. - # config.vm.provision "shell", inline: <<-SHELL - # apt-get update - # apt-get install -y apache2 - # SHELL end