0

I have installed mysql on my Ubuntu machine. I also have a locally running Kubernetes and deployed a mysql deployment on Kubernetes and can reach to that using kubectl exec -it mysql-b4769786-5hf4m sh command, then mysql -p.

I am a little confused now. I don't know do I have two separated databases, one running locally on my OS and the other one also runs locally but upon my Kubernetes cluster? If so, how can I reach to each of them? How should I know the shell I am working with is connected to Kubernetes mysql or my OS mysql?

Or when I write a NodeJS app, will that connect to the mysql installed on Ubuntu or mysql pod is running on local Kubernetes?

best_of_man
  • 367
  • 1
  • 3
  • 12

2 Answers2

1

You indeed have two different databases. The container could even have an entirely different operating system (base image).

You can double check by running a simple test:

  • create a "container" database inside the MySQL container

  • run SHOW DATABASES; on the other MySQL instance. You shouldn't find anything.

A. Darwin
  • 582
  • 2
  • 7
1

You have two mysql database: one on you Ubuntu machine and another one in kubernetes BUT If you want to use mysql on kubernetes from your Ubuntu machine you need to create a Nodeport. If you do not expose mysql service your local application on your Ubuntu machine is unable to connect to kubernetes mysql pod. If you expose mysql pod use another port to avoid mysql problems.