mongodb / mongodb-atlas-kubernetes

MongoDB Atlas Kubernetes Operator - Manage your MongoDB Atlas clusters from Kubernetes
http://www.mongodb.com/cloud/atlas
Apache License 2.0
146 stars 75 forks source link

Deleting Kubernetes Resource And Atlas Cluster #118

Closed matheusca closed 3 years ago

matheusca commented 3 years ago

how are you guys?

Context

In my company we are building a platform to give developers autonomy. One of the principles is that developers don't need to know how to create their service and service dependencies following all best practices enforced by us (by us I mean, my team, SRE)

Dependencies are everything a service needs, for instance: a mongodb, redis, storage (bucket) and so on.

Of course, we are using atlas mongodb solutions for provisioning our mongodb cluster and currently, we are using this project to provide an easy way to create developers mongodb clusters.

Use case

So, one of the features that we (SRE Team) would like to provide, it is a branch context deployment. In other words, a platform feature that could be possible developers deployed their branches in a kubernetes cluster, a code isolation from their principal branch (main or master, for example), it allows testing their branch code in a "production-like".

But, imagine that one of service dependencies is mongodb, when they set up a service, platform will create a mongodb cluster for that service.

It's perfect, because I can do it using this project.

Problem

The problem is, I want to provide a way, when that branch is deleted, every single service dependency needs to be deleted too. What I figured is that, the operator doesn't delete the cluster, when kubernetes atlas cluster resource is deleted.

Feature

I'd like to suggest two nice features

What do you think?

Btw, thanks for offering this project :)

antonlisovenko commented 3 years ago

Hi @matheusca

Thank you for your detailed feedback!

Let me answer each of the questions:

  1. The removal of the Cluster in Atlas as soon as the K8s resource is removed is already implemented - can you try the latest release and tell us if that works fine
  2. This sounds like a good idea, I'll add it to the list of possible features we support for Trial (~beta) version of the Atlas Operator
matheusca commented 3 years ago

Thanks @antonlisovenko :)

1 - Thanks, I didn't know! I am going to update my operator and let you know! 2 - Thanks! If you'd like to, we can discuss how to implement this feature in issue and I could open a PR for you

theburi commented 3 years ago

Hi @matheusca What we have been thinking so far is two-part:

  1. Add an annotation mongodb.com/atlas-resource-policy="keep" to prevent deleting resources in Atlas when CR's are deleted
  2. Allow creating Atlas project and MongoDBUser CR in a namespace that needs to "connect" to Atlas only and drop secrets with connection strings. So that AtlasCluster CR will not be required if the application only needs to connect to the existing cluster and does not need to manage it.

Feel free to drop a PR if you have an idea of how it could work, so we could discuss it.