how to access mySQL server in kubernetes

Viewed 8011

I have created a MySQL deployment in kubernetes and exposed it as nodes-port.

What I can do:
Access it from inside the cluster using
kubectl run -it --rm --image=mysql:5.6 --restart=Never mysql-client -- mysql -h mysql -ppassword

What I want to do:
Access the MySQL server from outside the cluster(like accessing a normal MySQL server).
Kubernetes v1.13 in DigitalOcean Cloud.
Guide me, please.

2 Answers

You can access it by mysql -u {username} -p {password} -h {any kubernetes worker ip} -P {nodePort}. After you start mysql container and expose it ad node port through a service.

You need to specify the MYSQL_ROOT_PASSWORD while bringing up the pod. How were you able to bring it up in Docker without it?

Related