You have to provide an static IP in mongodb network access policy,
When we create/delete/restart (deploy) any kubernates pod or any serverless (ex, lamda) they get new IP so mongodb won’t recognaise and allow read/write so you have to setup an NAT IP for your pods. It can be achiveable via load balance also.