#Question about running a Discord.NET bot in a k8s cluster using ASP.NET

1 messages · Page 1 of 1 (latest)

serene lodge
#

Hi everyone,

I’m developing an ASP.NET application that includes endpoints for oAuth2 and a Discord.NET bot. The app be deployed in a k8s cluster with at least 4 pods, and this setup cannot be changed.

My question: how can I ensure the Discord.NET bot runs on only one pod, and if the container with the bot crashes or disconnects, the bot automatically starts on another pod?

Has anyone implemented a similar scenario using the leader election pattern or other approaches? What are the best practices for solving this?

Thanks in advance for any advice!

serene lodge
#

🥺

ivory charm
#

I have no advice for this but just here to say you should try asking in some place that specializes in kubernetes

strange elm
#

The oauth endpoint can be in a separate project, maybe you can explain why you need it in the same project and I could give advice how to make them separte and still be able to communicate

serene lodge
#

the problem is that the infrastructure where I want to deploy the bot has a strict limitation of at least 4 pods on PROD (2+2 in different sectors zones)

strange elm
#

Maybe you could add an async message queue and communicate the restarting event from one instance to another

#

Like azure service bus or rabbitmq

#

First instance to consume the message will start the bot