Best practices to organize pods in kubernates

12/8/2018

I have a project that uses the following resources to work:

  • A jsf application running under JBoss and using a PostgreSQL

  • 2 spring boot API using MongoDB.

So, I have the following dockers:

  • jsf+JBoss in same docker

  • PostgreSQL docker

  • mongo docker

  • one docker for each spring boot app.

In kubernates I need organize this containers in PODs, so my ideia is create the following:

  • A POD for jsf+JBoss docker

  • Another for PostgreSQL

  • Another POD for MongoDB

  • Only one POD for both spring boot app, because they need each other.

So, I have 4 POD and 6 containers. Thinking about best practices to use ks8, this is a good way to organize my project?

-- Ronaldo Lanhellas
kubernetes

1 Answer

12/8/2018

tl;dr; This doesn't follow Kubernetes best practices. Each application should be a separate deployment or StatefulSet.

A better way to run this in Kubernetes would be using a deployment or StatefulSet for each individual application, so it would be:

One Deployment with a single container for jsf+JBoss

One StatefulSet for PostgreSQL (though I would suggest looking at an Operator to manage your PostgreSQL cluster, i.e. kubedb

One StatefulSet for MongoDB (again, strongly suggest using an Operator to manage your MongoDB cluster, which kubedb can also handle)

One deployment each for your Spring Boot applications, assuming they communicate with each other via a network. You can then manage and scale each independently of each other, regardless of their dependency on each other.

-- chaosaffe
Source: StackOverflow