ihanick / anydbver

Creates local multi-node database clusters for MySQL, Postgresql, MongoDB using Docker containers as nodes. Supports Kubernetes installations with K3D. Concentrated on Percona/Oracle MySQL/MongoDB/Postgresql database products with exact version specified.
MIT License
51 stars 12 forks source link

Allow port forwarding to expose nodes #9

Closed percona-csalguero closed 3 months ago

percona-csalguero commented 3 years ago

In order to be able to connect to the different nodes from outside the vagrant box, it would be useful to expose/forward the ports used by each node. For example, if I start a 3 nodes PS cluster, anydbver reports this:

./anydbver list
+-----------------+---------+--------------------+-----------------------------------------------+-----------+-----------+
|      NAME       |  STATE  |        IPV4        |                     IPV6                      |   TYPE    | SNAPSHOTS |
+-----------------+---------+--------------------+-----------------------------------------------+-----------+-----------+
| vagrant-default | RUNNING | 10.56.52.62 (eth0) | fd42:4c11:eee0:8c13:216:3eff:fe90:d784 (eth0) | CONTAINER | 0         |
+-----------------+---------+--------------------+-----------------------------------------------+-----------+-----------+
| vagrant-node1   | RUNNING | 10.56.52.24 (eth0) | fd42:4c11:eee0:8c13:216:3eff:feea:352d (eth0) | CONTAINER | 0         |
+-----------------+---------+--------------------+-----------------------------------------------+-----------+-----------+
| vagrant-node2   | RUNNING | 10.56.52.37 (eth0) | fd42:4c11:eee0:8c13:216:3eff:fe07:6b70 (eth0) | CONTAINER | 0         |
+-----------------+---------+--------------------+-----------------------------------------------+-----------+-----------+

The IP addresses 10.56.52.xxx cannot be accessed from a test running in my localhost. It would be useful to be able to forward, for example, 10.56.52.62:3306 to the vagrant box and being able to connect to MySQL from the outside

ihanick commented 3 months ago

Implemented in v0.1.6 added expose subcmd (currently docker-image is not supporting it), it works as docker run -p option PORT (random host port selected), HOSTPORT:PORT (select a specific port). For example after running anydbver deploy ps:latest,expose=3306 , anydbver list shows the port and you can connect with mysql client from the local machine.