title: MongoDB stopped being accessible when started using Kompose on Minikube
body: <p>I have a simple app that uses MongoDB docker image calling the url: mongodb://mongo:27017/. It was working fine using docker-compose:</p>
  
  <h2>docker-compose.yml</h2>
  
  <pre><code>version: "3.3"
  services:
    mongo:
      image: mongo
      restart: always
      container_name: mongo
      volumes:
        - /data/mongodb:/data/db
      ports:
       - "30001:27017"
    myapp:
      image: myapp:0.1.0
      restart: always
      links:
       - mongo # link this service to the database service
      depends_on:
       - mongo
  networks:
    default:
  </code></pre>
  
  <p>Then, I started to migrate to Kubernetes using Minikube (on top of VMWare) generating the following manifest YAML:</p>
  
  <pre><code>apiVersion: v1
  kind: PersistentVolumeClaim
  metadata:
    creationTimestamp: null
    labels:
      name: mongo-claim0
    name: mongo-claim0
  spec:
    accessModes:
    - ReadWriteOnce
    resources:
      requests:
        storage: 100Mi
  status: {}
  ---
  apiVersion: v1
  kind: Service
  metadata:
    creationTimestamp: null
    labels:
      name: mongo
    name: mongo
  spec:
    ports:
    - name: "30001"
      port: 30001
      targetPort: 27017
    selector:
      name: mongo
  status:
    loadBalancer: {}
  ---
  apiVersion: extensions/v1beta1
  kind: Deployment
  metadata:
    creationTimestamp: null
    labels:
      name: mongo
    name: mongo
  spec:
    replicas: 1
    strategy:
      type: Recreate
    template:
      metadata:
        creationTimestamp: null
        labels:
          name: mongo
      spec:
        containers:
        - image: mongo
          name: mongo
          ports:
          - containerPort: 27017
          resources: {}
          volumeMounts:
          - mountPath: /data/db
            name: mongo-claim0
        restartPolicy: Always
        volumes:
        - name: mongo-claim0
          persistentVolumeClaim:
            claimName: mongo-claim0
  status: {}
  ---
  apiVersion: extensions/v1beta1
  kind: Deployment
  metadata:
    creationTimestamp: null
    labels:
      name: myapp
    name: myapp
  spec:
    replicas: 1
    strategy: {}
    template:
      metadata:
        creationTimestamp: null
        labels:
          name: myapp
      spec:
        containers:
          image: myapp:0.1.0
          name: myapp
          resources: {}
        restartPolicy: Always
  status: {}
  </code></pre>
  
  <p>My PODs/services are running fine (kubectl get pods,svc):</p>
  
  <pre><code>NAME                                 READY   STATUS             RESTARTS   AGE
  pod/mongo-5d89cc6f7f-c2p4b           1/1     Running            0          43m
  pod/myapp-6c9c4f89fb-gg68t           1/1     Running            0          43m
  
  NAME                    TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)           AGE
  service/kubernetes      ClusterIP   10.96.0.1        &lt;none&gt;        443/TCP           110m
  service/mongo           NodePort    10.101.179.59    &lt;none&gt;        27017:30001/TCP   43m
  </code></pre>
  
  <p>I also, can't connect via Robo3T (MongoDB client) thought port 30001 as I could using docker-compose (even using the vboxnet0 IP 192.168.99.1).</p>
  
  <p>I don't know what could be the problem.</p>
  
  <p>UPDATE 1: I found out Kompose created a ClusterIP and transfered the port for inside the cluster to 30001, but that needed to be the port to connect from outside the cluster. I changed the services to a NodePort as follows:</p>
  
  <pre><code>apiVersion: v1
  kind: Service
  metadata:
    labels:
      name: mongo
    name: mongo
  spec:
    type: NodePort 
    ports:
      - port: 27017
        nodePort: 30001
        targetPort: 27017
    selector:
      name: mongo
  status:
    loadBalancer: {}
  </code></pre>
  
  <p>Now myapp pod is able to connect to mongo, but I still can't connect using Robo3t to the cluster via VMWare IP (192.168.99.1) and port 30001.</p>