Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9c67a24
commit dcf654c
Showing
15 changed files
with
224 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,8 +1,63 @@ | |||
# dogvscat | # dogvscat (Work In Progress) | ||
|
|
||
A Docker Swarm cluster needs more then just your app running. | This repo gives a few examples of patterns for how you might build Docker Swarm clusters with all the bells and whistles. | ||
|
|
||
Sometimes live on [dogvs.cat](http://dogvs.cat) | A Docker Swarm cluster needs more then just your app running, it often needs at least these additional services: | ||
|
|
||
COMING SOON (May/June 2018) | - Layer 7 Reverse Proxy (to host multiple HTTP sites on one port) | ||
- Swarm-aware storage for data persistance | |||
- Centralized logging of your app containers | |||
- Centralized monitoring of nodes and containers | |||
- Cluster management GUI | |||
- Continuous deployment of updated images | |||
|
|
||
This demo is meant for you to `git clone` and run locally to help you learn the tools and methods for building a complete Docker Swarm cluster. | |||
|
|||
## Getting Started | |||
|
|||
This repo holds two deployment examples for Docker Swarm | |||
|
|||
- Docker Swarm CE (Community Edition) open source stack | |||
- Docker Swarm EE (Enterprise Edition) stack | |||
|
|||
The EE stack requires at least a trial license to deploy. | |||
|
|||
## Deploying the Swarm CE Example | |||
|
|||
You can do all this locally on a single node or optionally using Docker Machine to multi-node clusters. | |||
|
|||
### Step 1: Set needed environment variables | |||
|
|||
The scripts and compose/stack files use variables to make this demo easier to get started. Set these at your shell before running commands | |||
|
|||
``` | |||
TODO: add envs | |||
``` | |||
|
|||
### Step 2: (single node local Swarm) | |||
|
|||
Just have Docker installed, either via Docker for Windows/Mac or on Linux. See my [YouTube videos on the proper way to setup your OS for Docker](https://www.youtube.com/watch?v=Fc7Rjll30jY&list=PL6cactdCCnTLqhFgmXAVdwLPCM_SZdGYq) using downloads from [store.docker.com](https://store.docker.com). | |||
|
|||
Then just create a single-node Swarm in that engine: | |||
|
|||
`docker swarm init` | |||
|
|||
### Step 2: (multi-node docker-machine Swarm) | |||
|
|||
`./create-servers.sh` gives example docker-machine commands for creating 3 nodes in various VM environments including locally with VirtualBox, Hyper-V, and in the cloud using Digital Ocean. | |||
|
|||
### Step 3: Enable Docker Engine Metrics | |||
|
|||
### Step 4: Initialize Swarm and Join Nodes | |||
|
|||
### Step 5: Enable Persistent Storage with REX-Ray | |||
|
|||
### Step 6: Deploy Reverse Proxy using Traefik | |||
|
|||
### Step 7: Deploy Ops Tools: ELK, Prometheus, and Portainer | |||
|
|||
### Step 8: Deploy sample apps and test | |||
|
|||
## Deploying the Swarm EE Example | |||
|
|||
TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,9 @@ | |||
#!/bin/sh | |||
|
|||
# create POST data files with ab friendly formats | |||
python make-data.py | |||
|
|||
# create 3000 votes | |||
ab -n 1000 -c 50 -p posta -T "application/x-www-form-urlencoded" http://vote.dogvs.cat/ | |||
ab -n 1000 -c 50 -p postb -T "application/x-www-form-urlencoded" http://vote.dogvs.cat/ | |||
ab -n 1000 -c 50 -p posta -T "application/x-www-form-urlencoded" http://vote.dogvs.cat/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,3 +1,5 @@ | |||
#!/bin/sh | #!/bin/sh | ||
set -x | |||
|
|||
export LOGSTASH_CONF=$(shasum logstash.conf -a 512 | cut -c1-16) | export LOGSTASH_CONF=$(shasum logstash.conf -a 512 | cut -c1-16) | ||
|
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,13 @@ | |||
# this creates urlencode-friendly files without EOL | |||
import urllib | |||
outfile = open('postb', 'w') | |||
params = ({ 'vote': 'b' }) | |||
encoded = urllib.urlencode(params) | |||
outfile.write(encoded) | |||
outfile.close() | |||
outfile = open('posta', 'w') | |||
params = ({ 'vote': 'a' }) | |||
encoded = urllib.urlencode(params) | |||
outfile.write(encoded) | |||
outfile.close() | |||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
vote=a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
vote=b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,5 +1,72 @@ | |||
version: '3.5' | version: '3.2' | ||
|
|||
services: | |||
|
|||
ghost: | |||
image: ghost:1-alpine | |||
networks: | |||
- proxy | |||
- ghost | |||
environment: | |||
# see https://docs.ghost.org/docs/config#section-running-ghost-with-config-env-variables | |||
database__client: mysql | |||
database__connection__host: db | |||
database__connection__user: root | |||
database__connection__password: OpdP2dy4jzAT | |||
database__connection__database: ghost | |||
url: http://ghost.dogvs.cat | |||
deploy: | |||
replicas: 1 | |||
labels: | |||
- traefik.port=2368 | |||
- traefik.docker.network=proxy | |||
- traefik.frontend.rule=Host:ghost.dogvs.cat | |||
db: | |||
image: mysql:5.7 | |||
volumes: | |||
- db:/var/lib/mysql | |||
secrets: | |||
- ghost-db-password | |||
networks: | |||
- ghost | |||
deploy: | |||
endpoint_mode: dnsrr | |||
environment: | |||
MYSQL_ROOT_PASSWORD_FILE: /run/secrets/ghost-db-password | |||
|
|||
db-backup: | |||
image: mysql:5.7 | |||
command: sh -c "while true; do /usr/bin/mysqldump -u root --password=$$(< $$MYSQL_ROOT_PASSWORD_FILE) --all-databases --host=db > /backup/backup$$(date +'%H').sql ; sleep 3600; done" | |||
volumes: | |||
- db-backup:/backup | |||
secrets: | |||
- ghost-db-password | |||
networks: | |||
- ghost | |||
environment: | |||
MYSQL_ROOT_PASSWORD_FILE: /run/secrets/ghost-db-password | |||
|
|||
#TODO: backup for static content | |||
|
|||
|
|||
networks: | |||
ghost: {} | |||
proxy: | |||
external: true | |||
|
|
||
volumes: | volumes: | ||
db: | db: | ||
driver: cloudstor:aws | driver: cloudstor:latest | ||
driver_opts: | |||
size: 1 | |||
db-backup: | |||
driver: cloudstor:latest | |||
driver_opts: | |||
size: 1 | |||
|
|||
secrets: | |||
ghost-db-password: | |||
external: true | |||
|
|||
|
|||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters