Skip to content

Commit

Permalink
Add k8s specfications
Browse files Browse the repository at this point in the history
  • Loading branch information
lucj committed Mar 5, 2018
1 parent e3eb2db commit 0fd383c
Show file tree
Hide file tree
Showing 10 changed files with 155 additions and 1 deletion.
23 changes: 22 additions & 1 deletion README.md
Expand Up @@ -21,6 +21,27 @@ Once you have your swarm, in this directory run:
docker stack deploy --compose-file docker-stack.yml vote
```

Run the app in Kubernetes
-------------------------

The folder k8s-specifications contains the yaml specifications of the Voting App's services.

Run the following command to create the deployments and services objects:
```
$ kubectl create -f k8s-specifications/
deployment "db" created
service "db" created
deployment "redis" created
service "redis" created
deployment "result" created
service "result" created
deployment "vote" created
service "vote" created
deployment "worker" created
```

The vote interface is then available on port 31000 on each host of the cluster, the result one is available on port 31001.

Architecture
-----

Expand All @@ -36,4 +57,4 @@ Architecture
Note
----

The voting application only accepts one vote per client. It does not register votes if a vote has already been submitted from a client.
The voting application only accepts one vote per client. It does not register votes if a vote has already been submitted from a client.
20 changes: 20 additions & 0 deletions k8s-specifications/db-deployment.yaml
@@ -0,0 +1,20 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: db
spec:
replicas: 1
template:
metadata:
labels:
app: db
spec:
containers:
- image: postgres:9.4
name: db
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: db-data
volumes:
- name: db-data
emptyDir: {}
12 changes: 12 additions & 0 deletions k8s-specifications/db-service.yaml
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: db
spec:
type: ClusterIP
ports:
- port: 5432
targetPort: 5432
selector:
app: db

20 changes: 20 additions & 0 deletions k8s-specifications/redis-deployment.yaml
@@ -0,0 +1,20 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: redis
spec:
replicas: 1
template:
metadata:
labels:
app: redis
spec:
containers:
- image: redis:alpine
name: redis
volumeMounts:
- mountPath: /data
name: redis-data
volumes:
- name: redis-data
emptyDir: {}
12 changes: 12 additions & 0 deletions k8s-specifications/redis-service.yaml
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: redis
spec:
type: ClusterIP
ports:
- port: 6379
targetPort: 6379
selector:
app: redis

14 changes: 14 additions & 0 deletions k8s-specifications/result-deployment.yaml
@@ -0,0 +1,14 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: result
spec:
replicas: 1
template:
metadata:
labels:
app: result
spec:
containers:
- image: dockersamples/examplevotingapp_result:before
name: result
13 changes: 13 additions & 0 deletions k8s-specifications/result-service.yaml
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: result
spec:
type: NodePort
ports:
- name: "result-service"
port: 5001
targetPort: 80
nodePort: 31001
selector:
app: result
14 changes: 14 additions & 0 deletions k8s-specifications/vote-deployment.yaml
@@ -0,0 +1,14 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: vote
spec:
replicas: 1
template:
metadata:
labels:
app: vote
spec:
containers:
- image: dockersamples/examplevotingapp_vote:before
name: vote
14 changes: 14 additions & 0 deletions k8s-specifications/vote-service.yaml
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: vote
spec:
type: NodePort
ports:
- name: "vote-service"
port: 5000
targetPort: 80
nodePort: 31000
selector:
app: vote

14 changes: 14 additions & 0 deletions k8s-specifications/worker-deployment.yaml
@@ -0,0 +1,14 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: worker
spec:
replicas: 1
template:
metadata:
labels:
app: worker
spec:
containers:
- image: dockersamples/examplevotingapp_worker
name: worker

0 comments on commit 0fd383c

Please sign in to comment.