Is it recommended to run keycloak and postgres on the same pod?

4/30/2020

I am planning to deploy Keycloak on my K8S cluster but for the moment not in cluster mode as described on https://www.keycloak.org/2019/04/keycloak-cluster-setup.html. PostgresSQL will be use as data storage for it.

My plan is:

enter image description here

Create a pod with Keycloak and PostgreSQL inside. Deployment replicas will be 1, because for the moment I do not need clustering.

I know, that it is recommended to run one container in one pod but for my purpose will be acceptable to run 2 containers in one pod?

-- zero_coding
keycloak
kubernetes
postgresql

2 Answers

4/30/2020

No, you should only run things in the same pod if there is no way to not do that. In this case the alternative is run separate pods so you should do that.

-- coderanger
Source: StackOverflow

4/30/2020

You answered your own question in the last sentence. First of all have a look at this article over at mirantis

It is not recommended to run containers with different use cases in one pod. You have two different use cases and therefore should run two different pods.

  • Storing data

  • Authentication

Besides that it is probably a pita if the pod with both services gets evicted and needs to be redeployed with both keycloak and postgres at the same time.

And my wild guess is that it is probably more time consuming to separate both containers into independent pods / services in the aftermath, than doing it right away.

Edit:

Look at it this way: Postgres is your datastorage for keycloak, but that doen't mean keycloak will be the only service which needs to store data in a postgresqlDB.

-- T8xi
Source: StackOverflow