Is it good to put complete application in one kubernetes pod?

4/12/2019

I have a application consisting of frontend, backend and a database. At the moment the application is running on a kubernetes cluster. Front-, backend and database is inside its own Pod communicating via services.

My consideration is to put all these application parts (Front-, Backend and DB) in one Pod, so i can make a Helm chart of it and for every new customer i only have to change the values.

The Question is, if this is a good solution or not to be recommended.

-- Raphael G.
kubernetes
kubernetes-pod

2 Answers

4/12/2019

You can create a helm chart consisting of multiple pods or deployments, so you do not need to put them in one pod just for that purpose. I would also not recommend that, as for example the Database would most likely fit better in a StatefulSet.

-- Blokje5
Source: StackOverflow

4/12/2019

No, it is a bad idea, this is why:

  • First, the DB is a stateful container, when you update any of the components, you have to put down all containers in the POD, let's say this is a small front end update, it will put down everything and the application will be unavailable.
  • Let's say you have multiple replicas of this pod to avoid the issue mentioned above, this will make extremely hard to scale the application, because you will need a copy of every container scaled, when you might likely need only FE or BE to scale, also creating multiple replicas of a database, depending how it replicates the data, will make it slower. You also have to consider backup and restore of the data in case of failures.
  • In the same example above, multiple replicas will make the PODs consume too much resources, even though you don't need it.

If you just want to deploy the resources without much customization, you could just deploy them into separate namespaces and add policies to prevent one namespace talking to each other and deploy the raw yaml there, only taking care to use config maps to load the different configurations for each.

If you want just a simple templating and deployment solution, you can use kustomize.

If you want to have the complex setup and management provided by Helm, you could defined all pods in the chart, an example is the Prometheus chart.

-- Diego Mendes
Source: StackOverflow