pterodactyl / panel

Pterodactyl® is a free, open-source game server management panel built with PHP, React, and Go. Designed with security in mind, Pterodactyl runs all game servers in isolated Docker containers while exposing a beautiful and intuitive UI to end users.
https://pterodactyl.io
Other
6.78k stars 1.73k forks source link

Add support for shared MySQL databases that is not open to the public #3239

Closed Mouradif closed 3 years ago

Mouradif commented 3 years ago

Is your feature request related to a problem? Please describe.

For BungeeCord based servers, one docker container is running BungeeCord and each server connected to it is on its own container. The only possibility so far for these servers to share the same MySQL database is if the database is open to the public (aka listening on 0.0.0.0).

Describe the solution you'd like An elegant solution IMHO would be to add the possibility to spawn MySQL/MariaDB containers in a node and give it a label (case insensitive, no space). One could then connect it to connect it to game servers. When a game server is connected to a database, the local IP of the database and its label (ie: 172.18.0.x mydatabase) could be added to the /etc/hosts of the game server container.

This should be done at the wings level I guess.

Describe alternatives you've considered

My current solution that works is that I manually spinned up a mariadb container and connected it to the pterodactyl_nw network. I had to inspect it to find its local IP and manually add it to /etc/hosts of all dependent containers. Now plugins that need access to MySQL like UltraPermissions can work across servers.

Besides the fact that it annoys me to have stuff going on outside of pterodactyl, the problem with this solution is that if the container is restarted the local IP may change and I would have to go update the hosts file on each container. But I'm still glad I thought of the hosts file trick otherwise I would have to change the mysql_host config entry for all dependent plugins in all servers

Additional context

I'm willing to work on a PR if other people manifest interest on this issue and manpower is needed

parkervcp commented 3 years ago

You can also just set the db to listen to 172.18.0.1 as well. Plus with a firewall you can block external access as well.

Mouradif commented 3 years ago

You can also just set the db to listen to 172.18.0.1 as well. Plus with a firewall you can block external access as well.

the keyword here is shared database

parkervcp commented 3 years ago

Is this between host servers? I am not sure what you are talking about "shared" you can use the login information from any server to log into a DB on the same host server.

I.E. All my servers I want to share a DB (172,18,0,1) are on server A. Game A has a DB (db1) associated to it. Game B can use the same login details even though the DB (db1) is associated to Game A

My Games on Server B will need to use the external IP for Server A to use the same DB (db1).

Mouradif commented 3 years ago

Sounds like a workaround to me. Also :

Besides the fact that it annoys me to have stuff going on outside of pterodactyl, the problem with this solution is that if the container is restarted the local IP may change and I would have to go update the hosts file on each container. But I'm still glad I thought of the hosts file trick otherwise I would have to change the mysql_host config entry for all dependent plugins in all servers

I like my workaround better but would still like to have all of that manageable without ever having to ssh in my server

DaneEveritt commented 3 years ago

Can't you just bind the MySQL instance to the docker0 interface and call it a day? You're basically wanting MySQL containers "on demand" for any given set of servers, rather than a single global MySQL instance that any of those servers can connect to?

Mouradif commented 3 years ago

@DaneEveritt Is that something I can do from the panel ?

DaneEveritt commented 3 years ago

No, but it is just part of running a large instance, the Panel was never designed to handle things like that. To my knowledge most everyone using the database support is running a few specific instances that they then deploy server-specific databases too, rather than individual MySQL instances on every node for every server.

Mouradif commented 3 years ago

The current behaviour regarding databases is the following:

I personally can't think of a use case that could have motivated the development of this feature the way it was done. But taking inspiration from it, and to fix my particular use case (creating a MySQL database that will be used by multiple servers on a node) which I believe is very common, I thought I'd post this feature request here.

Now my problem was already solved with a custom workaround before I came to post here. But I did think since there are many other people who use that panel and who don't have SSH access, it would be great if they could do that from the web interface. Since my own problem is solved, I have no particular reason to allocate time for that development but I thought I'd post the idea, see of more people are interested in that, if so, I would gladly work on it to help people who have the same use case as mine.

