how to access mySQL server in kubernetes

I have created a MySQL deployment in kubernetes and exposed it as nodes-port. I can access it from inside the cluster using kubectl run -it --rm --image=mysql:5.6 --restart=Never mysql-client -- mysql -h mysql -ppassword but I need to 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.

1 answer

  • answered 2019-01-11 05:26 Hansika Madushan Weerasena

    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.