Skip to content

Commit e16d6ef

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents ac496c8 + b3f42f4 commit e16d6ef

21 files changed

+598
-2
lines changed

Jenkinsfile

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
pipeline {
2+
agent {
3+
node {
4+
label 'ubuntu-1604-aufs-stable'
5+
}
6+
}
7+
stages {
8+
stage('Build result') {
9+
steps {
10+
sh 'docker build -t dockersamples/result ./result'
11+
}
12+
}
13+
stage('Build vote') {
14+
steps {
15+
sh 'docker build -t dockersamples/vote ./vote'
16+
}
17+
}
18+
stage('Build worker') {
19+
steps {
20+
sh 'docker build -t dockersamples/worker ./worker'
21+
}
22+
}
23+
stage('Push result image') {
24+
when {
25+
branch 'master'
26+
}
27+
steps {
28+
withDockerRegistry(credentialsId: 'dockerbuildbot-index.docker.io', url:'') {
29+
sh 'docker push dockersamples/result'
30+
}
31+
}
32+
}
33+
stage('Push vote image') {
34+
when {
35+
branch 'master'
36+
}
37+
steps {
38+
withDockerRegistry(credentialsId: 'dockerbuildbot-index.docker.io', url:'') {
39+
sh 'docker push dockersamples/vote'
40+
}
41+
}
42+
}
43+
stage('Push worker image') {
44+
when {
45+
branch 'master'
46+
}
47+
steps {
48+
withDockerRegistry(credentialsId: 'dockerbuildbot-index.docker.io', url:'') {
49+
sh 'docker push dockersamples/worker'
50+
}
51+
}
52+
}
53+
}
54+
}

