4.1.2 Access From Outside Kubernetes

NDB management and SQL applications running outside the Kubernetes cluster can access the NDB Cluster running inside using the management server and SQL node services described previously; these services are of type LoadBalancer. A Kubernetes cluster provider such as minikube provisions load balancers for these services. To expose the services outside the Kubernetes cluster if you are running minikube, execute the command shown here:

> minikube tunnel

Using kubectl get service, and passing it the service name or label, you can retrieve the IP address needed by applications to connect to the NDB Cluster. For the example management node service, this can be done using either of the commands shown here:

# Retrieve management load balancer service IP address using service name
> kubectl get service "example-ndb-mgmd-ext" \
      -o jsonpath={.status.loadBalancer.ingress[0].ip}

# Retrieve management load balancer service IP address using service label
> kubectl get service \
      -l "mysql.oracle.com/resource-type=mgmd-service-ext" \
      -o jsonpath={.items[0].status.loadBalancer.ingress[0].ip}

With the service IP address just extracted, NDB management clients like ndb_mgm can connect to the NDB Cluster management servers by way of the management node service, and perform management tasks.

Similarly, you can obtain the IP address for the example SQL node load balancer service using either of these kubectl get service commands:

# Retrieve SQL node load balancer service IP address using service name
> kubectl get service "example-ndb-mysqld-ext" \
      -o jsonpath={.status.loadBalancer.ingress[0].ip}

# Retrieve SQL node load balancer service IP address using service name
> kubectl get service \
      -l "mysql.oracle.com/resource-type=mysqld-service-ext" \
      -o jsonpath={.items[0].status.loadBalancer.ingress[0].ip}

With the IP address obtained by either of these two commands, MySQL clients such as mysql can connect to the NDB Cluster SQL nodes and execute SQL statements.