Skip to content

Commit bdfde49

Browse files
author
Alvin Richards
committed
Initial checkin for Docker 1.9
1 parent dbcd22a commit bdfde49

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+1020
-771
lines changed

aerospike/README.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Orchestration & Networking demo
2+
3+
## Cavets
4+
* has been tested on os-x 10.10 only
5+
* scripts will create machines based on the vmwarefusion driver. If you don't have that, then you will need to make some changes
6+
* because boot2docker.iso is used, the locations of files will change if you use Ubuntu or something else.
7+
8+
## Preparation
9+
10+
Create dev environment:
11+
12+
$ common/scripts/create-dev.sh
13+
$ echo "$(docker-machine ip dev) dev.awesome-counter.com" | sudo tee -a /etc/hosts
14+
15+
Create a Swarm:
16+
17+
$ eval $(docker-machine env dev)
18+
$ common/scripts/create-swarm.sh
19+
$ echo "$(docker-machine ip swarm-0) prod.awesome-counter.com" | sudo tee -a /etc/hosts
20+
21+
Start the Viz:
22+
23+
$ cd viz
24+
$ source scripts/setup.sh
25+
$ scripts/up.sh swarm-0
26+
$ echo "$(docker-machine ip swarm-consul) viz.awesome-counter.com" | sudo tee -a /etc/hosts
27+
28+
The app will be available at http://viz.awesome-counter.com:3000
29+
30+
## Running demo - Part One: Scale the app
31+
32+
To start app in development:
33+
34+
$ cd dev/
35+
$ source scripts/setup.sh
36+
$ docker-compose up
37+
38+
The app will be available at http://dev.awesome-counter.com:5000
39+
40+
To start app in production:
41+
42+
$ cd prod/
43+
$ docker $(docker-machine config swarm-0) network create --driver overlay prod
44+
$ source scripts/setup.sh
45+
$ docker-compose up -d
46+
$ docker $(docker-machine config swarm-0) network connect prod $(docker inspect -f "{{.Id}}" prod_haproxy_1)
47+
$ docker-compose scale web=5
48+
49+
The app will be available at http://prod.awesome-counter.com
50+
51+
## Running demo - Part Two: Scale the DB
52+
53+
$ docker-compose scale aerospike=3
54+
$ docker run --net prod aerospike/aerospike-tools asinfo -v "tip:host=$(docker inspect -f '{{ .NetworkSettings.Networks.prod.IPAddress }}' prod_aerospike_2);port=3002" -h prod_aerospike_1
55+
$ docker run --net prod aerospike/aerospike-tools asinfo -v "tip:host=$(docker inspect -f '{{ .NetworkSettings.Networks.prod.IPAddress }}' prod_aerospike_3);port=3002" -h prod_aerospike_1
56+
57+
You can log onto the Aerospike using by
58+
$ docker run -it --rm --net prod aerospike/aerospike-tools aql -h prot_aerospike_1 -p 3000
59+
60+
## Running demo - Part Three: Move the DB
61+
<TBD> need to look at runc checkpoint & restore, examples here https://github.com/crosbymichael/uhaul/blob/master/node.go
62+
63+
## Cleaning up the demo
64+
$ scripts/cleanup.sh
65+
66+
# Building the images
67+
If you want to rebuild the images for any reason, you will need to build, push and update the compose files as necessary (since you will push to a new repo)
68+
69+
## Build the web app
70+
71+
$ HUB_USER="my hub user"
72+
$ cd dev
73+
$ eval "$(docker-machine env dev)"
74+
$ docker build -t $HUB_USER/demo-webapp-as .
75+
$ docker push $HUB_USER/demo-webapp-as
76+
77+
## Build the aerospike images
78+
79+
$ HUB_USER="my hub user"
80+
81+
$ cd aerospike
82+
$ eval "$(docker-machine env dev)"
83+
$ docker build -t $HUB_USER/aerospike-server .
84+
$ docker push $HUB_USER/aerospike-server
85+
86+
# Amazon EC2 - WORK IN PROGRESS!
87+
Some work has been done to make this demo work on EC2. You will need to setup a VPC and configure it correctly (blog post is in the works). Creating through the "VPC Wizard" is the simplest way to get this right. The swarm can be created on EC2 thus
88+
89+
$ export AWS_ACCESS_KEY_ID=<my key>
90+
$ export AWS_SECRET_ACCESS_KEY=<my secret key>
91+
$ export AWS_SECURITY_GROUP=<my group name eg. alvin-dockercon>
92+
$ export AWS_SUBNET_ID=<my subnet eg. subnet-6c87e947>
93+
$ export AWS_VPC_ID=<my VPC name eg. alvin-dockercon>
94+
95+
If you are not using the default Region of `us-east-1` then you will also need to set your Region and Zone that the VPC and Subnet were created in.
96+
97+
$ export AWS_DEFAULT_REGION=us-west-2
98+
$ export AWS_ZONE=c
99+
100+
$ scripts/create-swarm.sh amazonec2
101+
102+
In order for this to work, you will need to create a VPC via the VPC Wizard (not by just creating the VPC). You will also need to ensure that the secutiry group opens up the following ports
103+
104+
Docker Engine / Swarm
105+
- TCP / 2376 / 0.0.0.0
106+
- TCP / 3376 / 0.0.0.0
107+
108+
Consul
109+
- TCP / 8400 / 0.0.0.0
110+
- TCP / 8500 / 0.0.0.0
111+
- UDP / 8600 / 0.0.0.0
112+
113+
Serf
114+
- TCP / 7946 / 0.0.0.0
115+
116+
Web App
117+
- TCP / 80 / 0.0.0.0
118+
119+
VxLAN
120+
- UDP / 46354 / 0.0.0.0
121+
Once the following is resolved https://github.com/docker/libnetwork/issues/358#issuecomment-128160349
122+
- UDP / 4789 / 0.0.0.0
123+
124+
You will also need to modify `prod/haproxy.yml` to change the volumnes mounted to the container
125+
# boot2docker images use the following
126+
# - "/var/lib/boot2docker:/etc/docker"
127+
# ubuntu / ec2 images use
128+
- "/etc/docker:/etc/docker"
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
areospike:
2+
extends:
3+
file: mdb_dev_cluster.yaml
4+
service: mongodb
5+
image: alvinr/mongos:latest
6+
environment:
7+
- "constraint:node==swarm-0"
8+
9+
rs1a:
10+
extends:
11+
file: mdb_dev_cluster.yaml
12+
service: rs1a
13+
image: mongo:3.0.3
14+
environment:
15+
- "affinity:com.docker.examples.mongodb.mongod.replset!=rs1"
16+
- "constraint:node!=swarm-0"
17+
18+
rs1b:
19+
extends:
20+
file: mdb_dev_cluster.yaml
21+
service: rs1b
22+
image: mongo:3.0.3
23+
environment:
24+
- "affinity:com.docker.examples.mongodb.mongod.replset!=rs1"
25+
- "constraint:node!=swarm-0"
26+
27+
rs1c:
28+
extends:
29+
file: mdb_dev_cluster.yaml
30+
service: rs1c
31+
image: mongo:3.0.3
32+
environment:
33+
- "affinity:com.docker.examples.mongodb.mongod.replset!=rs1"
34+
- "constraint:node!=swarm-0"
35+
36+
rs2a:
37+
extends:
38+
file: mdb_dev_cluster.yaml
39+
service: rs2a
40+
image: mongo:3.0.3
41+
environment:
42+
- "affinity:com.docker.examples.mongodb.mongod.replset!=rs2"
43+
- "constraint:node!=swarm-0"
44+
45+
rs2b:
46+
extends:
47+
file: mdb_dev_cluster.yaml
48+
service: rs2b
49+
image: mongo:3.0.3
50+
environment:
51+
- "affinity:com.docker.examples.mongodb.mongod.replset!=rs2"
52+
- "constraint:node!=swarm-0"
53+
54+
rs2c:
55+
extends:
56+
file: mdb_dev_cluster.yaml
57+
service: rs2c
58+
image: mongo:3.0.3
59+
environment:
60+
- "affinity:com.docker.examples.mongodb.mongod.replset!=rs2"
61+
- "constraint:node!=swarm-0"
62+
63+
config1:
64+
extends:
65+
file: mdb_dev_cluster.yaml
66+
service: config1
67+
image: mongo:3.0.3
68+
environment:
69+
- "affinity:com.docker.examples.mongodb.role!=mongoc"
70+
- "constraint:node!=swarm-0"
71+
72+
config2:
73+
extends:
74+
file: mdb_dev_cluster.yaml
75+
service: config2
76+
image: mongo:3.0.3
77+
environment:
78+
- "affinity:com.docker.examples.mongodb.role!=mongoc"
79+
- "constraint:node!=swarm-0"
80+
81+
config3:
82+
extends:
83+
file: mdb_dev_cluster.yaml
84+
service: config3
85+
image: mongo:3.0.3
86+
environment:
87+
- "affinity:com.docker.examples.mongodb.role!=mongoc"
88+
- "constraint:node!=swarm-0"
File renamed without changes.

