diff --git a/README.md b/README.md index d49bf2f..b8ad8a9 100644 --- a/README.md +++ b/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. \ No newline at end of file +The voting application only accepts one vote per client. It does not register votes if a vote has already been submitted from a client. diff --git a/k8s-specifications/db-deployment.yaml b/k8s-specifications/db-deployment.yaml new file mode 100644 index 0000000..774c54a --- /dev/null +++ b/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: {} diff --git a/k8s-specifications/db-service.yaml b/k8s-specifications/db-service.yaml new file mode 100644 index 0000000..81f59b4 --- /dev/null +++ b/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 + diff --git a/k8s-specifications/redis-deployment.yaml b/k8s-specifications/redis-deployment.yaml new file mode 100644 index 0000000..a606e5c --- /dev/null +++ b/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: {} diff --git a/k8s-specifications/redis-service.yaml b/k8s-specifications/redis-service.yaml new file mode 100644 index 0000000..1c6cda4 --- /dev/null +++ b/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 + diff --git a/k8s-specifications/result-deployment.yaml b/k8s-specifications/result-deployment.yaml new file mode 100644 index 0000000..bd29380 --- /dev/null +++ b/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 diff --git a/k8s-specifications/result-service.yaml b/k8s-specifications/result-service.yaml new file mode 100644 index 0000000..7a9793c --- /dev/null +++ b/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 diff --git a/k8s-specifications/vote-deployment.yaml b/k8s-specifications/vote-deployment.yaml new file mode 100644 index 0000000..ccd5b27 --- /dev/null +++ b/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 diff --git a/k8s-specifications/vote-service.yaml b/k8s-specifications/vote-service.yaml new file mode 100644 index 0000000..45f20a8 --- /dev/null +++ b/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 + diff --git a/k8s-specifications/worker-deployment.yaml b/k8s-specifications/worker-deployment.yaml new file mode 100644 index 0000000..9d483de --- /dev/null +++ b/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