<@U01LWRXUF7B> is there a reason that the kratos-c...
# ory-selfhosting
f
@User is there a reason that the kratos-courier is a stateful service and not just a deployment? Also why is it using a headless service?
w
Hello there, headless services are a good practice with statefulsets, you can find more on it here: https://medium.com/@akansh27/statefulset-3274f71a6942
f
Understand it's a good practise if you need to particularly target a specific instance of a statefulset. Does the courier service actually need that?
I actually don't even think the service is required or that it needs to be a stateful set. The courier is just a job runner that is watching messages on the queue
I'm pretty sure we could convert the courier into a deployment and remove the service from it as nothing is calling out to it
w
i see your point, would need to ask @User why the design decision, because there for sure was some reason but i can’t recall from the top of my head
👍 1
h
It's a singleton - it would send the same email twice otherwise
it can't be solved otherwise without locking the table which is a no-go since we will need to push new emails all the time
at some point we'll probably have some rpc messaging but for the time being we're using the db as the queue ;)
f
@User understood it needs to only be a single instance, but the two questions are 1. Does it need to be a statefulset? it isn't really stateful and I think you can enforce the same sematics with a deployment by keeping the replica to 1. 2. Does anything actually call out to this service via RPC? Or is all its work via querying the database?
w
1 - afaik statefulset is the only way of ensuring a single instance in the cluster, even during upgrades/replace scenario. We could make a POC with a 1 replica deployment and tinker with [strategies](https://www.weave.works/blog/kubernetes-deployment-strategies)