<p>I have an external SQL server, (On the Internet accessible from my local system) that I am trying to call from inside the Minikube. I am unable to do that. I have tried the 
<a href="https://stackoverflow.com/questions/54464722/calling-an-external-service-from-within-minikube">Calling an external service from within Minikube</a></p>

<p>Error that i am getting is <em>"sqlalchemy.exc.OperationalError: (pymssql.OperationalError) (20009, b'DB-Lib error message 20009, severity 9:\nUnable to connect: Adaptive Server is unavailable or does not exist "</em></p>

<hr>

<p>I have already created pod --> service --> Endpoints. All my Clusters are under an ingress. Please see the below code for the configuration that I have done. </p>

<p>Currently, I am passing the DB HOST (1.1.1.1) as an environment variable to the POD and after this configuration, I am trying to pass the service name (sql-server) instead of DB Host Name is this correct?
Moreover, I am unable to ping the IP from inside the container. </p>

<p>Can anyone please help me. </p>

<pre><code>apiVersion: v1
kind: Endpoints
metadata:
  name: sql-server
subsets:
  - addresses:
      - ip: 1.1.1.1
    ports:
      - port: 1433
</code></pre>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: sql-server
spec:
  type: ClusterIP
  ports:
    - port: 1433
      targetPort: 1433
</code></pre>

<p>I reproduced a similar scenario in my minikube system and this solution works as described. I will drive you through the setup and how to troubleshoot this issue. </p>

<p>I have a linux server (hostname http-server) and I installed a http server (apache2) in on it that's serving a hello world message: </p>

<pre><code>user@http-server:~$ netstat -tan | grep ::80
tcp6       0      0 :::80                   :::*                    LISTEN     
user@minikube-server:~$ curl 10.128.15.209
Hello World!
</code></pre>

<p>Now that we confirmed that my service is accessible from the machine where I have minikube installed, lets connect to minikube VM and check if I can access this http service: </p>

<pre><code>user@minikube-server:~$ minikube ssh
                         _             _            
            _         _ ( )           ( )           
  ___ ___  (_)  ___  (_)| |/')  _   _ | |_      __  
/' _ ` _ `\| |/' _ `\| || , &lt;  ( ) ( )| '_`\  /'__`\
| ( ) ( ) || || ( ) || || |\`\ | (_) || |_) )(  ___/
(_) (_) (_)(_)(_) (_)(_)(_) (_)`\___/'(_,__/'`\____)

$ curl 10.128.15.209
Hello World!
</code></pre>

<p>Great! This is looking good. If you can't access your service here, you have to check your network, something is preventing your minikube server from communicating with your service. </p>

<p>Now let's exit from this minikube ssh and create our endpoint: </p>

<p>My endpoint manifest is looking like this: </p>

<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Endpoints
metadata:
  name: http-server
subsets:
  - addresses:
      - ip: 10.128.15.209
    ports:
      - port: 80
</code></pre>

<pre><code>user@minikube-server:~$ kubectl apply -f http-server-endpoint.yaml
endpoints/http-server configured
</code></pre>

<p>Let's create our service: </p>

<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Service
metadata:
  name: http-server
spec:
  ports:
    - port: 80
      targetPort: 80
</code></pre>

<pre><code>user@minikube-server:~$ kubectl apply -f http-server-service.yaml
service/http-server created
</code></pre>

<p>Checking if our service exists and save it's clusterIP for letter usage: </p>

<pre><code>user@minikube-server:~$$ kubectl get service
NAME          TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)   AGE
http-server   ClusterIP   10.96.228.220   &lt;none&gt;        80/TCP    30m
kubernetes    ClusterIP   10.96.0.1       &lt;none&gt;        443/TCP   10d
</code></pre>

<p>Now it's time to verify if we can access our service from a pod: </p>

<pre><code>kubectl run ubuntu -it --rm=true --restart=Never --image=ubuntu bash
</code></pre>

<p>This command will create and open a bash session inside a ubuntu pod. </p>

<p>In my case I'll install curl to be able to check if I can access my http server. You may need install mysql:</p>

<pre><code>root@ubuntu:/# apt update; apt install -y curl
</code></pre>

<p>Checking connectivity with my service using clusterIP:</p>

<pre><code>root@ubuntu:/# curl 10.128.15.209:80
Hello World!
</code></pre>

<p>And finally using the service name (DNS): </p>

<pre><code>root@ubuntu:/# curl http-server
Hello World!
</code></pre>

<p>Please run into all these steps and let me know if you have trouble on any and where.</p>
