how to access mySQL server in kubernetes

1/11/2019

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).
Guide me, please. I'm using Kubernetes v1.13 in Digital Ocean Cloud.

-- AATHITH RAJENDRAN
digital-ocean
kubernetes
mysql

2 Answers

2/27/2019

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?

-- SamK
Source: StackOverflow

1/11/2019

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.

-- Hansika Madushan Weerasena
Source: StackOverflow