<p>My deployed Spring boot application to trying to connect to an external SQL Server database from Kubernetes Pod. But every time it fails with error </p>

<blockquote>
  <p>Failed to initialize pool: The TCP/IP connection to the host &lt;>, port 1443 has failed.<br>
  Error: "Connection timed out: no further information.<br>
  Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.</p>
</blockquote>

<p>I have tried to exec into the Pod and successfully ping the DB server without any issues</p>

<p>Below are the solutions I have tried:</p>

<ol>
<li><p>Created a Service and Endpoint and provided the DB IP in configuration file tried to bring up the application in the Pod</p></li>
<li><p>Tried using the Internal IP from Endpoint instead of DB IP in configuration to see Internal IP is resolved to DB IP</p></li>
</ol>

<p>But both these cases gave the same result. Below is the yaml I am using the create the Service and Endpoint.</p>

<pre class="lang-css prettyprint-override"><code>---
apiVersion: v1
kind: Service
metadata:
  name: mssql
  namespace: cattle
spec:
  type: ClusterIP
  ports:
  - port: 1433
---
apiVersion: v1
kind: Endpoints
metadata:
  name: mssql
  namespace: cattle
subsets:
- addresses:
  - ip: &lt;&lt;DB IP&gt;&gt;
  ports:
  - port: 1433
</code></pre>

<p>Please let me know if I am wrong or missing in this setup.</p>

<p>Additional information the K8s setup</p>

<ul>
<li>It is clustered master with external etcd cluster topology</li>
<li>OS on the nodes is CentOS</li>
<li>Able to ping the server from all nodes and the pods that are created</li>
</ul>

Sujith Shajee
<p>For this scenario a headless service is very useful. You will redirect traffic to this ip without defining an endpoint. </p>

<pre><code>kind: "Service"
apiVersion: "v1"
metadata:
  namespace: "your-namespace"
  name: "ftp"
spec:
  type: ExternalName
  externalName: your-ip
</code></pre>
