<p>I wanted to check my mongo database, not sure which database my application is putting the data. Basically i have configured a very simple tasks application using a python flask api(deployed in gke) which in turn connects to a mongo database in the same gke cluster. The application works fine.
I referred to this link
<a href="https://levelup.gitconnected.com/deploy-your-first-flask-mongodb-app-on-kubernetes-8f5a33fa43b4" rel="nofollow noreferrer">link</a></p>
<p>Below is my application yaml file</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: tasksapp
  labels:
    app: tasksapp
spec:
  replicas: 1
  selector:
    matchLabels:
      app: tasksapp
  template:
    metadata:
      labels:
        app: tasksapp
    spec:
      containers:
        - name: tasksapp
          image: myimage/1.0
          ports:
            - containerPort: 5000
          imagePullPolicy: Always
</code></pre>
<p>The python code section which connects to the database ---&gt;This does not have username /password. Not sure which database it is connecting to(even though in the code it says as 'dev'. This is why I wanted to check the mongo db pod.</p>
<pre><code>from bson.objectid import ObjectId
import socket
app = Flask(__name__)
app.config[&quot;MONGO_URI&quot;] = &quot;mongodb://mongo:27017/dev&quot;
mongo = PyMongo(app)
db = mongo.db
@app.route(&quot;/&quot;)
def index():
    hostname = socket.gethostname()
    return jsonify(
        message=&quot;Welcome to Tasks app! I am running inside {} pod!&quot;.format(hostname)
    )
</code></pre>
<p>the mongo db deployment yaml</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: mongo
spec:
  selector:
    matchLabels:
      app: mongo
  template:
    metadata:
      labels:
        app: mongo
    spec:
      containers:
        - name: mongo
          image: mongo
          ports:
            - containerPort: 27017
          volumeMounts:
            - name: storage
              mountPath: /data/db
      volumes:
        - name: storage
          persistentVolumeClaim:
            claimName: mongo-pvc
</code></pre>
<p>the issue is that when i log into the pod for mongo, mongo command is not recognized as shown below?</p>
<pre><code>kubectl exec -it mongo-869f6488c8-jnkgp -- /bin/bash
root@mongo-869f6488c8-jnkgp:/# cd home
root@mongo-869f6488c8-jnkgp:/home# ls
root@mongo-869f6488c8-jnkgp:/home# mongo
bash: mongo: command not found
</code></pre>

bionics parv
<p>Your deployment does not specify an image tag so will run the latest version of mongo (currently v6).</p>
<p>v6 mongo does not include this legacy <code>mongo</code> shell; it has been replaced with <code>mongosh</code></p>
<pre><code>docker run -it --entrypoint /bin/bash mongo
root@e920eac138d7:/# mongo
bash: mongo: command not found
root@e920eac138d7:/# mongosh --nodb
Current Mongosh Log ID: 648ce23ff5d64ce445218977
Using Mongosh:          1.10.0

For mongosh info see: https://docs.mongodb.com/mongodb-shell/


To help improve our products, anonymous usage data is collected and sent to MongoDB periodically (https://www.mongodb.com/legal/privacy-policy).
You can opt-out by running the disableTelemetry() command.
</code></pre>
<p>Notwithstanding this, the points that <a href="https://stackoverflow.com/a/76493330/10490683">Ernani</a> makes are also relevant.</p>
