I have a headless service in my cluster:
apiVersion: v1
kind: Service
metadata:
namespace: my-namespace
name: my-headless-service
spec:
clusterIP: None # <- Headless service
selector:
service: my-app
ports:
- port: 52323
targetPort: 52323
However I don't quite get how I'm supposed to extract the endpoints the headless service defines. I can see them in OpenLens:
How can I get these endpoints from my C# application that's running in the cluster?
I have a headless service in my cluster:
apiVersion: v1
kind: Service
metadata:
namespace: my-namespace
name: my-headless-service
spec:
clusterIP: None # <- Headless service
selector:
service: my-app
ports:
- port: 52323
targetPort: 52323
However I don't quite get how I'm supposed to extract the endpoints the headless service defines. I can see them in OpenLens:
How can I get these endpoints from my C# application that's running in the cluster?
Share Improve this question edited Mar 26 at 16:35 Sal asked Mar 25 at 13:05 SalSal 5,9646 gold badges31 silver badges60 bronze badges1 Answer
Reset to default 0To quote the Kubernetes documentation:
headless Services report the endpoint IP addresses of the individual pods via internal DNS records, served through the cluster's DNS service.
So you can perform a DNS lookup on your headless service's host name to resolve those ip's:
var ips = Dns.GetHostEntry("my-headless-service.my-namespace").AddressList;
This won't return the ports however. Not quite sure how to get those
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744194217a4562575.html
评论列表(0条)