Visual studio docker container capable of seeing kubernetes pods outside?

1/11/2020

I am currently developing docker containers using visual studio, and these container images are supposed to run in a kubernetes cluster that I am also running locally.

Currently, the docker container that is running via visual studio is not being deployed to a kubernetes cluster, but for some reason am I able to ping the kubernetes pod's ip address from the docker container, but for which I don't quite understand; should they not be separated, and not be able to reach each other?

  • And it cannot be located on the kubernetes dashboard?
  • And since they are connected, why can't I use the kubernetes service to connect to my pod from my docker container?

The docker container is capable of pinging the cluster IP, meaning that it is reachable.

nslookup the service is not able to resolve the hostname.

-- kafka
docker
kubernetes
visual-studio-2019

1 Answer

1/13/2020

So, as I already stated in the comment:

When Docker is installed, a default bridge network named docker0 is created. Each new Docker container is automatically attached to this network, unless a custom network is specified.

Thats mean you are able to ping containers by their respective IP. But you are not able to resolve DNS names of cluster objects - you VM know nothing about internal cluster DNS server.

Few option what you can do:

1) explicitly add record of cluster DNS to /etc/hosts inside VM

2) add a record to /etc/resolv.conf with nameserver and search inside VM. See one of my answers related to DNS resolution on stack: nslookup does not resolve Kubernetes.default

3)use dnsmasq as described in Configuring your Linux host to resolve a local Kubernetes cluster’s service URLs article. Btw I highly recommend you read it from the beginning till the end. It greatly describes how to work with DNS and what workaround you can use.

Hope it helps.

-- VKR
Source: StackOverflow