Add k8s specfications

This commit is contained in:
Luc Juggery 2018-03-05 12:57:48 +01:00
parent e3eb2dbd2a
commit 0fd383ce27
10 changed files with 155 additions and 1 deletions

View File

@ -21,6 +21,27 @@ Once you have your swarm, in this directory run:
docker stack deploy --compose-file docker-stack.yml vote 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 Architecture
----- -----
@ -36,4 +57,4 @@ Architecture
Note 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.

View File

@ -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: {}

View File

@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: db
spec:
type: ClusterIP
ports:
- port: 5432
targetPort: 5432
selector:
app: db

View File

@ -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: {}

View File

@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: redis
spec:
type: ClusterIP
ports:
- port: 6379
targetPort: 6379
selector:
app: redis

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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