mirror of
https://codeberg.org/scottslowe/learning-tools.git
synced 2026-03-11 09:04:37 +00:00
Update documentation
Update the documentation for the Swarm/etcd/Photon OS learning environment. Addresses #63. Signed-off-by: Scott S. Lowe <scott.lowe@scottlowe.org>
This commit is contained in:
parent
684fd439fa
commit
07f2fbad3b
1 changed files with 46 additions and 8 deletions
|
|
@ -4,29 +4,39 @@ These files were created to allow users to use Vagrant ([http://www.vagrantup.co
|
|||
|
||||
## Contents
|
||||
|
||||
* **ansible.cfg**: This is an Ansible configuration file to fine-tune how Ansible behaves when called by Vagrant. No edits to this file should be necessary.
|
||||
|
||||
* **cfg-docker.yml**: This Ansible playbook configures the Docker Engine in the learning environment. It's called automatically by Vagrant. No edits to this file should be needed.
|
||||
|
||||
* **cfg-etcd.yml**: This Ansible playbook installs and configures the etcd cluster. No edits to this file should be needed.
|
||||
|
||||
* **docker-tcp.socket**: This systemd unit enables the Docker Engine to listen on a network socket. You should not need to edit this file.
|
||||
|
||||
* **docker.service**: This systemd unit replaces the default systemd unit for Docker Engine on Photon OS hosts. No edits to this file should be needed.
|
||||
|
||||
* **docker.socket**: This systemd unit configures the local UNIX socket for Docker Engine. No changes to this file should be needed.
|
||||
|
||||
* **etcd.conf**: This is an Upstart script (written for Ubuntu) to start etcd. No modifications to this file should be necessary. This file is installed by the provisioning script called in `Vagrantfile`.
|
||||
|
||||
* **etcd.defaults.erb**: A template used by Vagrant to create machine-specific service defaults files for each node in the etcd cluster. The appropriate node-specific file is installed as `etcd` in the `/etc/default` directory on each node by the provisioning script called in `Vagrantfile`.
|
||||
|
||||
* **provision.sh**: This provisioning script is called by the shell provisioner in `Vagrantfile`. It downloads the etcd 2.0.9 release from GitHub, expands it, creates necessary directories, and places files in the appropriate locations. Finally it starts etcd ( or restarts it if already running ).
|
||||
* **machines.yml**: This YAML file contains a list of VM definitions. It is referenced by `Vagrantfile` when Vagrant instantiates the VMs. You may need to edit this file to provide appropriate IP addresses and other VM configuration data (see "Instructions" below).
|
||||
|
||||
* **README.md**: This file you're currently reading.
|
||||
|
||||
* **servers.yml**: This YAML file contains a list of VM definitions. It is referenced by `Vagrantfile` when Vagrant instantiates the VMs. You may need to edit this file to provide appropriate IP addresses and other VM configuration data (see "Instructions" below). _If you change the hostnames or IP addresses provided in this file, you **must** also edit the Upstart override files._
|
||||
|
||||
* **Vagrantfile**: This file is used by Vagrant to spin up the virtual machines. This file is fairly extensively commented to help explain what's happening. You should be able to use this file unchanged; all the VM configuration options are stored outside this file.
|
||||
* **Vagrantfile**: This file is used by Vagrant to spin up the virtual machines. This file is fairly extensively commented to help explain what's happening. You should be able to use this file unchanged; all the VM configuration options are stored outside this file in `machines.yml`.
|
||||
|
||||
## Instructions
|
||||
|
||||
These instructions assume you've already installed VirtualBox and Vagrant. Please refer to the documentation for those products for more information on installation or configuration.
|
||||
These instructions assume you've already installed your back-end virtualization provider (VirtualBox or VMware Fusion/Workstation), Vagrant, and any necessary Vagrant plugins (such as the VMware plugin). Please refer to the documentation for those products for more information on installation or configuration.
|
||||
|
||||
1. Use `vagrant box add` to install an Ubuntu 14.04 x64 box for the "virtualbox" provider. (In theory you should be able to use this Vagrant environment with VMware Workstation and VMware Fusion as well, with minor changes to the `Vagrantfile`.) If you don't already have a Vagrant box for Photon, use `vagrant box add` to download a Photon box as well.
|
||||
1. Use `vagrant box add` to install an Ubuntu 14.04 x64 box. The "bento/ubuntu-14.04" box is one good option with support for both VMware and VirtualBox. If you don't already have a Vagrant box for Photon, use `vagrant box add` to download a Photon box as well.
|
||||
|
||||
2. Place the files from the `swarm-etcd2-photon` directory of this GitHub repository (the "lowescott/learning-tools" repository) into a directory on your system. You can clone the entire "learning-tools" repository (using `git clone`), or just download the specific files from the `swarm-etcd2-photon` directory.
|
||||
|
||||
3. Edit `servers.yml` to ensure that the box specified in that file matches the Ubuntu 14.04 x64 base box you just installed and will be using. _I recommend that you do not change any other values in this file unless you know it is necessary._
|
||||
3. Edit `machines.yml` to ensure that the box specified in that file matches the Ubuntu 14.04 x64 base box you just installed and will be using. _I recommend that you do not change any other values in this file unless you know it is necessary._
|
||||
|
||||
4. From a terminal window, change into the directory where the files from this directory are stored and run `vagrant up` to bring up the VMs specified in `servers.yml` and `Vagrantfile`.
|
||||
4. From a terminal window, change into the directory where the files from this directory are stored and run `vagrant up` to bring up the VMs specified in `machines.yml` and `Vagrantfile`.
|
||||
|
||||
5. Once Vagrant has finished creating, booting, and provisioning each of the VMs and starting etcd, log into the first system ("etcd-01" by default) using `vagrant ssh etcd-01`.
|
||||
|
||||
|
|
@ -36,4 +46,32 @@ These instructions assume you've already installed VirtualBox and Vagrant. Pleas
|
|||
|
||||
This should return a list of three nodes as members of the etcd cluster. If you receive an error or don't see all three VMs listed, tear down the Vagrant environment with `vagrant destroy` and recreate the environment from scratch. If you continue to experience problems, open an issue here on GitHub (or file a pull request fixing the problem).
|
||||
|
||||
7. Log into the first Photon OS instance using `vagrant ssh photon-01`. Launch the first Swarm container:
|
||||
|
||||
docker run -d swarm join --addr=192.168.100.111:2375 etcd://192.168.100.101:2379/swarm
|
||||
|
||||
Make sure the IP address referenced by the `--addr=` parameter matches the IP address assigned to the Photon OS VM (which is pulled from the "ip_addr" key in `machines.yml`). Further, make sure the IP address in the "etcd://" URL matches the IP address assigned to one of the Ubuntu-based etcd cluster nodes.
|
||||
|
||||
8. Repeat step 7 with `photon-02` and `photon-03`, making sure to change the value of the `--addr=` parameter appropriately on each system. The default values from `machines.yml` are 192.168.100.111 (photon-01), 192.168.100.112 (photon-02), and 192.168.100.113 (photon-03).
|
||||
|
||||
9. On `photon-04`, launch the Swarm manager with this command:
|
||||
|
||||
docker run -d -p 8333:2375 swarm manage etcd://192.168.100.101:2379/swarm
|
||||
|
||||
The IP address specified in the "etcd://" URL should correspond to the IP address assigned to one of the Ubuntu-based etcd cluster nodes. Make note of the port exposed by the `-p` command and the IP address of the node on which you're running the Swarm manager. _This will be the endpoint against which you will run Docker commands against the cluster._
|
||||
|
||||
10. Verify the operation of the Swarm cluster by running this command (from any system that has connectivity to the Photon OS system running the Swarm manager container launched in the previous step):
|
||||
|
||||
docker -H tcp://192.168.100.114:8333 info
|
||||
|
||||
Docker should return information indicating that there are 3 containers running across 3 nodes, and then provide more information about each node and the containers running on that node.
|
||||
|
||||
11. Launch an Nginx container somewhere on the cluster with this command:
|
||||
|
||||
docker -H tcp://192.168.100.114:8333 run -d --name www -p 80:80 nginx
|
||||
|
||||
If everything is working as expected, Docker will launch an Nginx container on one of the Photon OS nodes in the Swarm cluster. Re-running the command from step 10 can help track it down, as well as using this command:
|
||||
|
||||
docker -H tcp://192.168.100.114:8333 ps
|
||||
|
||||
Enjoy!
|
||||
|
|
|
|||
Loading…
Reference in a new issue