-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
[bitnami/mongodb] Simplify and fix externalAccess configuration #25397
Conversation
Signed-off-by: Fran Mulero <[email protected]>
Signed-off-by: Fran Mulero <[email protected]>
Signed-off-by: Bitnami Containers <[email protected]>
Hey @fmulero thanks for looking into this. Does this work? One of the issues is that Mongo will see the external DNS name in the Replica config (which can be seen in |
At the moment I didn't face that issue, maybe because I am changing my coredns config to rewrite |
Signed-off-by: Fran Mulero <[email protected]>
…blic-names Signed-off-by: Fran Mulero <[email protected]>
Signed-off-by: Fran Mulero <[email protected]>
…arts into feature/mongoedb-public-names
Signed-off-by: Bitnami Containers <[email protected]>
Signed-off-by: Fran Mulero <[email protected]>
Hi @rrileyca, I think I reproduced the problem you mentioned. To fix it I configured the cluster using the external names and I added an init container to ensure that we can resolve the external name before init the cluster. |
Signed-off-by: Fran Mulero <[email protected]>
Hey @fmulero, thanks this is defnitely a useful feature. Does it work without the coreDNS edits in the kubernetes cluster though? I think the external DNS name has to match the hostname of the Pod, and failing a hostname match it does a DNS lookup and tries to match the IP's of the Replicas to its own IP. I don't see any changes to the hostname of the Pod, just the services. The reason changing the coreDNS config works (I believe) is because you can put the public DNS names like I think the problem here is that when you resolve the public DNS name of a node, it will resolve to the Loadbalancer IP address which is not the Pod IP. Mongo will not think it is part of the cluster in this case. Does your PR assume that you have a DNS name that always translates to the Pod IP? If so, how do you keep this DNS entry up to date? I've only used external-dns for Loadbalancers and Ingresses. |
HI @rrileyca thanks for taking care of this. I've tested it following these steps:
architecture: replicaset
replicaCount: 2
tls:
enabled: true
autoGenerated: false
replicaset:
existingSecrets:
- mongodb-0-cert
- mongodb-1-cert
arbiter:
existingSecret: mongodb-arbiter-cert
externalAccess:
enabled: true
service:
type: LoadBalancer
publicNames:
- 'mongodb-0.example.com'
- 'mongodb-1.example.com' That will create 2 external services and the pods will wait for the
architecture: replicaset
replicaCount: 2
tls:
enabled: true
autoGenerated: false
replicaset:
existingSecrets:
- mongodb-0-cert
- mongodb-1-cert
arbiter:
existingSecret: mongodb-arbiter-cert
externalAccess:
enabled: true
service:
type: LoadBalancer
publicNames:
- 'mongodb-0.example.com'
- 'mongodb-1.example.com'
hostAliases: &aliases
- ip: 35.243.236.68
hostnames:
- mongodb-0.example.com
- ip: 34.75.99.90
hostnames:
- mongodb-1.example.com
arbiter:
hostAliases: *aliases
$ kubectl delete pods mongodb-0 mongodb-arbiter-0
pod "mongodb-0" deleted
pod "mongodb-arbiter-0" deleted
$ kubectl exec -it mongodb-0 -c mongodb -- mongosh --tls --tlsCertificateKeyFile=/certs/mongodb.pem --tlsCAFile=/certs/mongodb-ca-cert --tlsAllowInvalidHostnames --port $MONGODB_PORT_NUMBER --eval "db.hello().isWritablePrimary"
true
$ kubectl exec -it mongodb-0 -c mongodb -- mongosh --tls --tlsCertificateKeyFile=/certs/mongodb.pem --tlsCAFile=/certs/mongodb-ca-cert --tlsAllowInvalidHostnames --port $MONGODB_PORT_NUMBER --eval "db.hello().secondary"
false
$ kubectl exec -it mongodb-1 -c mongodb -- mongosh --tls --tlsCertificateKeyFile=/certs/mongodb.pem --tlsCAFile=/certs/mongodb-ca-cert --tlsAllowInvalidHostnames --port $MONGODB_PORT_NUMBER --eval "db.hello().isWritablePrimary"
false
$ kubectl exec -it mongodb-1 -c mongodb -- mongosh --tls --tlsCertificateKeyFile=/certs/mongodb.pem --tlsCAFile=/certs/mongodb-ca-cert --tlsAllowInvalidHostnames --port $MONGODB_PORT_NUMBER --eval "db.hello().secondary"
true From my understanding everything looks good. |
Signed-off-by: Fran Mulero <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
…blic-names Signed-off-by: Fran Mulero <[email protected]>
Signed-off-by: Fran Mulero <[email protected]>
…le: ENOENT: no such file or directory, mkdir '/.mongodb/mongosh' Signed-off-by: Fran Mulero <[email protected]>
thanks @fmulero. Should those instructions regarding the hostAliases be added to the README? As I understand it, there is no way to deploy using public names in a single |
Signed-off-by: Fran Mulero <[email protected]>
I've just added a note about |
…ami#25397) * [bitnami/mongodb] Simplify and fix externalAccess configuration Signed-off-by: Fran Mulero <[email protected]> * Version bump Signed-off-by: Fran Mulero <[email protected]> * Update README.md with readme-generator-for-helm Signed-off-by: Bitnami Containers <[email protected]> * Change validations Signed-off-by: Fran Mulero <[email protected]> * Create init container to wait for dns resolution Signed-off-by: Fran Mulero <[email protected]> * Update README.md with readme-generator-for-helm Signed-off-by: Bitnami Containers <[email protected]> * Amend MONGODB_INITIAL_PRIMARY_HOST on arbiter statefulset Signed-off-by: Fran Mulero <[email protected]> * Add documentation Signed-off-by: Fran Mulero <[email protected]> * Fix Chart copyright and little fix on replicaset statefulset Signed-off-by: Fran Mulero <[email protected]> * Remove local addresses and IPs from certificate definition Signed-off-by: Fran Mulero <[email protected]> * Add mongosh home directory to avoid this message: Could not access file: ENOENT: no such file or directory, mkdir '/.mongodb/mongosh' Signed-off-by: Fran Mulero <[email protected]> * Add README note about hostAliases Signed-off-by: Fran Mulero <[email protected]> --------- Signed-off-by: Fran Mulero <[email protected]> Signed-off-by: Bitnami Containers <[email protected]> Co-authored-by: Bitnami Containers <[email protected]> Signed-off-by: Francois Marceau <[email protected]>
Description of the change
Allow the use of external certificates signed for external names. Current chart requires several internal names and IPs signed in the certificates provided by the user. That restriction makes almost impossible the use of this chart with external names and TLS enabled.
Benefits
Allow the use of external certificates and names in MongoDB chart.
Possible drawbacks
None
Applicable issues
Additional information
These changes were tested in the following scenario:
$ k3d cluster create
coredns
configmap:Checklist
Chart.yaml
according to semver. This is not necessary when the changes only affect README.md files.README.md
using readme-generator-for-helm