From ca1ae3f2083f0da38360eb78bc1b5334a686a2c5 Mon Sep 17 00:00:00 2001 From: LRubin Date: Tue, 25 Oct 2016 12:02:46 -0700 Subject: [PATCH] Fix formatting indentation --- swarm/swarm_at_scale/deploy-infra.md | 247 ++++++++++++++------------- 1 file changed, 125 insertions(+), 122 deletions(-) diff --git a/swarm/swarm_at_scale/deploy-infra.md b/swarm/swarm_at_scale/deploy-infra.md index cc40054f5e..2e886cf510 100644 --- a/swarm/swarm_at_scale/deploy-infra.md +++ b/swarm/swarm_at_scale/deploy-infra.md @@ -59,42 +59,43 @@ href="https://www.consul.io/" target="blank">Consul container. 1. Create a "machine" named `keystore`. - ```bash - $ docker-machine create -d virtualbox --virtualbox-memory "2000" \ - --engine-opt="label=com.function=consul" keystore - ``` + ```bash + $ docker-machine create -d virtualbox --virtualbox-memory "2000" \ + --engine-opt="label=com.function=consul" keystore + ``` - You can set options for the Engine daemon with the `--engine-opt` flag. You'll - use it to label this Engine instance. + You can set options for the Engine daemon with the `--engine-opt` flag. You'll + use it to label this Engine instance. 2. Set your local shell to the `keystore` Docker host. - ```bash - $ eval $(docker-machine env keystore) - ``` + ```bash + $ eval $(docker-machine env keystore) + ``` + 3. Run the `consul` container. - ```bash - $ docker run --restart=unless-stopped -d -p 8500:8500 -h consul progrium/consul -server -bootstrap - ``` + ```bash + $ docker run --restart=unless-stopped -d -p 8500:8500 -h consul progrium/consul -server -bootstrap + ``` - The `-p` flag publishes port 8500 on the container which is where the Consul - server listens. The server also has several other ports exposed which you can - see by running `docker ps`. + The `-p` flag publishes port 8500 on the container which is where the Consul + server listens. The server also has several other ports exposed which you can + see by running `docker ps`. - ```bash - $ docker ps - CONTAINER ID IMAGE ... PORTS NAMES - 372ffcbc96ed progrium/consul ... 53/tcp, 53/udp, 8300-8302/tcp, 8400/tcp, 8301-8302/udp, 0.0.0.0:8500->8500/tcp dreamy_ptolemy - ``` + ```bash + $ docker ps + CONTAINER ID IMAGE ... PORTS NAMES + 372ffcbc96ed progrium/consul ... 53/tcp, 53/udp, 8300-8302/tcp, 8400/tcp, 8301-8302/udp, 0.0.0.0:8500->8500/tcp dreamy_ptolemy + ``` 4. Use a `curl` command test the server by listing the nodes. - ```bash - $ curl $(docker-machine ip keystore):8500/v1/catalog/nodes - [{"Node":"consul","Address":"172.17.0.2"}] - ``` + ```bash + $ curl $(docker-machine ip keystore):8500/v1/catalog/nodes + [{"Node":"consul","Address":"172.17.0.2"}] + ``` ## Task 2. Create the Swarm manager @@ -112,62 +113,62 @@ support the container network you'll create later. 1. Create the `manager` host. - ```bash - $ docker-machine create -d virtualbox --virtualbox-memory "2000" \ - --engine-opt="label=com.function=manager" \ - --engine-opt="cluster-store=consul://$(docker-machine ip keystore):8500" \ - --engine-opt="cluster-advertise=eth1:2376" manager - ``` + ```bash + $ docker-machine create -d virtualbox --virtualbox-memory "2000" \ + --engine-opt="label=com.function=manager" \ + --engine-opt="cluster-store=consul://$(docker-machine ip keystore):8500" \ + --engine-opt="cluster-advertise=eth1:2376" manager + ``` - You also give the daemon a `manager` label. + You also give the daemon a `manager` label. 2. Set your local shell to the `manager` Docker host. - ```bash - $ eval $(docker-machine env manager) - ``` + ```bash + $ eval $(docker-machine env manager) + ``` 3. Start the Swarm manager process. - ```bash - $ docker run --restart=unless-stopped -d -p 3376:2375 \ - -v /var/lib/boot2docker:/certs:ro \ - swarm manage --tlsverify \ - --tlscacert=/certs/ca.pem \ - --tlscert=/certs/server.pem \ - --tlskey=/certs/server-key.pem \ - consul://$(docker-machine ip keystore):8500 - ``` + ```bash + $ docker run --restart=unless-stopped -d -p 3376:2375 \ + -v /var/lib/boot2docker:/certs:ro \ + swarm manage --tlsverify \ + --tlscacert=/certs/ca.pem \ + --tlscert=/certs/server.pem \ + --tlskey=/certs/server-key.pem \ + consul://$(docker-machine ip keystore):8500 + ``` - This command uses the TLS certificates created for the `boot2docker.iso` or - the manager. This is key for the manager when it connects to other machines - in the cluster. + This command uses the TLS certificates created for the `boot2docker.iso` or + the manager. This is key for the manager when it connects to other machines + in the cluster. 4. Test your work by using displaying the Docker daemon logs from the host. - ```bash - $ docker-machine ssh manager - <-- output snipped --> - docker@manager:~$ tail /var/lib/boot2docker/docker.log - time="2016-04-06T23:11:56.481947896Z" level=debug msg="Calling GET /v1.15/version" - time="2016-04-06T23:11:56.481984742Z" level=debug msg="GET /v1.15/version" - time="2016-04-06T23:12:13.070231761Z" level=debug msg="Watch triggered with 1 nodes" discovery=consul - time="2016-04-06T23:12:33.069387215Z" level=debug msg="Watch triggered with 1 nodes" discovery=consul - time="2016-04-06T23:12:53.069471308Z" level=debug msg="Watch triggered with 1 nodes" discovery=consul - time="2016-04-06T23:13:13.069512320Z" level=debug msg="Watch triggered with 1 nodes" discovery=consul - time="2016-04-06T23:13:33.070021418Z" level=debug msg="Watch triggered with 1 nodes" discovery=consul - time="2016-04-06T23:13:53.069395005Z" level=debug msg="Watch triggered with 1 nodes" discovery=consul - time="2016-04-06T23:14:13.071417551Z" level=debug msg="Watch triggered with 1 nodes" discovery=consul - time="2016-04-06T23:14:33.069843647Z" level=debug msg="Watch triggered with 1 nodes" discovery=consul - ``` + ```bash + $ docker-machine ssh manager + <-- output snipped --> + docker@manager:~$ tail /var/lib/boot2docker/docker.log + time="2016-04-06T23:11:56.481947896Z" level=debug msg="Calling GET /v1.15/version" + time="2016-04-06T23:11:56.481984742Z" level=debug msg="GET /v1.15/version" + time="2016-04-06T23:12:13.070231761Z" level=debug msg="Watch triggered with 1 nodes" discovery=consul + time="2016-04-06T23:12:33.069387215Z" level=debug msg="Watch triggered with 1 nodes" discovery=consul + time="2016-04-06T23:12:53.069471308Z" level=debug msg="Watch triggered with 1 nodes" discovery=consul + time="2016-04-06T23:13:13.069512320Z" level=debug msg="Watch triggered with 1 nodes" discovery=consul + time="2016-04-06T23:13:33.070021418Z" level=debug msg="Watch triggered with 1 nodes" discovery=consul + time="2016-04-06T23:13:53.069395005Z" level=debug msg="Watch triggered with 1 nodes" discovery=consul + time="2016-04-06T23:14:13.071417551Z" level=debug msg="Watch triggered with 1 nodes" discovery=consul + time="2016-04-06T23:14:33.069843647Z" level=debug msg="Watch triggered with 1 nodes" discovery=consul + ``` - The output indicates that the `consul` and the `manager` are communicating correctly. + The output indicates that the `consul` and the `manager` are communicating correctly. 5. Exit the Docker host. - ```bash - docker@manager:~$ exit - ``` + ```bash + docker@manager:~$ exit + ``` ## Task 3. Add the load balancer @@ -177,58 +178,60 @@ loadbalancer. Before you build the load balancer host, you'll create the configuration you'll use for Nginx. 1. On your local host, create a `config` directory. + 2. Change directories to the `config` directory. - ```bash - $ cd config - ``` + ```bash + $ cd config + ``` + 3. Get the IP address of the Swarm manager host. - For example: + For example: - ```bash - $ docker-machine ip manager - 192.168.99.101 - ``` + ```bash + $ docker-machine ip manager + 192.168.99.101 + ``` 5. Use your favorite editor to create a `config.toml` file and add this content to the file: - ```json - ListenAddr = ":8080" - DockerURL = "tcp://SWARM_MANAGER_IP:3376" - TLSCACert = "/var/lib/boot2docker/ca.pem" - TLSCert = "/var/lib/boot2docker/server.pem" - TLSKey = "/var/lib/boot2docker/server-key.pem" + ```json + ListenAddr = ":8080" + DockerURL = "tcp://SWARM_MANAGER_IP:3376" + TLSCACert = "/var/lib/boot2docker/ca.pem" + TLSCert = "/var/lib/boot2docker/server.pem" + TLSKey = "/var/lib/boot2docker/server-key.pem" - [[Extensions]] - Name = "nginx" - ConfigPath = "/etc/conf/nginx.conf" - PidPath = "/etc/conf/nginx.pid" - MaxConn = 1024 - Port = 80 - ``` + [[Extensions]] + Name = "nginx" + ConfigPath = "/etc/conf/nginx.conf" + PidPath = "/etc/conf/nginx.pid" + MaxConn = 1024 + Port = 80 + ``` 6. In the configuration, replace the `SWARM_MANAGER_IP` with the `manager` IP you got in Step 4. - You use this value because the load balancer listens on the manager's event - stream. + You use this value because the load balancer listens on the manager's event + stream. 7. Save and close the `config.toml` file. 8. Create a machine for the load balancer. - ```bash - $ docker-machine create -d virtualbox --virtualbox-memory "2000" \ - --engine-opt="label=com.function=interlock" loadbalancer - ``` + ```bash + $ docker-machine create -d virtualbox --virtualbox-memory "2000" \ + --engine-opt="label=com.function=interlock" loadbalancer + ``` 9. Switch the environment to the `loadbalancer`. - ```bash - $ eval $(docker-machine env loadbalancer) - ``` + ```bash + $ eval $(docker-machine env loadbalancer) + ``` 10. Start an `interlock` container running. @@ -312,38 +315,38 @@ commands below, notice the label you are applying to each node. 1. Create the `frontend01` host and add it to the Swarm cluster. - ```bash - $ docker-machine create -d virtualbox --virtualbox-memory "2000" \ - --engine-opt="label=com.function=frontend01" \ - --engine-opt="cluster-store=consul://$(docker-machine ip keystore):8500" \ - --engine-opt="cluster-advertise=eth1:2376" frontend01 - $ eval $(docker-machine env frontend01) - $ docker run -d swarm join --addr=$(docker-machine ip frontend01):2376 consul://$(docker-machine ip keystore):8500 - ``` + ```bash + $ docker-machine create -d virtualbox --virtualbox-memory "2000" \ + --engine-opt="label=com.function=frontend01" \ + --engine-opt="cluster-store=consul://$(docker-machine ip keystore):8500" \ + --engine-opt="cluster-advertise=eth1:2376" frontend01 + $ eval $(docker-machine env frontend01) + $ docker run -d swarm join --addr=$(docker-machine ip frontend01):2376 consul://$(docker-machine ip keystore):8500 + ``` 2. Create the `frontend02` VM. - ```bash - $ docker-machine create -d virtualbox --virtualbox-memory "2000" \ - --engine-opt="label=com.function=frontend02" \ - --engine-opt="cluster-store=consul://$(docker-machine ip keystore):8500" \ - --engine-opt="cluster-advertise=eth1:2376" frontend02 - $ eval $(docker-machine env frontend02) - $ docker run -d swarm join --addr=$(docker-machine ip frontend02):2376 consul://$(docker-machine ip keystore):8500 - ``` + ```bash + $ docker-machine create -d virtualbox --virtualbox-memory "2000" \ + --engine-opt="label=com.function=frontend02" \ + --engine-opt="cluster-store=consul://$(docker-machine ip keystore):8500" \ + --engine-opt="cluster-advertise=eth1:2376" frontend02 + $ eval $(docker-machine env frontend02) + $ docker run -d swarm join --addr=$(docker-machine ip frontend02):2376 consul://$(docker-machine ip keystore):8500 + ``` 3. Create the `worker01` VM. - ```bash - $ docker-machine create -d virtualbox --virtualbox-memory "2000" \ - --engine-opt="label=com.function=worker01" \ - --engine-opt="cluster-store=consul://$(docker-machine ip keystore):8500" \ - --engine-opt="cluster-advertise=eth1:2376" worker01 - $ eval $(docker-machine env worker01) - $ docker run -d swarm join --addr=$(docker-machine ip worker01):2376 consul://$(docker-machine ip keystore):8500 - ``` + ```bash + $ docker-machine create -d virtualbox --virtualbox-memory "2000" \ + --engine-opt="label=com.function=worker01" \ + --engine-opt="cluster-store=consul://$(docker-machine ip keystore):8500" \ + --engine-opt="cluster-advertise=eth1:2376" worker01 + $ eval $(docker-machine env worker01) + $ docker run -d swarm join --addr=$(docker-machine ip worker01):2376 consul://$(docker-machine ip keystore):8500 + ``` -4. Create the `dbstore` VM. +4. Create the `dbstore` VM. ```bash $ docker-machine create -d virtualbox --virtualbox-memory "2000" \ @@ -354,7 +357,7 @@ commands below, notice the label you are applying to each node. $ docker run -d swarm join --addr=$(docker-machine ip dbstore):2376 consul://$(docker-machine ip keystore):8500 ``` -5. Check your work. +5. Check your work. At this point, you have deployed on the infrastructure you need to run the application. Test this now by listing the running machines: @@ -371,7 +374,7 @@ commands below, notice the label you are applying to each node. worker01 * virtualbox Running tcp://192.168.99.110:2376 v1.10.3 ``` -6. Make sure the Swarm manager sees all your nodes. +6. Make sure the Swarm manager sees all your nodes. ``` $ docker -H $(docker-machine ip manager):3376 info