aerospike/dev/aerospike.conf

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Aerospike database configuration file.
2+
3+
# This stanza must come first.
4+
service {
5+
user root
6+
group root
7+
paxos-single-replica-limit 1 # Number of nodes where the replica count is automatically reduced to 1.
8+
pidfile /var/run/aerospike/asd.pid
9+
service-threads 4
10+
transaction-queues 4
11+
transaction-threads-per-queue 4
12+
proto-fd-max 15000
13+
}
14+
15+
logging {
16+
17+
# Log file must be an absolute path.
18+
file /var/log/aerospike/aerospike.log {
19+
context any info
20+
}
21+
22+
# Send log messages to stdout
23+
console {
24+
context any critical
25+
}
26+
}
27+
28+
network {
29+
service {
30+
address any
31+
port 3000
32+
33+
# Uncomment the following to set the `access-address` parameter to the
34+
# IP address of the Docker host. This will the allow the server to correctly
35+
# publish the address which applications and other nodes in the cluster to
36+
# use when addressing this node.
37+
# access-address <IPADDR>
38+
}
39+
40+
heartbeat {
41+
42+
# mesh is used for environments that do not support multicast
43+
mode mesh
44+
port 3002
45+
46+
# use asinfo -v 'tip:host=<ADDR>;port=3002' to inform cluster of
47+
# other mesh nodes
48+
mesh-port 3002
49+
50+
interval 150
51+
timeout 10
52+
}
53+
54+
fabric {
55+
port 3001
56+
}
57+
58+
info {
59+
port 3003
60+
}
61+
}
62+
63+
namespace test {
64+
replication-factor 2
65+
memory-size 1G
66+
default-ttl 5d # 5 days, use 0 to never expire/evict.
67+
68+
# storage-engine memory
69+
70+
# To use file storage backing, comment out the line above and use the
71+
# following lines instead.
72+
storage-engine device {
73+
file /opt/aerospike/data/test.dat
74+
filesize 4G
75+
data-in-memory true # Store data in memory in addition to file.
76+
}
77+
}

