-
Notifications
You must be signed in to change notification settings - Fork 525
Can't create a connection string secret in a different namespace #1578
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
Comments
From what I've seen, it appears this could be caused by the following code mongodb-kubernetes-operator/controllers/mongodb_users.go Lines 42 to 74 in 3108a94
In it:
Therefore, the password secret and connection string secret need to be in the same namespace. However, when ensuring user resources, in the following code, it is expected that the password secret is in the namespace of the MDBC, and not in the one specified for the connection string secret. mongodb-kubernetes-operator/controllers/mongodb_users.go Lines 16 to 20 in 3108a94
Ensuring consistency in the namespace used in both functions should fix the problem of needing to have the secret in both namespaces for the connection string secret to be created. However, I'm not sure what is causing the connection string secret to be deleted immediately after it is created (could be related, or not). |
An update on this: ensuring consistency on the namespaces used did solve the problem of needing to have the password secret in both namespaces (I can open a PR for this, it's a single line change). However, the problem with the connection string secret being immediately deleted was not solved. After some investigation, I came to the conclusion that the secret was being garbage collected by kubernetes. https://kubernetes.io/docs/concepts/architecture/garbage-collection/#owners-dependents states that cross-namespace owner references are disallowed by design, which is causing the secret to be immediately deleted. |
A possible solution to the connection string secret problem is to follow an approach similar to |
Since creating the "connectionStringSecretTemplate" proved to be too complex for me (I haven't ever programmed in Go), I've gone ahead and implemented a "connectionStringSecretAnnotations" property. It is implemented in my fork. Let me know if you'd like me to open a PR for the namespace consistency fix and/or the connectionStringSecretAnnotations property. |
What did you do to encounter the bug?
Steps to reproduce the behavior:
mongodb
namespace (set to watch all namespaces in the cluster)helm repo add mongodb https://mongodb.github.io/helm-charts
helm install community-operator mongodb/community-operator --namespace mongodb --create-namespace --set operator.watchNamespace="*"
testing
namespace for new secrets being created.kubectl get secret -n testing -w --output-watch-events
testing
namespace, even after the MDBC resource reaches the "Running" phase.What did you expect?
I expected a connection string secret with the name "testinguser-mongodb-secret" in the "testing" namespace to be created, after the MDBC resource reached the "Running" phase.
What happened instead?
No connection string secret was created in the "testing" namespace, even after the MDBC resource reached the "Running" phase. This only happened for the "testinguser". The "adminuser", which doesn't specify the "connectionStringSecretNamespace" parameter, had its connection string secret created in the
mongodb
namespace.Operator Information
Kubernetes Cluster Information
Additional context
If I add the
mongodb-apps-testinguser-credentials
secret to both themongodb
and thetesting
namespaces, thetestinguser-mongodb-secret
secret is created in thetesting
namespace, however, it is instantly deleted.If I only create the
mongodb-apps-testinguser-credentials
secret in thetesting
namespace, the MDBC resource never reaches the "Running" phase.Operator Logs: https://gist.github.com/limwa/f5c507000ba48edcae238134b49b0af3/raw/934bcc1016e6a2f935c576a0a7557a5452d7beaf/operator-logs.txt
kubectl get sts -n mongodb -oyaml
: https://gist.githubusercontent.com/limwa/f5c507000ba48edcae238134b49b0af3/raw/e712f778aa27e37daa361284e633301853099629/sts-out.yamlkubectl get pods -n mongodb -oyaml
: https://gist.githubusercontent.com/limwa/f5c507000ba48edcae238134b49b0af3/raw/e712f778aa27e37daa361284e633301853099629/pods-out.yamlRegarding the
mongodb-apps-0
pod (all pods seem fine, I just chose this one because it was the first one):The text was updated successfully, but these errors were encountered: