'Connecting to Milvus Database through Google Kubernetes Engine and Python

I’m looking to connect to a Milvus database I deployed on Google Kubernetes Engine.

I am running into an error in the last line of the script. I'm running the script locally.

Here's the process I followed to set up the GKE cluster: (https://milvus.io/docs/v2.0.0/gcp.md)

Here is a similar question I'm drawing from

Any thoughts on what I'm missing?

import os
from pymilvus import connections
from kubernetes import client, config

My_Kubernetes_IP = 'XX.XXX.XX.XX'

# Authenticate with GCP credentials
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = os.path.abspath('credentials.json')

# load milvus config file and connect to GKE instance 
config = client.Configuration(os.path.abspath('milvus/config.yaml'))
config.host = f'https://{My_Kubernetes_IP}:19530'
client.Configuration.set_default(config)

## connect to milvus
milvus_ip = 'xx.xxx.xx.xx'
connections.connect(host=milvus_ip, port= '19530')

Error:

BaseException: <BaseException: (code=2, message=Fail connecting to server on xx.xxx.xx.xx:19530. Timeout)>



Solution 1:[1]

If you want to connect to the Milvus in the k8s cluster by ip+port, you may need to forward your local port 19530 to the Milvus service. Use a command like the following:

$ kubectl port-forward service/my-release-milvus 19530

Solution 2:[2]

Have you checked where your milvus external IP is?

Follow the instructions by the documentation you should use kubectl get services to check which external IP is allocated for the milvus.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Lea
Solution 2 Ji Bin