Benefit to placing Database and Application in same Kubernetes pod

12/14/2018

I know just the bare minimum of Kubernetes. However, I wanted to know if there would be any benefit in running 2 containers in a single pod:

  • 1 Container running the application (e.g. a NodeJS app)
  • 1 Container running the corresponding local database (e.g. a PouchDB database)

Would this would increase performance or the down-sides of coupling the two containers would overcome any benefits?

-- jagueros
docker
kubernetes
kubernetes-pod

2 Answers

12/14/2018

Lets say you neeed to scale your app (the pod), what would happen is that the DB will also be scaled, and that will cause an error because it is not set to be a cluster, just a single node.

-- Diego Velez
Source: StackOverflow

12/15/2018

Pods, are designed to put together containers that share the same lifecyle. Containers inside the same pod, share some namespaces (like networking) and volumes.
This way, coupling an app with its database could look like a good idea, because the app could just connect to the database through localhost, etc. But it is not! As Diego Velez pointed out, one of the first limitations you could face is scaling your app. If you couple your app with your database, you are forced to scale your database whenever you scale your app, what is not optimal at all and prevents you from benefit of one of the main benefits of using a container orchestrator like kubernetes.
Some good use cases are:

  • Container with app + container with agent for app metrics, ci agents, etc.
  • CI/CD container (like jenkins agents) + container(s) with tools for CI/CD.
  • Container with app + container with proxy (like in istio making use of the sidecar pattern).
-- aespejel
Source: StackOverflow