# Consuming External TCP Services

DevFeed: [Consuming External TCP Services](<https://devfeed.tech/articles/consuming-external-tcp-services-48667.md>)

Original publisher: [Read original article](<https://istio.io/latest/blog/2018/egress-tcp/>)

Author: Vadim Eisenberg

Published: 2018-02-06T00:00:00Z

Content type: tutorial

Language: en

Sources: [Istio](<https://devfeed.tech/sources/istio-blog.md>)

Topics: [istio](<https://devfeed.tech/topics/istio.md>), [Kubernetes](<https://devfeed.tech/topics/kubernetes.md>), [MySQL](<https://devfeed.tech/topics/mysql.md>), [Microservices](<https://devfeed.tech/topics/microservices.md>), [Deployment](<https://devfeed.tech/topics/deployment.md>), [SSL](<https://devfeed.tech/topics/ssl.md>)

Tags: [curl](<https://devfeed.tech/tags/curl.md>), [egress](<https://devfeed.tech/tags/egress.md>), [environment-variables](<https://devfeed.tech/tags/environment-variables.md>), [external](<https://devfeed.tech/tags/external.md>), [external-services](<https://devfeed.tech/tags/external-services.md>), [istio](<https://devfeed.tech/tags/istio.md>), [kubernetes](<https://devfeed.tech/tags/kubernetes.md>), [mesh](<https://devfeed.tech/tags/mesh.md>), [microservices](<https://devfeed.tech/tags/microservices.md>), [mysql](<https://devfeed.tech/tags/mysql.md>), [password](<https://devfeed.tech/tags/password.md>), [services](<https://devfeed.tech/tags/services.md>), [ssl](<https://devfeed.tech/tags/ssl.md>), [tcp](<https://devfeed.tech/tags/tcp.md>), [traffic-management](<https://devfeed.tech/tags/traffic-management.md>), [web-services](<https://devfeed.tech/tags/web-services.md>)

## AI overview

A tutorial showing how Istio applications in a Kubernetes mesh can consume an external MySQL database over TCP. It configures a Service Entry, initializes the database, and applies least-privilege credentials for the Bookinfo ratings service.

## Source excerpt

This blog post was updated on July 23, 2018 to use the new v1alpha3 traffic management API. If you need to use the old version, follow these docs. In my previous blog post, Consuming External Web Services, I described how external services can be consumed by in-mesh Istio applications via HTTPS. In this post, I demonstrate consuming external services over TCP. You will use the Istio Bookinfo sample application, the version in which the book ratings data is persisted in a MySQL database. You deploy this database outside the cluster and configure the ratings microservice to use it. You define a Service Entry to allow the in-mesh applications to access the external database. Bookinfo sample application with external ratings database First, you set up a MySQL database instance to hold book ratings data outside of your Kubernetes cluster. Then you modify the Bookinfo sample application to use your database. Setting up the database for ratings data For this task you set up an instance of MySQL. You can use any MySQL instance; I used Compose for MySQL. I used mysqlsh (MySQL Shell) as a MySQL client to feed the ratings data. Set the MYSQL_DB_HOST and MYSQL_DB_PORT environment variables: $ export MYSQL_DB_HOST=<your MySQL database host> $ export MYSQL_DB_PORT=<your MySQL database port> In case of a local MySQL database with the default port, the values are localhost and 3306, respectively. To initialize the database, run the following command entering the password when prompted. The command is performed with the credentials of the admin user, created by default by Compose for MySQL. $ curl -s https://raw.githubusercontent.com/istio/istio/release-1.31/samples/bookinfo/src/mysql/mysqldb-init.sql | mysqlsh --sql --ssl-mode=REQUIRED -u admin -p --host $MYSQL_DB_HOST --port $MYSQL_DB_PORT OR When using the mysql client and a local MySQL database, run: $ curl -s https://raw.githubusercontent.com/istio/istio/release-1.31/samples/bookinfo/src/mysql/mysqldb-init.sql | mysql -u root -