Lastly, if I may, answers like you can just <insert-solution-that-requires-scripting> for a user-friendly panel project are not helping for a feature request. The whole idea behind this project and PufferPanel before it is to allow people to manage their game servers without having to ssh in their server. I'm just proposing a feature that solves an extremely common situation, maybe the solution I'm proposing is not the best (let's discuss it maybe?) but the problem is real. Exhibit A: none of the alternative solutions you replied with can be done using only the panel.

And @DaneEveritt, by observing how everyone is using the database support you can't possibly observe the need I'm talking about because people who have this need don't use the currently built-in database support because it doesn't allow it. Hence my feature request.

DaneEveritt commented 3 years ago

Need to remember this panel is built to support large-scale hosting instances as well, which I can already guess are unlikely to be excited about having potentially tens/hundreds of different MySQL containers running on top of the servers on each node. In addition, many end-users of hosting companies are looking for interfaces like phpmyadmin to exist so they can just login to their instance, so that adds additional complexity on top of this request.

Reading back over your request, it sounds like you're asking for something similar to #1694?

Also, to clarify, I think you misunderstand the point of this project. It is not to remove the need for SSH access for those trying to have more complicated or tailored setups. It exists to fill a void in the community and provide a stable and secure platform that allows people to build out custom features that work for them, rather than forcing everyone into one way of doing things.

There are plenty of great ideas out there, and if I had a full-time job working on this software and a team of engineers to help me build things, sure I'd be more happy to dig into every request and build things, but alas that is not the current state of the project so I have to be measured in what I am willing to entertain feature wise (and for long-term support).

Mouradif commented 3 years ago

Yes my feature requests comes from exactly the same problem as #1694

And I'm surprised by @schrej's answer. Literally every Minecraft server admin I know needs this feature (and uses it one way or another). A lot of people run multiple servers and want their players to have shared attributes like in-game currency, roles, etc...

schrej commented 3 years ago

You don't need to assign a database to multiple servers in order to use it though. You can simply use the same credentials from all servers. Linking a database to multiple servers so they show up in the database lists of those servers would merely be a UX improvement. I'm not saying that people aren't using the same database with multiple servers.

Mouradif commented 3 years ago

The feature I'm requesting would allow creating a database instance that's only accessible by servers in a specific node (same docker network) without ever having to use the command line.

Also the whole panel is "merely" a UX improvement if you compare it to the command line

DaneEveritt commented 3 years ago

Does that not just fall apart the moment you have a network spanning more than one machine where you need to "link" a database to multiple servers? This also is a significant increase in resource usage to spin up a MySQL instance for every combination of servers that wants one (imagine one server wanting three databases linked to three different sets of servers), and then you've got the inevitable performance issues associated with that.

The idea is valid, but there is a lot of implementation that you're just glossing over here I feel.

tinyoverflow commented 3 years ago

I don't really get your point here. In addition, you're not answering all the questions asked.

I'm hosting many gameservers which are interconnected via BungeeCord and all use the same single database created in one of them.

You simply bind your MySQL instance to (I guess) 172.18.0.1 and then use that as your MySQL host on ALL Minecraft servers. This obviously only works for Minecraft servers on that specific physical host / virtual machine.

There is no need to spin up MySQL containers for every single gameserver. If you do not want to bike it to 172.18.0.1 because you have other things on that host, bind it to 0.0.0.0 and block it via the firewall.

Mouradif commented 3 years ago

@tinyoverflow I never suggested to spawn a new mysql instance for each gameserver. Quite the opposite. Nevermind, I must be dumb

andriemc commented 2 years ago

@DaneEveritt hey, what he is saying is that a database created for a single server could be made to show for multiple servers in the panel which is just a visual effect not using any more resources

fucksophie commented 2 years ago

172.18.0.1

If I change the MySQL database to 0.0.0.0, how would I access it from the pterodactyl container?