README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,27 @@ Once you have your swarm, in this directory run:
2121
docker stack deploy --compose-file docker-stack.yml vote
2222
```
2323

24+
Run the app in Kubernetes
25+
-------------------------
26+
27+
The folder k8s-specifications contains the yaml specifications of the Voting App's services.
28+
29+
Run the following command to create the deployments and services objects:
30+
```
31+
$ kubectl create -f k8s-specifications/
32+
deployment "db" created
33+
service "db" created
34+
deployment "redis" created
35+
service "redis" created
36+
deployment "result" created
37+
service "result" created
38+
deployment "vote" created
39+
service "vote" created
40+
deployment "worker" created
41+
```
42+
43+
The vote interface is then available on port 31000 on each host of the cluster, the result one is available on port 31001.
44+
2445
Architecture
2546
-----
2647

@@ -36,4 +57,4 @@ Architecture
3657
Note
3758
----
3859

39-
The voting application only accepts one vote per client. It does not register votes if a vote has already been submitted from a client.
60+
The voting application only accepts one vote per client. It does not register votes if a vote has already been submitted from a client.

docker-compose-k8s.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
version: ':8080'
2+
3+
services:
4+
redis:
5+
image: redis:alpine
6+
ports:
7+
- "6379:6379"
8+
db:
9+
image: postgres:9.4
10+
ports:
11+
- "5432:5432"
12+
vote:
13+
image: dockersamples/examplevotingapp_vote:before
14+
ports:
15+
- "5000:80"
16+
deploy:
17+
replicas: 2
18+
result:
19+
image: dockersamples/examplevotingapp_result:before
20+
ports:
21+
- "5001:80"
22+
worker:
23+
image: dockersamples/examplevotingapp_worker
24+
visualizer:
25+
image: dockersamples/visualizer:stable
26+
ports:
27+
- "8080:8080"

docker-stack-simple.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
version: "3"
2+
services:
3+
4+
redis:
5+
image: redis:alpine
6+
ports:
7+
- "6379"
8+
networks:
9+
- frontend
10+
deploy:
11+
replicas: 1
12+
update_config:
13+
parallelism: 2
14+
delay: 10s
15+
restart_policy:
16+
condition: on-failure
17+
db:
18+
image: postgres:9.4
19+
volumes:
20+
- db-data:/var/lib/postgresql/data
21+
networks:
22+
- backend
23+
deploy:
24+
placement:
25+
constraints: [node.role == manager]
26+
vote:
27+
image: dockersamples/examplevotingapp_vote:before
28+
ports:
29+
- 5000:80
30+
networks:
31+
- frontend
32+
depends_on:
33+
- redis
34+
deploy:
35+
replicas: 1
36+
update_config:
37+
parallelism: 2
38+
restart_policy:
39+
condition: on-failure
40+
result:
41+
image: dockersamples/examplevotingapp_result:before
42+
ports:
43+
- 5001:80
44+
networks:
45+
- backend
46+
depends_on:
47+
- db
48+
deploy:
49+
replicas: 1
50+
update_config:
51+
parallelism: 2
52+
delay: 10s
53+
restart_policy:
54+
condition: on-failure
55+
56+
worker:
57+
image: dockersamples/examplevotingapp_worker
58+
networks:
59+
- frontend
60+
- backend
61+
deploy:
62+
mode: replicated
63+
replicas: 1
64+
labels: [APP=VOTING]
65+
restart_policy:
66+
condition: on-failure
67+
delay: 10s
68+
max_attempts: 3
69+
window: 120s
70+
placement:
71+
constraints: [node.role == manager]
72+
73+
networks:
74+
frontend:
75+
backend:
76+
77+
volumes:
78+
db-data:

k8s-specifications/db-deployment.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
apiVersion: extensions/v1beta1
2+
kind: Deployment
3+
metadata:
4+
name: db
5+
spec:
6+
replicas: 1
7+
template:
8+
metadata:
9+
labels:
10+
app: db
11+
spec:
12+
containers:
13+
- image: postgres:9.4
14+
name: db
15+
volumeMounts:
16+
- mountPath: /var/lib/postgresql/data
17+
name: db-data
18+
volumes:
19+
- name: db-data
20+
emptyDir: {}

k8s-specifications/db-service.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: db
5+
spec:
6+
type: ClusterIP
7+
ports:
8+
- port: 5432
9+
targetPort: 5432
10+
selector:
11+
app: db
12+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
apiVersion: extensions/v1beta1
2+
kind: Deployment
3+
metadata:
4+
name: redis
5+
spec:
6+
replicas: 1
7+
template:
8+
metadata:
9+
labels:
10+
app: redis
11+
spec:
12+
containers:
13+
- image: redis:alpine
14+
name: redis
15+
volumeMounts:
16+
- mountPath: /data
17+
name: redis-data
18+
volumes:
19+
- name: redis-data
20+
emptyDir: {}

k8s-specifications/redis-service.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: redis
5+
spec:
6+
type: ClusterIP
7+
ports:
8+
- port: 6379
9+
targetPort: 6379
10+
selector:
11+
app: redis
12+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: extensions/v1beta1
2+
kind: Deployment
3+
metadata:
4+
name: result
5+
spec:
6+
replicas: 1
7+
template:
8+
metadata:
9+
labels:
10+
app: result
11+
spec:
12+
containers:
13+
- image: dockersamples/examplevotingapp_result:before
14+
name: result
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: result
5+
spec:
6+
type: NodePort
7+
ports:
8+
- name: "result-service"
9+
port: 5001
10+
targetPort: 80
11+
nodePort: 31001
12+
selector:
13+
app: result
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: extensions/v1beta1
2+
kind: Deployment
3+
metadata:
4+
name: vote
5+
spec:
6+
replicas: 1
7+
template:
8+
metadata:
9+
labels:
10+
app: vote
11+
spec:
12+
containers:
13+
- image: dockersamples/examplevotingapp_vote:before
14+
name: vote

k8s-specifications/vote-service.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: vote
5+
spec:
6+
type: NodePort
7+
ports:
8+
- name: "vote-service"
9+
port: 5000
10+
targetPort: 80
11+
nodePort: 31000
12+
selector:
13+
app: vote
14+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: extensions/v1beta1
2+
kind: Deployment
3+
metadata:
4+
name: worker
5+
spec:
6+
replicas: 1
7+
template:
8+
metadata:
9+
labels:
10+
app: worker
11+
spec:
12+
containers:
13+
- image: dockersamples/examplevotingapp_worker
14+
name: worker

0 commit comments

Comments
 (0)