An application running inside the Kubernetes Cluster can use these extracted information and can access the data in MySQL Cluster without any additional setup.
NDB Cluster tools such as ndb_mgm can use the
management node service name as a connection string to connect
to the management servers. MySQL clients such as
mysql can use the
mysqld-ext
service and the password stored in
rootPasswordSecretName
to connect to the SQL
nodes.
It is first necessary to log in to an NDB Cluster pod using
kubectl
, like this:
> kubectl exec -it example-ndb-mysqld-599bcfbd45-hq8ll
Now you can execute ndb_mgm to start the NDB management client, using the mnagement node service name as the connection string:
> ndb_mgm -c example-ndb-mgmd-ext
From within ndb_mgm you can issue all of the usual management client commands, as shown here:
-- NDB Cluster -- Management Client --
ndb_mgm> SHOW
Connected to Management Server at: example-ndb-mgmd-ext:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=3 @172.17.0.6 (mysql-8.3.0 ndb-8.3.0, Nodegroup: 0, *)
id=4 @172.17.0.7 (mysql-8.3.0 ndb-8.3.0, Nodegroup: 0)
[ndb_mgmd(MGM)] 2 node(s)
id=1 @172.17.0.5 (mysql-8.3.0 ndb-8.3.0)
id=2 @172.17.0.8 (mysql-8.3.0 ndb-8.3.0)
[mysqld(API)] 5 node(s)
id=145 @172.17.0.10 (mysql-8.3.0 ndb-8.3.0)
id=146 @172.17.0.9 (mysql-8.3.0 ndb-8.3.0)
id=147 (not connected, accepting connect from any host)
id=148 (not connected, accepting connect from any host)
id=149 (not connected, accepting connect from any host)
ndb_mgm> ALL STATUS
Node 5: started (mysql-8.3.0 ndb-8.3.0)
Node 6: started (mysql-8.3.0 ndb-8.3.0)
ndb_mgm> EXIT
To connect to MySQL with the mysql client,
use the service name example-ndb-mysqld-ext
for the host name, like this:
> mysql -h example-ndb-mysqld-ext -uroot -p
Enter password: ********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 500
Server version: 8.3.0-cluster MySQL Cluster Community Server - GPL
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> SELECT * FROM INFORMATION_SCHEMA.ENGINES
> WHERE ENGINE LIKE "ndb%"\G
*************************** 1. row ***************************
ENGINE: ndbinfo
SUPPORT: YES
COMMENT: MySQL Cluster system information storage engine
TRANSACTIONS: NO
XA: NO
SAVEPOINTS: NO
*************************** 2. row ***************************
ENGINE: ndbcluster
SUPPORT: YES
COMMENT: Clustered, fault-tolerant tables
TRANSACTIONS: YES
XA: NO
SAVEPOINTS: NO
2 rows in set (0.00 sec)