Skip to content
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] Can't figure out configuration to access the mongo container outside the k8s cluster #23776

Closed
rekaburmeister opened this issue Feb 21, 2024 · 4 comments
Labels
mongodb solved stale 15 days without activity tech-issues The user has a technical issue about an application

Comments

@rekaburmeister
Copy link

rekaburmeister commented Feb 21, 2024

Name and Version

bitnami/mongodb 13.16.3

What architecture are you using?

None

What steps will reproduce the bug?

I would like to deploy mongo (standalone or replicaset - I just want to get this working for now) into our EKS cluster, using Helm.

Assuming I cloned https://github.com/bitnami/charts/tree/main/bitnami/mongodb, which values should be set to simply be able to do helm install mongo ., to have a container running that I can connect to, outside the k8s cluster?

For simplicity, I tried switching TLS off and changed the architecture to replicaset but made no other major changes (e.g. set root password etc)

Installation produced the following output:

NAME: mongo
LAST DEPLOYED: Wed Feb 21 12:57:34 2024
NAMESPACE: gayr
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: mongodb
CHART VERSION: 13.16.3
APP VERSION: 6.0.8

** Please be patient while the chart is being deployed **

MongoDB® can be accessed on the following DNS name(s) and ports from within your cluster:

    mongo-gayr-0.mongo-gayr-headless.gayr.svc.cluster.local:27017
    mongo-gayr-1.mongo-gayr-headless.gayr.svc.cluster.local:27017

To get the root password run:

    export MONGODB_ROOT_PASSWORD=$(kubectl get secret --namespace gayr mongo-gayr -o jsonpath="{.data.mongodb-root-password}" | base64 -d)

To connect to your database, create a MongoDB® client container:

    kubectl run --namespace gayr mongo-gayr-client --rm --tty -i --restart='Never' --env="MONGODB_ROOT_PASSWORD=$MONGODB_ROOT_PASSWORD" --image docker.io/bitnami/mongodb:6.0.8-debian-11-r12 --command -- bash

Then, run the following command:
    mongosh admin --host "mongo-gayr-0.mongo-gayr-headless.gayr.svc.cluster.local:27017,mongo-gayr-1.mongo-gayr-headless.gayr.svc.cluster.local:27017" --authenticationDatabase admin -u $MONGODB_ROOT_USER -p $MONGODB_ROOT_PASSWORD

To connect to your database nodes from outside, you need to add both primary and secondary nodes hostnames/IPs to your Mongo client. To obtain them, follow the instructions below:

  NOTE: It may take a few minutes for the LoadBalancer IPs to be available.
        Watch the status with: 'kubectl get svc --namespace gayr -l "app.kubernetes.io/name=gayr,app.kubernetes.io/instance=mongo,app.kubernetes.io/component=mongodb,pod" -w'

    MongoDB® nodes domain: You will have a different external IP for each MongoDB® node. You can get the list of external IPs using the command below:

        echo "$(kubectl get svc --namespace gayr -l "app.kubernetes.io/name=gayr,app.kubernetes.io/instance=mongo,app.kubernetes.io/component=mongodb,pod" -o jsonpath='{.items[*].status.loadBalancer.ingress[0].ip}' | tr ' ' '\n')"

    MongoDB® nodes port: 27017
  • running the suggested kubectl run --namespace gayr mongo-gayr-client ... allowed me to connect to the deployed container within the client container, but only to the service deployed as mongo-gayr-0-external
  • running the suggested get svc --namespace gayr -l "app.kubernetes.io/name=gayr,app.kubernetes.io/instance=mongo,app.kubernetes.io/component=mongodb,pod" -w command did provide the external IPs (host names) to the load balancers for mongo-gayr-0-external and mongo-gayr-1-external
  • running the suggested echo "$(kubectl get svc --namespace gayr -l "app.kubernetes.io/name=gayr,app.kubernetes.io/instance=mongo,app.kubernetes.io/component=mongodb,pod" -o jsonpath='{.items[*].status.loadBalancer.ingress[0].ip}' | tr ' ' '\n')" returned empty
  • using a mongo shell to connect from my local machine, as mongosh admin --host "host-name-for-mongo-gayr-0-external" --authenticationDatabase admin -u admin_user_name -p admin_password would result in MongoServerSelectionError: Server selection timed out after 30000 ms (running the same command in the mongo-gayr-client container worked fine)

I don't think this is a bug in the product - but given I'm trying the simplest of use cases (i.e. gimme a working mongo!) I would say the documentation would need updating with some "getting started" steps.

Are you using any custom parameters or values?

- nameOverride: "gayr"

What is the expected behavior?

I should be able to produce a basic cluster deployment

What do you see instead?

I can't connect to the deployed container unless I use the provided client

@rekaburmeister rekaburmeister added the tech-issues The user has a technical issue about an application label Feb 21, 2024
@github-actions github-actions bot added the triage Triage is needed label Feb 21, 2024
@github-actions github-actions bot removed the triage Triage is needed label Feb 22, 2024
@github-actions github-actions bot assigned fevisera and unassigned carrodher Feb 22, 2024
@fevisera
Copy link
Contributor

fevisera commented Mar 8, 2024

Hi @rekaburmeister,

Thanks for reaching out. It seems that needs some additional configurations related to EKS which I am not an expert. I would recommend reaching out to the appropriate forum where the community can provide you with more specific guidance related to configuring EKS.

Additionally, I suggest exploring the Get Started With Bitnami Charts Using The Amazon Elastic Container Service For Kubernetes (EKS). There, you will find an example of configuring EKS with a helm chart example.

I hope this information is helpful to you.

Copy link

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.

@github-actions github-actions bot added the stale 15 days without activity label Mar 24, 2024
Copy link

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.

@bitnami-bot bitnami-bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 30, 2024
@ZeldOcarina
Copy link

How I've handled this is by port-forwarding the mongodb service and from there access it with Compass. It's even more secure as it can be accessed with credentials only if port-forwarded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mongodb solved stale 15 days without activity tech-issues The user has a technical issue about an application
Projects
None yet
Development

No branches or pull requests

5 participants