So I have installed a MongoDB server on my local development machine inside a Docker container and can successfully read and write data from outside the container. However, I want to connect to this database from within my local kubernetes cluster running on the same machine.
I have created a K8 service to do this:
---
apiVersion: v1
kind: Service
metadata:
name: mongo
spec:
type: ClusterIP
ports:
- port: 27017
targetPort: 27017
---
apiVersion: v1
kind: Endpoints
metadata:
name: mongo
subsets:
- addresses:
- ip: 172.17.0.2
ports:
- port: 27017
However when I run a shell from one of the pods in my cluster, I am unable to connect to establish a mongo shell connection.
Any help is greatly appreciated as I am fairly new to K8. I have read the docs and I can't figure out why this isn't working...