Hello!
We are attempting to create a MongoDB ReplicaSet Cluster that supports TLS with a Certificate from a ClusterIssuer of letsencrypt.
However, we have been unable to get this working, We have crt-manager set up in the cluster but for some reason, I don’t think that the operator is using it.
I tried a few workarounds to make it happen:
-
workaround 1 - I download the
ca.pam
from letsencrypt website and I thought to use it as theca.crt
in the*-ssl
and/or*-ssl-internal
secrets. - psmdb stay stuck with initializing state with errors:No SSL certificate provided by peer; connection rejected
-
workaround 2 - try to create my own Certificate with the replica set nodes as DNS and ClusterIssuer of Letsencrypt using cert-manager, then I took the
tls.crt
andtls.key
and combine them with theca.pam
from letsencrypt (from workaround 1)
certificate.yaml:
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: cluster-tls
namespace: mongodb
spec:
secretName: minimal-cluster-tls
issuerRef:
kind: ClusterIssuer
name: “letsencrypt”
dnsNames:
- stg-mongo-psmdb-rs0-0.comapny.com
- stg-mongo-psmdb-rs0-1.comapny.com
- stg-mongo-psmdb-rs0-2.comapny.com
result: psmdb still stuck on initializing state with errors:
The server certificate does not match the remote host name" and Failed to authenticate
and
{“client”“,“mechanism”:“MONGODB-X509”,“user”:“CN=stg-mongo-psmdb-rs0-0.comapny.com”,“db”:”$external",“error”:{“code”:11,“codeName”:“UserNotFound”,“errmsg”:“Could not find user "CN=stg-mongo-psmdb-rs0-0.comapny.com" for db "$external"”}}}
I don’t quite sure if it’s related, but as far as I understand when the clusterServiceDNSMode
is set to External
, then I can reach it from outside with this command:
mongo "mongodb://databaseAdmin:databasepassword@DNS:27017,DNS:27017,DNS:27017/admin?replicaSet=rs0"
apiVersion: psmdb.percona.com/v1
kind: PerconaServerMongoDB
metadata:
name: stg-mongo-psmdb
finalizers:
- delete-psmdb-pods-in-order
- delete-psmdb-pvc
spec:
clusterServiceDNSMode: “External”
unmanaged: false
allowUnsafeConfigurations: false
updateStrategy: Never
crVersion: 1.15.0
image: percona/percona-server-mongodb:5.0.15-13
imagePullPolicy: Always
upgradeOptions:
apply: disabled
schedule: “0 2 * * *”
secrets:
users: stg-eng-mongo-users
ssl: my-custom-ssl
sslInternal: my-custom-ssl-internal
replsets:
- name: rs0
size: 3
expose:
enabled: true
exposeType: LoadBalancer
serviceAnnotations:
networking.gke.io/load-balancer-type: “Internal”
volumeSpec:
persistentVolumeClaim:
resources:
requests:
storage: 3Gi
sharding:
enabled: false
any ideas on how I can do it with our own Certificate, I don’t want to use the operator Issuer because I cannot share the certificate(*.pem) with all the clients that will need to contact DB.
Thanks.