简体   繁体   中英

What IP Address should I point to in my containerized Python application that is deployed on a Kubernetes cluster?

So I currently have a database server that is up and running. I have it running on 0.0.0.0:8080. I have another python file making requests to that IP address, but when I run it in a container I have this python file point to the container's IP address, but when I have it on a kubernetes cluster I have it now point to the IP address of the kubernetes pod.

The pod IP address constantly changes, so how do I solve this approach?

Define a Service for that database:

https://kubernetes.io/docs/concepts/services-networking/service/

This will expose the database with a fixed DNS name. Then from your python app, use the service name to access your database. The service will direct the traffic to the correct IP.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM