<p>I'm trying to deploy mongodb on my k8s cluster as mongodb is my db of choice. To do that I've  config files (very similar to what I did with postgress few weeks ago). </p>

<p>Here's mongo's deployment k8s object:</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: panel-admin-mongo-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      component: panel-admin-mongo
  template:
    metadata:
      labels:
        component: panel-admin-mongo
    spec:
      volumes:
        - name: panel-admin-mongo-storage
          persistentVolumeClaim:
            claimName: database-persistent-volume-claim
      containers:
        - name: panel-admin-mongo
          image: mongo
          ports:
            - containerPort: 27017
          volumeMounts:
            - name: panel-admin-mongo-storage
              mountPath: /data/db
</code></pre>

<p>In order to get into the pod I made a service:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: panel-admin-mongo-cluster-ip-service
spec:
  type: ClusterIP
  selector:
    component: panel-admin-mongo
  ports:
    - port: 27017
      targetPort: 27017
</code></pre>

<p>And of cource I need a PVC as well:</p>

<pre><code>apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: database-persistent-volume-claim
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 2Gi
</code></pre>

<p>In order to get to the db from my server I used server deployment object:</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: panel-admin-api-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      component: panel-admin-api
  template:
    metadata:
      labels:
        component: panel-admin-api
    spec:
      containers:
        - name: panel-admin-api
          image: my-image
          ports:
            - containerPort: 3001
          env:
            - name: MONGO_URL 
              value: panel-admin-mongo-cluster-ip-service // This is important
      imagePullSecrets:
        - name: gcr-json-key
</code></pre>

<p>But for some reason when I'm booting up all containers with kubectl apply command my server says:
<code>MongoDB :: connection error: MongoParseError: Invalid connection string</code></p>

<p>Can I deploy it like that (as it was possible with postgress)? Or what am I missing here?</p>

Murakami
<p>Use <em>mongodb://</em> in front of your <em>panel-admin-mongo-cluster-ip-service</em></p>

<p>So it should look like this:
<code>mongodb://panel-admin-mongo-cluster-ip-service</code></p>
