gokul kandasamy
gokul kandasamy

Reputation: 303

3 tier architecture on kubernetes

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.

Upvotes: 0

Views: 2001

Answers (3)

Ijaz Ahmad
Ijaz Ahmad

Reputation: 12100

  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.

Upvotes: 0

jlmayorga
jlmayorga

Reputation: 433

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.

Upvotes: 1

Mostafa Zare
Mostafa Zare

Reputation: 185

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

Upvotes: 0

Related Questions