Skip to content

feat: customize connection string secret annotations #1582

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

limwa
Copy link
Contributor

@limwa limwa commented Jul 5, 2024

Summary:

Closes #1522.

In this PR, I've added the ability to add custom annotations to the generated connection string secrets.

This is useful to handle more deployment scenarios, in particular, the scenarios where the operator is not deployed cluster-wide, but to a specific namespace. In these scenarios the connectionStringSecretNamespace property becomes useless, because, as stated in the Kubernetes docs, cross-namespace owner references are disallowed, thus allowing for the secrets to be immediately garbage-collected, as stated in #1578. For the owner references to be valid, the secrets need to be generated in the namespace of the MDBC resource. However, if the user needs the secrets to be present in other namespaces, they can use reflector, for instance, which allows for the secrets to be copied to other namespaces. The problem is that reflector and other similar controllers require the source secrets to be annotated with specific properties.

As such, I've implemented a connectionStringSecretAnnotations property which allows mongodb-kubernetes-operator users to specify per-user connection string secret annotations.

I've done it in this way because I'm not very experienced with Go and this felt like the simplest way to do it. I could've also refactored all of the connection string secret to be grouped under a connectionStringSecret object, but this would break backwards compatibility.

All Submissions:

  • Have you opened an Issue before filing this PR?
  • Have you signed our CLA?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Put closes #XXXX in your comment to auto-close the issue that your PR fixes (if such).

@limwa limwa force-pushed the feat/connection-string-secret-annotations branch from 2ece40f to c7c21e5 Compare July 5, 2024 15:26
@mircea-cosbuc
Copy link
Member

Thank you for your contribution @limwa , enabling the tests for this and will review to get it to a merge-able state.

@mircea-cosbuc mircea-cosbuc added the safe-to-test Add this label to PRs from forks to trigger E2E tests label Jul 5, 2024
@limwa
Copy link
Contributor Author

limwa commented Jul 20, 2024

Hey @mircea-cosbuc! Is there any thing I need to do or should I just wait? Thanks!

@nammn
Copy link
Collaborator

nammn commented Sep 5, 2024

Hey @limwa thanks for the contribution!
Can you add a unit test and update one of our existing e2e tests (example) as well?

Thank you!

@limwa
Copy link
Contributor Author

limwa commented Sep 11, 2024

Hi. Yes, I'll add the tests (and thank you for the example)! Right now, I'm a bit busy, but I'll pick this up as soon as possible.

@jorgecuesta
Copy link

Hi thanks @limwa for this PR, was exaclty what I need and btw, it works smooth.

I build and push to a public registry an image non official from this PR code. I want to let you all know in case someone else came to this before mongodb guys and the pr owner figure out the remaining requirements.

Docker Image: https://hub.docker.com/layers/poktscan/mongodb-kubernetes-operator/pr-1582/images/sha256-be92755482fafd207b1a8ef2f0e48eb9f6cbc58355c3e07bc31c4c9e06780cc4?context=repo

@limwa limwa force-pushed the feat/connection-string-secret-annotations branch from 441396d to 0d6e1f2 Compare October 14, 2024 00:44
@limwa
Copy link
Contributor Author

limwa commented Oct 14, 2024

Hey @nammn, regarding the tests, I've added a test that tests for the presence of the annotations in the generated secret.
Also, when testing, I noticed that there was some new code that was autogenerated. I committed it in 0d6e1f2. Please let me know if this is okay and is expected!

If there's anything else I can help with, please let me know! Thank you for your time.

Copy link
Contributor

This PR is being marked stale because it has been open for 60 days with no activity. Please update the PR or ask for a fresh review.

@github-actions github-actions bot added the stale label Dec 13, 2024
@limwa
Copy link
Contributor Author

limwa commented Dec 16, 2024

@mircea-cosbuc @lsierant @slaskawi @nammn @Julien-Ben @MaciejKaras @lucian-tosa @fealebenpae can this PR get a review please? Sorry for the notification, but the stale-bot said I should ask for a fresh review

@limwa limwa force-pushed the feat/connection-string-secret-annotations branch from e71a8fb to 4075d85 Compare December 16, 2024 11:05
@github-actions github-actions bot removed the stale label Mar 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe-to-test Add this label to PRs from forks to trigger E2E tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Enable Copying/Annotation of Generated Secrets to Additional Namespaces
4 participants