Kubernetes - Why does the helm chart use StatefulSets rather than Deployments?

I’m installing Keycloak with the Helm chart at https://github.com/codecentric/helm-charts/tree/master/charts/keycloak. The chart is configured to deploy Keycloak as a StatefulSet rather than a Deployment and I’m wondering why that is. I could see a reason to use a StatefulSet if some volume claim templates were required, but since there doesn’t seem to be any, I don’t know why not simply use a Deployment.
Since I’m deploying with Keycloak configured with a Postgres database, I would expect the state to be in the database, therefore my pod to be stateless and not requiring a StatefulSet.

2 Likes

Hi,

This is stated in the README.

On our side we’re using deployment w/ a name length < 6 characters

Regards,

1 Like

By default Keycloak uses embedded Infinispan in a clustered configuration. There are number of issues when you scale Infinispan up and down drastically (e.g. going from 1 to 10 replicas). Some of them might lead to partitions and data loss. All this problems go away when you use StatefulSets. They scale up and down gradually (and give you stable hostname, which is helpful in some Infinispan corner cases).

3 Likes