Add k8s specfications
This commit is contained in:
parent
e3eb2dbd2a
commit
0fd383ce27
23
README.md
23
README.md
@ -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
|
||||
-----
|
||||
|
||||
@ -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
k8s-specifications/db-deployment.yaml
Normal file
20
k8s-specifications/db-deployment.yaml
Normal 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: {}
|
12
k8s-specifications/db-service.yaml
Normal file
12
k8s-specifications/db-service.yaml
Normal file
@ -0,0 +1,12 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: db
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- port: 5432
|
||||
targetPort: 5432
|
||||
selector:
|
||||
app: db
|
||||
|
20
k8s-specifications/redis-deployment.yaml
Normal file
20
k8s-specifications/redis-deployment.yaml
Normal 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: {}
|
12
k8s-specifications/redis-service.yaml
Normal file
12
k8s-specifications/redis-service.yaml
Normal file
@ -0,0 +1,12 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: redis
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- port: 6379
|
||||
targetPort: 6379
|
||||
selector:
|
||||
app: redis
|
||||
|
14
k8s-specifications/result-deployment.yaml
Normal file
14
k8s-specifications/result-deployment.yaml
Normal 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
|
13
k8s-specifications/result-service.yaml
Normal file
13
k8s-specifications/result-service.yaml
Normal 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
|
14
k8s-specifications/vote-deployment.yaml
Normal file
14
k8s-specifications/vote-deployment.yaml
Normal 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
|
14
k8s-specifications/vote-service.yaml
Normal file
14
k8s-specifications/vote-service.yaml
Normal 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
|
||||
|
14
k8s-specifications/worker-deployment.yaml
Normal file
14
k8s-specifications/worker-deployment.yaml
Normal 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
|
Loading…
Reference in New Issue
Block a user