[Bitnami/Mongodb] can't read the mongodb.pem file permission denied
Which chart: 4.4.10 / mongodb-10.29.2
Describe the bug
{"t":{"$date":"2021-11-23T14:50:36.021+01:00"},"s":"E", "c":"NETWORK", "id":23248, "ctx":"main","msg":"Cannot read certificate file","attr":{"keyFile":"/certs/mongodb.pem","error":"error:0200100D:system library:fopen:Permission denied"}}
values used
helm upgrade kb-mongodb bitnami/mongodb --namespace demo \
--set architecture="replicaset" \
--set replicaCount=3 \
--set resources.limits.memory="2048Mi" \
--set resources.limits.cpu="1.5" \
--set resources.requests.memory="245Mi" \
--set resources.requests.cpu="500m" \
--set extraEnvVars[0].name=TZ \
--set extraEnvVars[0].value=Europe/Paris \
--set metrics.enabled=true \
--set metrics.resources.limits.memory="128Mi" \
--set metrics.resources.limits.cpu="100m" \
--set metrics.resources.requests.memory="128Mi" \
--set metrics.resources.requests.cpu="100m" \
--set metrics.serviceMonitor.enabled=true \
--set metrics.serviceMonitor.namespace=demo \
--set externalAccess.enabled=true \
--set externalAccess.service.type=NodePort \
--set externalAccess.service.nodePorts[0]=30001 \
--set externalAccess.service.nodePorts[1]=30002 \
--set externalAccess.service.nodePorts[2]=30003 \
--set auth.rootPassword=xxxxx \
--set auth.replicaSetKey=xxxxxx \
--set persistence.enabled=true \
--set persistence.storageClass="local-storage" \
--set persistence.accessModes[0]=ReadWriteOnce \
--set persistence.size=200Gi \
--set persistence.moutPath=/bitnami/mongodb/data/db \
--set serviceAccount.create=true \
--set serviceAccount.name="mongodb-sa" \
--set containerSecurityContext.enabled=true \
--set containerSecurityContext.runAsUser=1002 \
--set containerSecurityContext.runAsNonRoot=true \
--set podSecurityContext.enabled=true \
--set podSecurityContext.fsGroup=1002 \
--set tls.enabled=true \
--set tls.autoGenerated=true
error
mongodb 14:30:43.01
mongodb 14:30:43.01 INFO ==> ** Starting MongoDB setup **
mongodb 14:30:43.03 INFO ==> Validating settings in MONGODB_* env vars...
mongodb 14:30:43.04 INFO ==> Initializing MongoDB...
mongodb 14:30:43.06 INFO ==> Enabling authentication...
mongodb 14:30:43.06 INFO ==> Deploying MongoDB with persisted data...
mongodb 14:30:43.07 INFO ==> Writing keyfile for replica set authentication...
mongodb 14:30:43.09 INFO ==> ** MongoDB setup finished! **
mongodb 14:30:43.10 INFO ==> ** Starting MongoDB **
{"t":{"$date":"2021-11-23T14:30:43.119+01:00"},"s":"I", "c":"CONTROL", "id":20698, "ctx":"main","msg":"***** SERVER RESTARTED *****"}
{"t":{"$date":"2021-11-23T14:30:43.120+01:00"},"s":"I", "c":"CONTROL", "id":23285, "ctx":"main","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
{"t":{"$date":"2021-11-23T14:30:43.121+01:00"},"s":"E", "c":"NETWORK", "id":23248, "ctx":"main","msg":"Cannot read certificate file","attr":{"keyFile":"/certs/mongodb.pem","error":"error:0200100D:system library:fopen:Permission denied"}}
{"t":{"$date":"2021-11-23T14:30:43.121+01:00"},"s":"F", "c":"CONTROL", "id":20574, "ctx":"main","msg":"Error during global initialization","attr":{"error":{"code":140,"codeName":"InvalidSSLConfiguration","errmsg":"Can not set up PEM key file."}}}
Hi @fayssaldarif,
I see that the command is an upgrade, could you share the values of the install to try to reproduce the issue?
Hi @Mauraza
Sorry for that, I have used --install option to install it if doesn't exist.
what I'm looking for exactly, is to deploy the mongodb in replicat set mode by activating the tls and external access. I tried several times through several values yam files , but sometimes I have a permissions problem and sometimes I have a fork process problem.
If you do it, can you please share with me the values yaml file that you have used
Hi @Mauraza Do you have any updates for this issue, please ? Thanks
Hi @fayssaldarif,
Why are you using -set containerSecurityContext.runAsUser=1002 \ instead -set containerSecurityContext.runAsUser=1001 \?
Hi @Mauraza
Thanks for coming back, I am using UID 1002 instead of 1001, because I have two users in my hosts with 1001 and 1002, but my container mongodb should be run with UID 1002.
I know the default user ID used by bitnmai all times is 1001, for my case I need to change it to 1002.
Hope my answer is clear enough.
Hi,
Could you try using volumePermissions.enabled=true ?. That will run an init container that updates the permissions
This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.
Due to the lack of activity in the last 5 days since it was marked as "stale", we proceed to close this Issue. Do not hesitate to reopen it later if necessary.