0

I'm new to Kubernetes and I'm learning about statefulsets. For stateful applications, where the identity of pods matter, we use statefulsets instead of simple deployments so each pod can have its own persistent volume. The writes need to be pointed to the master pod, while the reading operations can be pointed to the slaves. So pointing to the ClusterIP service attached to the statefulset won't guarantee the replication, instead we need to use a headless service that will be pointing to the master. My questions are the following :

  • How to edit the application.properties in spring boot project to use the slaves for reading operations ( normal ClusterIP service ) and the master for writing/reading operations ( Headless service )?
  • In case that is unnecessary and the headless service does this work for us, how does it work exactly since it's pointing to the master ?
joe1531
  • 345
  • 4
  • 16
  • Hi, you need to add more information to make your question as [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). How exactly did you set up your cluster? Please attach your yaml files. What did you try? Where exactly did you have problem? – Mikołaj Głodziak Oct 25 '21 at 10:38
  • It's not an error because I did not try anything yet. I am trying to understand how the connection will work between the master-slave postgres statefulset and a client, such as spring boot. Normally I would just enter the URL to the spring data source url field in the application.properties. In kubernetes case, I think I should enter the headless service dns name. But in that way, all data access operations will be forwarded to the master node right ? I want to load balance those operations to other replicated slaves, through the ClusterIP service but how do I do that ? – joe1531 Oct 25 '21 at 11:07

0 Answers0