Merge pull request #270 from danix800/fix-codeblock-format

Fix codeblock format in swarm/swarm_at_scale/deploy-app.md.
This commit is contained in:
John Mulhausen 2016-10-19 10:38:00 -07:00 committed by GitHub
commit 3c5a664534
1 changed files with 203 additions and 203 deletions

View File

@ -36,41 +36,41 @@ on the Swarm `manager` instance.
1. Direct your local environment to the Swarm manager host. 1. Direct your local environment to the Swarm manager host.
```bash ```bash
$ eval $(docker-machine env manager) $ eval $(docker-machine env manager)
``` ```
You can create the network on a cluster node at the network is visible on You can create the network on a cluster node at the network is visible on
them all. them all.
2. Create the `voteapp` container network. 2. Create the `voteapp` container network.
```bash ```bash
$ docker network create -d overlay voteapp $ docker network create -d overlay voteapp
``` ```
3. Switch to the db store. 3. Switch to the db store.
```bash ```bash
$ eval $(docker-machine env dbstore) $ eval $(docker-machine env dbstore)
``` ```
4. Verify you can see the new network from the dbstore node. 4. Verify you can see the new network from the dbstore node.
```bash ```bash
$ docker network ls $ docker network ls
NETWORK ID NAME DRIVER NETWORK ID NAME DRIVER
e952814f610a voteapp overlay e952814f610a voteapp overlay
1f12c5e7bcc4 bridge bridge 1f12c5e7bcc4 bridge bridge
3ca38e887cd8 none null 3ca38e887cd8 none null
3da57c44586b host host 3da57c44586b host host
``` ```
3. Create a container volume called `db-data`. 3. Create a container volume called `db-data`.
```bash ```bash
$ docker volume create --name db-data $ docker volume create --name db-data
``` ```
## Task 2. Start the containerized microservices ## Task 2. Start the containerized microservices
@ -98,71 +98,71 @@ command below, look for the value constraint.
1. Start a Postgres database container. 1. Start a Postgres database container.
```bash ```bash
$ docker -H $(docker-machine ip manager):3376 run -t -d \ $ docker -H $(docker-machine ip manager):3376 run -t -d \
-v db-data:/var/lib/postgresql/data \ -v db-data:/var/lib/postgresql/data \
-e constraint:com.function==dbstore \ -e constraint:com.function==dbstore \
--net="voteapp" \ --net="voteapp" \
--name db postgres:9.4 --name db postgres:9.4
``` ```
6. Start the Redis container. 6. Start the Redis container.
```bash ```bash
$ docker -H $(docker-machine ip manager):3376 run -t -d \ $ docker -H $(docker-machine ip manager):3376 run -t -d \
-p 6379:6379 \ -p 6379:6379 \
-e constraint:com.function==dbstore \ -e constraint:com.function==dbstore \
--net="voteapp" \ --net="voteapp" \
--name redis redis --name redis redis
``` ```
The `redis` name is important so don't change it. The `redis` name is important so don't change it.
7. Start the worker application 7. Start the worker application
```bash ```bash
$ docker -H $(docker-machine ip manager):3376 run -t -d \ $ docker -H $(docker-machine ip manager):3376 run -t -d \
-e constraint:com.function==worker01 \ -e constraint:com.function==worker01 \
--net="voteapp" \ --net="voteapp" \
--net-alias=workers \ --net-alias=workers \
--name worker01 docker/example-voting-app-worker --name worker01 docker/example-voting-app-worker
``` ```
6. Start the results application. 6. Start the results application.
```bash ```bash
$ docker -H $(docker-machine ip manager):3376 run -t -d \ $ docker -H $(docker-machine ip manager):3376 run -t -d \
-p 80:80 \ -p 80:80 \
--label=interlock.hostname=results \ --label=interlock.hostname=results \
--label=interlock.domain=myenterprise.com \ --label=interlock.domain=myenterprise.com \
-e constraint:com.function==dbstore \ -e constraint:com.function==dbstore \
--net="voteapp" \ --net="voteapp" \
--name results-app docker/example-voting-app-result-app --name results-app docker/example-voting-app-result-app
``` ```
7. Start the voting application twice; once on each frontend node. 7. Start the voting application twice; once on each frontend node.
```bash ```bash
$ docker -H $(docker-machine ip manager):3376 run -t -d \ $ docker -H $(docker-machine ip manager):3376 run -t -d \
-p 80:80 \ -p 80:80 \
--label=interlock.hostname=vote \ --label=interlock.hostname=vote \
--label=interlock.domain=myenterprise.com \ --label=interlock.domain=myenterprise.com \
-e constraint:com.function==frontend01 \ -e constraint:com.function==frontend01 \
--net="voteapp" \ --net="voteapp" \
--name voting-app01 docker/example-voting-app-voting-app --name voting-app01 docker/example-voting-app-voting-app
``` ```
And again on the other frontend node. And again on the other frontend node.
```bash ```bash
$ docker -H $(docker-machine ip manager):3376 run -t -d \ $ docker -H $(docker-machine ip manager):3376 run -t -d \
-p 80:80 \ -p 80:80 \
--label=interlock.hostname=vote \ --label=interlock.hostname=vote \
--label=interlock.domain=myenterprise.com \ --label=interlock.domain=myenterprise.com \
-e constraint:com.function==frontend02 \ -e constraint:com.function==frontend02 \
--net="voteapp" \ --net="voteapp" \
--name voting-app02 docker/example-voting-app-voting-app --name voting-app02 docker/example-voting-app-voting-app
``` ```
## Task 3. Check your work and update /etc/hosts ## Task 3. Check your work and update /etc/hosts
@ -173,68 +173,68 @@ allow you to take advantage of the loadbalancer.
1. Change to the `loadbalancer` node. 1. Change to the `loadbalancer` node.
```bash ```bash
$ eval $(docker-machine env loadbalancer) $ eval $(docker-machine env loadbalancer)
``` ```
2. Check your work by reviewing the configuration of nginx. 2. Check your work by reviewing the configuration of nginx.
```html ```html
$ docker exec interlock cat /etc/conf/nginx.conf $ docker exec interlock cat /etc/conf/nginx.conf
... output snipped ... ... output snipped ...
upstream results.myenterprise.com { upstream results.myenterprise.com {
zone results.myenterprise.com_backend 64k; zone results.myenterprise.com_backend 64k;
server 192.168.99.111:80; server 192.168.99.111:80;
} }
server { server {
listen 80; listen 80;
server_name results.myenterprise.com; server_name results.myenterprise.com;
location / { location / {
proxy_pass http://results.myenterprise.com; proxy_pass http://results.myenterprise.com;
} }
} }
upstream vote.myenterprise.com { upstream vote.myenterprise.com {
zone vote.myenterprise.com_backend 64k; zone vote.myenterprise.com_backend 64k;
server 192.168.99.109:80; server 192.168.99.109:80;
server 192.168.99.108:80; server 192.168.99.108:80;
} }
server { server {
listen 80; listen 80;
server_name vote.myenterprise.com; server_name vote.myenterprise.com;
location / { location / {
proxy_pass http://vote.myenterprise.com; proxy_pass http://vote.myenterprise.com;
} }
} }
include /etc/conf/conf.d/*.conf; include /etc/conf/conf.d/*.conf;
} }
``` ```
The `http://vote.myenterprise.com` site configuration should point to either The `http://vote.myenterprise.com` site configuration should point to either
frontend node. Requests to `http://results.myenterprise.com` go just to the frontend node. Requests to `http://results.myenterprise.com` go just to the
single `dbstore` node where the `example-voting-app-result-app` is running. single `dbstore` node where the `example-voting-app-result-app` is running.
8. On your local host, edit `/etc/hosts` file add the resolution for both these 3. On your local host, edit `/etc/hosts` file add the resolution for both these
sites. sites.
9. Save and close the `/etc/hosts` file. 4. Save and close the `/etc/hosts` file.
10. Restart the `nginx` container. 5. Restart the `nginx` container.
Manual restart is required because the current Interlock server is not forcing an Manual restart is required because the current Interlock server is not forcing an
Nginx configuration reload. Nginx configuration reload.
```bash ```bash
$ docker restart nginx $ docker restart nginx
``` ```
## Task 4. Test the application ## Task 4. Test the application
@ -282,24 +282,24 @@ the containers at once. This extra credit
in the `docker-compose.yml` file. For example, in the `docker-compose.yml` file. For example,
this command: this command:
```bash ```bash
$ docker -H $(docker-machine ip manager):3376 run -t -d \ $ docker -H $(docker-machine ip manager):3376 run -t -d \
-e constraint:com.function==worker01 \ -e constraint:com.function==worker01 \
--net="voteapp" \ --net="voteapp" \
--net-alias=workers \ --net-alias=workers \
--name worker01 docker/example-voting-app-worker --name worker01 docker/example-voting-app-worker
``` ```
Becomes this in a Compose file. Becomes this in a Compose file.
``` ```bash
worker: worker:
image: docker/example-voting-app-worker image: docker/example-voting-app-worker
networks: networks:
voteapp: voteapp:
aliases: aliases:
- workers - workers
``` ```
In general, Compose starts services in reverse order they appear in the file. In general, Compose starts services in reverse order they appear in the file.
So, if you want a service to start before all the others, make it the last So, if you want a service to start before all the others, make it the last
@ -313,108 +313,108 @@ result file</a>
5. Set `DOCKER_HOST` to the Swarm manager. 5. Set `DOCKER_HOST` to the Swarm manager.
```bash ```bash
$ DOCKER_HOST=$(docker-machine ip manager):3376 $ DOCKER_HOST=$(docker-machine ip manager):3376
``` ```
6. In the same directory as your `docker-compose.yml` file, start the services. 6. In the same directory as your `docker-compose.yml` file, start the services.
```bash ```bash
$ docker-compose up -d $ docker-compose up -d
Creating network "scale_voteapp" with the default driver Creating network "scale_voteapp" with the default driver
Creating volume "scale_db-data" with default driver Creating volume "scale_db-data" with default driver
Pulling db (postgres:9.4)... Pulling db (postgres:9.4)...
worker01: Pulling postgres:9.4... : downloaded worker01: Pulling postgres:9.4... : downloaded
dbstore: Pulling postgres:9.4... : downloaded dbstore: Pulling postgres:9.4... : downloaded
frontend01: Pulling postgres:9.4... : downloaded frontend01: Pulling postgres:9.4... : downloaded
frontend02: Pulling postgres:9.4... : downloaded frontend02: Pulling postgres:9.4... : downloaded
Creating db Creating db
Pulling redis (redis:latest)... Pulling redis (redis:latest)...
dbstore: Pulling redis:latest... : downloaded dbstore: Pulling redis:latest... : downloaded
frontend01: Pulling redis:latest... : downloaded frontend01: Pulling redis:latest... : downloaded
frontend02: Pulling redis:latest... : downloaded frontend02: Pulling redis:latest... : downloaded
worker01: Pulling redis:latest... : downloaded worker01: Pulling redis:latest... : downloaded
Creating redis Creating redis
Pulling worker (docker/example-voting-app-worker:latest)... Pulling worker (docker/example-voting-app-worker:latest)...
dbstore: Pulling docker/example-voting-app-worker:latest... : downloaded dbstore: Pulling docker/example-voting-app-worker:latest... : downloaded
frontend01: Pulling docker/example-voting-app-worker:latest... : downloaded frontend01: Pulling docker/example-voting-app-worker:latest... : downloaded
frontend02: Pulling docker/example-voting-app-worker:latest... : downloaded frontend02: Pulling docker/example-voting-app-worker:latest... : downloaded
worker01: Pulling docker/example-voting-app-worker:latest... : downloaded worker01: Pulling docker/example-voting-app-worker:latest... : downloaded
Creating scale_worker_1 Creating scale_worker_1
Pulling voting-app (docker/example-voting-app-voting-app:latest)... Pulling voting-app (docker/example-voting-app-voting-app:latest)...
dbstore: Pulling docker/example-voting-app-voting-app:latest... : downloaded dbstore: Pulling docker/example-voting-app-voting-app:latest... : downloaded
frontend01: Pulling docker/example-voting-app-voting-app:latest... : downloaded frontend01: Pulling docker/example-voting-app-voting-app:latest... : downloaded
frontend02: Pulling docker/example-voting-app-voting-app:latest... : downloaded frontend02: Pulling docker/example-voting-app-voting-app:latest... : downloaded
worker01: Pulling docker/example-voting-app-voting-app:latest... : downloaded worker01: Pulling docker/example-voting-app-voting-app:latest... : downloaded
Creating scale_voting-app_1 Creating scale_voting-app_1
Pulling result-app (docker/example-voting-app-result-app:latest)... Pulling result-app (docker/example-voting-app-result-app:latest)...
dbstore: Pulling docker/example-voting-app-result-app:latest... : downloaded dbstore: Pulling docker/example-voting-app-result-app:latest... : downloaded
frontend01: Pulling docker/example-voting-app-result-app:latest... : downloaded frontend01: Pulling docker/example-voting-app-result-app:latest... : downloaded
frontend02: Pulling docker/example-voting-app-result-app:latest... : downloaded frontend02: Pulling docker/example-voting-app-result-app:latest... : downloaded
worker01: Pulling docker/example-voting-app-result-app:latest... : downloaded worker01: Pulling docker/example-voting-app-result-app:latest... : downloaded
Creating scale_result-app_1 Creating scale_result-app_1
``` ```
9. Use the `docker ps` command to see the containers on the Swarm cluster. 7. Use the `docker ps` command to see the containers on the Swarm cluster.
```bash ```bash
$ docker -H $(docker-machine ip manager):3376 ps $ docker -H $(docker-machine ip manager):3376 ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b71555033caa docker/example-voting-app-result-app "node server.js" 6 seconds ago Up 4 seconds 192.168.99.104:32774->80/tcp frontend01/scale_result-app_1 b71555033caa docker/example-voting-app-result-app "node server.js" 6 seconds ago Up 4 seconds 192.168.99.104:32774->80/tcp frontend01/scale_result-app_1
cf29ea21475d docker/example-voting-app-worker "/usr/lib/jvm/java-7-" 6 seconds ago Up 4 seconds worker01/scale_worker_1 cf29ea21475d docker/example-voting-app-worker "/usr/lib/jvm/java-7-" 6 seconds ago Up 4 seconds worker01/scale_worker_1
98414cd40ab9 redis "/entrypoint.sh redis" 7 seconds ago Up 5 seconds 192.168.99.105:32774->6379/tcp frontend02/redis 98414cd40ab9 redis "/entrypoint.sh redis" 7 seconds ago Up 5 seconds 192.168.99.105:32774->6379/tcp frontend02/redis
1f214acb77ae postgres:9.4 "/docker-entrypoint.s" 7 seconds ago Up 5 seconds 5432/tcp frontend01/db 1f214acb77ae postgres:9.4 "/docker-entrypoint.s" 7 seconds ago Up 5 seconds 5432/tcp frontend01/db
1a4b8f7ce4a9 docker/example-voting-app-voting-app "python app.py" 7 seconds ago Up 5 seconds 192.168.99.107:32772->80/tcp dbstore/scale_voting-app_1 1a4b8f7ce4a9 docker/example-voting-app-voting-app "python app.py" 7 seconds ago Up 5 seconds 192.168.99.107:32772->80/tcp dbstore/scale_voting-app_1
``` ```
When you started the services manually, you had a When you started the services manually, you had a
`voting-app` instances running on two frontend servers. How many `voting-app` instances running on two frontend servers. How many
do you have now? do you have now?
10. Scale your application up by adding some `voting-app` instances. 8. Scale your application up by adding some `voting-app` instances.
```bash ```bash
$ docker-compose scale voting-app=3 $ docker-compose scale voting-app=3
Creating and starting 2 ... done Creating and starting 2 ... done
Creating and starting 3 ... done Creating and starting 3 ... done
``` ```
After you scale up, list the containers on the cluster again. After you scale up, list the containers on the cluster again.
7. Change to the `loadbalancer` node. 9. Change to the `loadbalancer` node.
```bash ```bash
$ eval $(docker-machine env loadbalancer) $ eval $(docker-machine env loadbalancer)
``` ```
7. Restart the Nginx server. 10. Restart the Nginx server.
```bash ```bash
$ docker restart nginx $ docker restart nginx
``` ```
8. Check your work again by visiting the `http://vote.myenterprise.com` and 11. Check your work again by visiting the `http://vote.myenterprise.com` and
`http://results.myenterprise.com` again. `http://results.myenterprise.com` again.
9. You can view the logs on an individual container. 12. You can view the logs on an individual container.
```bash ```bash
$ docker logs scale_voting-app_1 $ docker logs scale_voting-app_1
* Running on http://0.0.0.0:80/ (Press CTRL+C to quit) * Running on http://0.0.0.0:80/ (Press CTRL+C to quit)
* Restarting with stat * Restarting with stat
* Debugger is active! * Debugger is active!
* Debugger pin code: 285-809-660 * Debugger pin code: 285-809-660
192.168.99.103 - - [11/Apr/2016 17:15:44] "GET / HTTP/1.0" 200 - 192.168.99.103 - - [11/Apr/2016 17:15:44] "GET / HTTP/1.0" 200 -
192.168.99.103 - - [11/Apr/2016 17:15:44] "GET /static/stylesheets/style.css HTTP/1.0" 304 - 192.168.99.103 - - [11/Apr/2016 17:15:44] "GET /static/stylesheets/style.css HTTP/1.0" 304 -
192.168.99.103 - - [11/Apr/2016 17:15:45] "GET /favicon.ico HTTP/1.0" 404 - 192.168.99.103 - - [11/Apr/2016 17:15:45] "GET /favicon.ico HTTP/1.0" 404 -
192.168.99.103 - - [11/Apr/2016 17:22:24] "POST / HTTP/1.0" 200 - 192.168.99.103 - - [11/Apr/2016 17:22:24] "POST / HTTP/1.0" 200 -
192.168.99.103 - - [11/Apr/2016 17:23:37] "POST / HTTP/1.0" 200 - 192.168.99.103 - - [11/Apr/2016 17:23:37] "POST / HTTP/1.0" 200 -
192.168.99.103 - - [11/Apr/2016 17:23:39] "POST / HTTP/1.0" 200 - 192.168.99.103 - - [11/Apr/2016 17:23:39] "POST / HTTP/1.0" 200 -
192.168.99.103 - - [11/Apr/2016 17:23:40] "POST / HTTP/1.0" 200 - 192.168.99.103 - - [11/Apr/2016 17:23:40] "POST / HTTP/1.0" 200 -
192.168.99.103 - - [11/Apr/2016 17:23:41] "POST / HTTP/1.0" 200 - 192.168.99.103 - - [11/Apr/2016 17:23:41] "POST / HTTP/1.0" 200 -
192.168.99.103 - - [11/Apr/2016 17:23:43] "POST / HTTP/1.0" 200 - 192.168.99.103 - - [11/Apr/2016 17:23:43] "POST / HTTP/1.0" 200 -
192.168.99.103 - - [11/Apr/2016 17:23:44] "POST / HTTP/1.0" 200 - 192.168.99.103 - - [11/Apr/2016 17:23:44] "POST / HTTP/1.0" 200 -
192.168.99.103 - - [11/Apr/2016 17:23:46] "POST / HTTP/1.0" 200 - 192.168.99.103 - - [11/Apr/2016 17:23:46] "POST / HTTP/1.0" 200 -
``` ```
This log shows the activity on one of the active voting application containers. This log shows the activity on one of the active voting application containers.