Closed Freyert closed 2 years ago
Related to #215
Fixed in #282
I can still see the same issue with GlobalAPIKey.
mongodb
and created the global secret in the same namespace.kubectl get secret mongodb-atlas-operator-api-key -n mongodb --show-labels
NAME TYPE DATA AGE LABELS
mongodb-atlas-operator-api-key Opaque 3 18h atlas.mongodb.com/type=credentials
WATCH_NAMESPACE
to ns2
AtlasProject
CR in ns2
namespace and got following error
{"level":"INFO","time":"2022-07-12T09:04:54.662Z","msg":"Status update","atlasproject":"ns2/test-project","lastCondition":{"type":"ProjectReady","status":"False","lastTransitionTime":null,"reason":"AtlasCredentialsNotProvided","message":"Secret \"mongodb-atlas-operator-api-key\" not found"}}
What am I missing here?
mongodb
ns2
reason":"AtlasCredentialsNotProvided","message":"Secret \"mongodb-atlas-operator-api-key\" not found"
I used the debugger to discover that the cache for the manager's kubernetes client uses the
WATCH_NAMESPACE
to populate its cache ofSecrets
. Therefore the cache will not havemongodb/mongodb-atlas-operator-api-key
.This is the documented behavior of the
Namespace
option for controller mangers: https://github.com/kubernetes-sigs/controller-runtime/blob/ef5c8a3ffd288667b89005aebad5ff6e0cf0c5e4/pkg/manager/manager.go#L188-L194So for the GlobalAPIKey secret to be usable I think we need to be able to mount the secret as a volume or otherwise configure a different kubernetes client for retrieving the GlobalAPIKey secret.
Please let me know if there's a workaround/configuration I'm missing! Thank you for your help.