3 tier architecture on kubernetes

7/18/2019

I have 1 master kubernetes server and 9 nodes. In that, I want to run backend on 2 nodes and frontend on 2 nodes and DB on 3 nodes.

For all backend, frontend, DB I have ready DockerImage.

How to run an image using kubernetes on only desired(2 or 3).

Please share some ideas to achieve the same.

-- gokul kandasamy
3-tier
docker
kubernetes

3 Answers

7/18/2019
  1. Run the front end as a Deployment with desired replica count and let kubernetes manage it for you.

  2. Run Backend as Deployment with desired number of replicas and Kubernetes will figure out how to run it. Use node selectors if you prefer specific nodes.

  3. Run the DB as Deployment OR StatefulSet, Kubernetes will figure out how to run it.

https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/

Use network policies to restrict traffic.

-- Ijaz Ahmad Khan
Source: StackOverflow

7/18/2019

You may use labels and nodeSelector. Here it is: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/

-- Mostafa Zare
Source: StackOverflow

7/18/2019

The Kubernetes scheduler most of the time will do a good job distributing the pods across the cluster. You may want to delegate that responsibility to the scheduler unless you have very specific requirements.

If you want to control this, you can use:

From these three, the recommended approach is to use node affinity or anti-affinity due to its flexibility.

-- jlmayorga
Source: StackOverflow