aerospike/dev/app.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
import aerospike
33
import os
44
import datetime
5+
import time
56
import socket
67
import uuid
78

89
app = Flask(__name__)
910

1011
config = {
11-
'hosts': [ (os.environ.get('AEROSPIKE_HOST', 'aerospike_aerospike_1'), 3000) ]
12+
'hosts': [ (os.environ.get('AEROSPIKE_HOST', 'aerospike_aerospike_1'), 3000) ],
13+
'policies': { 'key': aerospike.POLICY_KEY_SEND }
1214
}
1315

1416
host = socket.gethostbyname(socket.gethostname())
@@ -26,7 +28,9 @@ def hello():
2628

2729
#key = ("test", "hits", foo)
2830
# Insert the 'hit' record
29-
client.put(("test", "hits", foo), {"server": host, "ts": datetime.datetime.utcnow()} )
31+
# ts = datetime.datetime.utcnow()
32+
ts = int(round(time.time() * 1000))
33+
client.put(("test", "hits", foo), {"server": host, "ts": ts} )
3034

3135
# Maintain our summaries for the grand total and for each server
3236
#key = ("test", "summary", "total_hits")

aerospike/dev/docker-compose.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ web:
44
- "5000:5000"
55
links:
66
- aerospike
7-
hostname: dev.dockercon.com
7+
hostname: dev.awesome-counter.com
88
environment:
99
- AEROSPIKE_HOST=dev_aerospike_1
1010
aerospike:
11-
image: aerospike/aerospike-server:latest
12-
ports:
13-
- "3000:3000"
14-
- "3001:3001"
15-
- "3003:3003"
11+
image: alvinr/aerospike-server:latest
12+
volumes:
13+
- $PWD:/opt/aerospike/etc
14+
command: -foreground --config-file /opt/aerospike/etc/aerospike.conf

0 commit comments

Comments
 (0)