I am running Rancher Desktop on my ubuntu laptop. I have a container running mongodb in a kubernetes container:
$ kubectl get all
NAME READY STATUS RESTARTS AGE
pod/mongo-deployment-7fb46bd85-vz9th 1/1 Running 0 37m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.43.0.1 <none> 443/TCP 3d17h
service/mongo-service NodePort 10.43.132.185 <none> 27017:32040/TCP 37m
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/mongo-deployment 1/1 1 1 37m
NAME DESIRED CURRENT READY AGE
replicaset.apps/mongo-deployment-7fb46bd85 1 1 1 37m
So the node port of the mongo service is: 32040.
I have found the local ip of the kubernetes node:
$ kubectl get node -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
lima-rancher-desktop Ready control-plane,master 3d17h v1.23.6+k3s1 192.168.5.15 <none> Alpine Linux v3.15 5.15.32-0-virt containerd://1.5.11
so the internal ip is: 192.168.5.15
but when i try to connect to 192.168.5.15 on port 32040 i get connection timed out
.
could i have a hint on how to do this with Rancher Desktop ?
thank you, Andrei
kubectl port-forward service/mongo-service 28015:27017
, then you can uselocalhost:28015
to connect to it. Rancher desktop comes with traefik as ingress controller if I am not mistaken. You could also create an ingress for your mongo service. – Goar