This topic describes connecting to the In-Memory DB instance from your managed Kubernetes cluster.
Ensure that the following are available before connecting to the In-Memory DB instance:
A datacenter with the following id: xyz-my-datacenter.
A private LAN with id 3 using the network 10.1.1.0/24.
A database connected to LAN 3 with the following IP address: 10.1.1.5/24.
A Kubernetes cluster with the following id: xyz-my-cluster.
In the following example, DHCP is used to assign IP addresses to node pools. Therefore, the database must be in the same subnet as the DHCP server.
To enable connectivity, follow these steps:
Connect node pools to the private LAN, which is connected to the database:
Create a pod to test the connectivity. Schedule the pod exclusively for the node pools connected to the additional LAN if you have several node pools.
Alternatively, you can also use the following commands:
Create the pod: kubectl apply -f pod.yaml
Attach the pod and test connectivity:
Result: The database starts accepting connections.
ionosctl k8s nodepool create --cluster-id xyz-my-cluster --datacenter-id xyz-my-datacenter --lan-ids 3 --dhcp=true --name=my_nodepool# pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: connectivity-test
labels:
role: connectivity-test
spec:
containers:
- name: connectivity-test
image: in-memory db
stdin: true
tty: true
command:
- "/bin/bash"kubectl attach -it connectivity-test
in-memory-db -u <USERNAME> -p -h <DNS_NAME> --execute \"SHOW DATABASES;\"