如何连接部署在 Kubernetes 上的数据库
How can I connect with a database deployed at Kubernetes
所以,我在 AWS Kubernetes Cluster(EKS)
部署了 Influx
数据库。
我想要的是能够使用我的 python
项目连接数据库并能够查询数据库。
我可以看到我可以使用 Influx API ,就像这些 examples 一样,但是我无法配置数据库,因为它没有部署在本地。
既然数据库已部署在 EKS 中,我应该如何配置该数据库?
我做了一些研究,但到目前为止没有任何帮助。
我是 Kubernetes 和 Influx 的新手,所以这可能是一个简单的问题,无论如何任何建议或提示将不胜感激。
将您的 Influx 服务类型更改为 LoadBalancer
类型将为您的 Influx 实例提供一个外部 IP,然后您可以使用 Python 代码中的 IP 连接到 Influx。
你可以看看here and here.
您可以尝试 port-forwarding 在本地访问您的数据库。
试试这个
kubectl port-forward pod-name -n namespace localport:podport
pod-name -- your influxdb pod name
localport -- the port that you want to use locally(try 8086).
podport -- the port which is exposed by pod (i believe this is 8086).
现在尝试通过 localhost:8086
在本地访问数据库
这是临时解决方案。您需要创建服务或路由才能在集群外使用数据库。
所以,我在 AWS Kubernetes Cluster(EKS)
部署了 Influx
数据库。
我想要的是能够使用我的 python
项目连接数据库并能够查询数据库。
我可以看到我可以使用 Influx API ,就像这些 examples 一样,但是我无法配置数据库,因为它没有部署在本地。
既然数据库已部署在 EKS 中,我应该如何配置该数据库?
我做了一些研究,但到目前为止没有任何帮助。
我是 Kubernetes 和 Influx 的新手,所以这可能是一个简单的问题,无论如何任何建议或提示将不胜感激。
将您的 Influx 服务类型更改为 LoadBalancer
类型将为您的 Influx 实例提供一个外部 IP,然后您可以使用 Python 代码中的 IP 连接到 Influx。
你可以看看here and here.
您可以尝试 port-forwarding 在本地访问您的数据库。 试试这个
kubectl port-forward pod-name -n namespace localport:podport
pod-name -- your influxdb pod name
localport -- the port that you want to use locally(try 8086).
podport -- the port which is exposed by pod (i believe this is 8086).
现在尝试通过 localhost:8086
在本地访问数据库这是临时解决方案。您需要创建服务或路由才能在集群外使用数据库。