<p>I've got an InfluxDB as database service in the <strong>default</strong> namespace.
It's service is called influxdb and works fine with chronograf to visualize the data.</p>
<p>Now i'd like to connect with an other deployment from the namspace <strong>test</strong> to this service. It's a python application. The normal python Influxdb Lib uses <a href="http://docs.python-requests.org/" rel="nofollow noreferrer">Requests</a> to connect to the db.</p>
<p><strong>Architecture Overview</strong></p>
<p>Istio is also installed.</p>
<p>Namspace: Default</p>
<ul>
<li>Influxdb Deployment</li>
<li>Influxdb Service</li>
<li>Chronograf Deployment (visualise influxdb)</li>
<li>Chronograf Service to Ingress(for external web access)</li>
</ul>
<p>Namespace: test</p>
<ul>
<li>Python App which should connect to influxdb for processing etc.</li>
<li>Influxdb Service (which points to influxdb.default.svc.cluster.local)</li>
</ul>
<p>Therefore i created a <strong>service</strong> in the Namespace <strong>test</strong> which points to the service of influxdb in the default namespace.</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: influxdb
  labels:
    app: pythonapp
  namespace: test
spec:
  type: ExternalName
  externalName: influxdb.default.svc.cluster.local
  ports:
    - port: 8086
      name: http
    - port: 8088
      name: http-flux
</code></pre>
<p>And now deployed the python app which points to the influxdb Service. Which keeps getting a http connection error.</p>
<pre><code>2020-07-03 13:02:05 - db.meterdb [meterdb.__init__:57] - ERROR - Oops, something wen't wrong during init of db. message: HTTPConnectionPool(host='influxdb', port=8086): Max retries exceeded with url: /query?q=SHOW+DATABASES (Caused by NewConnectionError('&lt;urllib3.connection.HTTPConnection object at 0x7f6863ed6310&gt;: Failed to establish a new connection: [Errno 111] Connection refused'))
2020-07-03 13:02:05 - db.meterdb [meterdb.check_connection:113] - ERROR - can't reach db server... message: HTTPConnectionPool(host='influxdb', port=8086): Max retries exceeded with url: /ping (Caused by NewConnectionError('&lt;urllib3.connection.HTTPConnection object at 0x7f6863e57650&gt;: Failed to establish a new connection: [Errno 111] Connection refused'))
</code></pre>
<p>When I visualise the traffic with kiali I see, that the Python app tries to connect to the influxdb service, but which is unknown with http traffic.</p>
<p>I don't know how to get it work to use the created influxdb Service.</p>
<p>Connection settings for python influxdb Client library. <a href="https://github.com/influxdata/influxdb-python" rel="nofollow noreferrer">Link to python influxdb lib</a></p>
<ul>
<li>host=influxdb</li>
<li>port=8086</li>
</ul>
<p><a href="https://i.stack.imgur.com/ZjXQu.png" rel="nofollow noreferrer">Traffic from Kiali</a></p>
<p>How can i route the traffik to the right service ?
It seems to me, that it routes the traffik to an unknown service because it's http and not tcp.</p>

<p>You don't need the</p>
<pre><code>kind: Service
metadata:
  name: influxdb
  labels:
    app: pythonapp
  namespace: test
</code></pre>
<p>Just access the service directly in your python request:</p>
<pre><code>requests.get('influxdb.default.svc.cluster.local:8086')
</code></pre>
<p>And this can be more configurable.</p>
<pre class="lang-yaml prettyprint-override"><code># Kubernetes deployment
      containers:
      - name: pythonapp
        env:
        - name: DB_URL
          value: influxdb.default.svc.cluster.local:8086
</code></pre>
<pre class="lang-py prettyprint-override"><code># python
DB = os.environ['DB_URL']
requests.get(DB)
</code></pre>
