oracle / mysql-operator

Create, operate and scale self-healing MySQL clusters in Kubernetes
870 stars 235 forks source link

mysql router cant connect to cluster outside of cluster namespace #244

Open adrianNEMO opened 5 years ago

adrianNEMO commented 5 years ago

Is this a BUG REPORT or FEATURE REQUEST?

Choose one: FEATURE REQUEST

Versions

MySQL Operator Version:

Environment:

What happened?

Using the mysql router in a different namespace from cluster

What you expected to happen?

The router should be able to connect to the cluster from a different namespace

How to reproduce it (as minimally and precisely as possible)?

Create a cluster. Create a deployment in a different namespace with the mysql router as sidecar (like in the wordpress example).

Anything else we need to know?

The router can connect to the master, but after the bootstrapping the router tries to connect to the mysql cluster node without the namespace appendix of the dns record. The log from the router:

Succesfully contacted mysql server at mysql-wordpress-1.mysql-wordpress.mysql-cluster-test.svc.cluster.local. Checking for cluster state.
Succesfully contacted cluster with 3 members. Bootstrapping.
Please enter MySQL password for root:
Bootstrapping MySQL Router instance at '/tmp/mysqlrouter'...
Checking for old Router accounts
Creating account mysql_router7_izxrdpbopyx7@'%'
MySQL Router has now been configured for the InnoDB cluster 'Cluster'.
The following connection information can be used to connect to the cluster.
Classic MySQL protocol connections to cluster 'Cluster':
- Read/Write Connections: localhost:6446
- Read/Only Connections: localhost:6447
X protocol connections to cluster 'Cluster':
- Read/Write Connections: localhost:64460
- Read/Only Connections: localhost:64470
Starting mysql-router.
2018-12-12 17:10:50 main INFO [7f254112c880] Loading all plugins.
2018-12-12 17:10:50 main INFO [7f254112c880] plugin 'metadata_cache:Cluster' loading
2018-12-12 17:10:50 main INFO [7f254112c880] plugin 'routing:Cluster_default_ro' loading
2018-12-12 17:10:50 main INFO [7f254112c880] plugin 'routing:Cluster_default_rw' loading
2018-12-12 17:10:50 main INFO [7f254112c880] plugin 'routing:Cluster_default_x_ro' loading
2018-12-12 17:10:50 main INFO [7f254112c880] plugin 'routing:Cluster_default_x_rw' loading
2018-12-12 17:10:50 main INFO [7f254112c880] Initializing all plugins.
2018-12-12 17:10:50 main INFO [7f254112c880] plugin 'metadata_cache' initializing
2018-12-12 17:10:50 main INFO [7f254112c880] plugin 'routing' initializing
2018-12-12 17:10:50 main INFO [7f254112c880] Starting all plugins.
2018-12-12 17:10:50 main INFO [7f253cb29700] plugin 'metadata_cache:Cluster' starting
2018-12-12 17:10:50 main INFO [7f2537fff700] plugin 'routing:Cluster_default_ro' starting
2018-12-12 17:10:50 routing INFO [7f2537fff700] [routing:Cluster_default_ro] started: listening on 0.0.0.0:6447
2018-12-12 17:10:50 main INFO [7f25377fe700] plugin 'routing:Cluster_default_rw' starting
2018-12-12 17:10:50 routing INFO [7f25377fe700] [routing:Cluster_default_rw] started: listening on 0.0.0.0:6446
2018-12-12 17:10:50 main INFO [7f2536ffd700] plugin 'routing:Cluster_default_x_ro' starting
2018-12-12 17:10:50 routing INFO [7f2536ffd700] [routing:Cluster_default_x_ro] started: listening on 0.0.0.0:64470
2018-12-12 17:10:50 main INFO [7f25367fc700] plugin 'routing:Cluster_default_x_rw' starting
2018-12-12 17:10:50 main INFO [7f254112c880] Running.
2018-12-12 17:10:50 routing INFO [7f25367fc700] [routing:Cluster_default_x_rw] started: listening on 0.0.0.0:64460
2018-12-12 17:10:50 metadata_cache INFO [7f253cb29700] Starting Metadata Cache
2018-12-12 17:10:50 metadata_cache INFO [7f253cb29700] Connections using ssl_mode 'PREFERRED'
2018-12-12 17:10:50 metadata_cache WARNING [7f253cb29700] Failed connecting with Metadata Server mysql-wordpress-1.mysql-wordpress:3306: Unknown MySQL server host 'mysql-wordpress-1.mysql-wordpress' (2) (2005)
2018-12-12 17:10:50 metadata_cache ERROR [7f253cb29700] Failed to connect to metadata server
2018-12-12 17:10:50 metadata_cache WARNING [7f253cb29700] Failed connecting with Metadata Server mysql-wordpress-0.mysql-wordpress:3306: Unknown MySQL server host 'mysql-wordpress-0.mysql-wordpress' (2) (2005)
2018-12-12 17:10:50 metadata_cache ERROR [7f253cb29700] Failed to connect to metadata server
2018-12-12 17:10:50 metadata_cache WARNING [7f253cb29700] Failed connecting with Metadata Server mysql-wordpress-2.mysql-wordpress:3306: Unknown MySQL server host 'mysql-wordpress-2.mysql-wordpress' (2) (2005)
2018-12-12 17:10:50 metadata_cache ERROR [7f253cb29700] Failed to connect to metadata server
2018-12-12 17:10:50 metadata_cache ERROR [7f253cb29700] Failed connecting with any of the metadata servers
macno commented 5 years ago

Any update on this issue? We need to be able to reach a mysql cluster instance from several other namespaces but this bug is stopping us.

delgod commented 5 years ago

a workaround idea -- start router inside cluster namespace, create a ClusterIP or LoadBalancer service which points to the router.

macno commented 5 years ago

Thanks @delgod , I'd prefer to use mysql-router as a sidecar in my app pod, but I will give it a try

jfmrm commented 4 years ago

any update on this? For production environments this would be a great feature