Connecting flask app to mysql on kubernetes

9/11/2017

I have a MySQL container running on a Kube cluster and a flask app running on my local machine (which I eventually also plan to upload onto the kube cluster). How can I connect my flask app to the database? So far I have tried changing the host to the IP address of the Kube cluster.

conn = MySQLdb.connect(
    host=host_ip,
    user="root",
    passwd="password",
    db="flaskapp")

Just to reiterate, the flask application is running on my local machine. I can connect to a database that I run locally, but I'm not sure how to connect it to a database run on a Kube cluster, on a different machine.

-- monadoboi
flask
kubernetes
mysql
python

1 Answer

9/11/2017

you can use PyMySQL to connect to any DB, locally or online.

https://pymysql.readthedocs.io/en/latest/

-- Sriram Arvind Lakshmanakumar
Source: StackOverflow