I
I
Ivan Vekov2020-05-29 02:32:00
PHP
Ivan Vekov, 2020-05-29 02:32:00

How to set up an application with Mysql in minikube?

I'm trying to learn kubernetes through minikube. As an example, I am making an application on the Slim Framework. But I haven’t gotten to it yet, I seem to have realized what all these pods, nodes, services, deployments are. volumes, brands, etc. But I totally stuck on one issue and the Internet does not save me. Here I have an application on Nginx + Php-fpm as one service. Is Mysql as the second service through StatefulSet. But... how can I work with this database from my application?
I made this horror with grief in half:
https://github.com/ivekov/minikubeNginxPhpMysql

I already realized that it would be worthwhile to store database data, probably create something like the storage/ directory and exclude it from the git ... And look at the code in the app not even worth it, copied from somewhere. I can write in php and slim)
But not before that - now the goal is to understand how to get to the database.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
chupasaurus, 2020-05-29
@vekov

Well, there is a Service by name mysql, the application must knock on it by this DNS name.
Your database is already stored on hostPath inside the virtual machine according to PV.
Another note: nginx doesn't need PV unless you need to store caches (obviously not about your project). For configs, there are ConfigMap and Secret, which must be deployed along with the rest of the application.

S
Saboteur, 2020-05-29
@saboteur_kiev

Base separately, application separately.
Yes, you can run the database in a container, mount some network drive to the container where data files will be stored.
But if the cloud is supposed to be used, then there are ready-made database services for which you don’t need to think about containers at all, about manual management.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question