I recently started working on a code base that uses fabric8 to manage containers, pods, services, etc. in kubernetes.
After creating a service for a given pod, I need to inform our end users of the external IP via which they can access said service.
From the command line (kubectl), I would do a describe, and get output like this
kubectl describe service spark-master
Name: spark-master
Namespace: 5683616f16426028459a535c
Labels: group=krylov-dev,name=spark-master
Selector: name=spark-master
Type: LoadBalancer
IP: 10.0.0.103
Port: 7077 7077/TCP
NodePort: 7077 31988/TCP
Endpoints: 172.17.0.2:7077
Port: 7070 7070/TCP
NodePort: 7070 32539/TCP
Endpoints: 172.17.0.2:7070 <<- this is what i want!
Session Affinity: None
No events.I used wireshark to trace the REST API calls that were being made when the above command runs, and it seems the raw Kubernetes REST API accesses the above info via a URL like this
GET /api/v1/namespaces/my_namespace_whatever/endpoints/spark-master So, I could theoretically get the info I want via the raw Kubernetes REST API. But since we are using fabric8, I would prefer to stick to that if there is any way to accomplish this with their API.
I see that there is class that carries info about endpoints in fabric8
( io.fabric8.kubernetes.api.model.Endpoints), but I searched and could find no documentation on how to query a service for its Endpoints information.
Also, when using the fabric8 API to watch for events we have tried looking at service.getStatus.getLoadBalancer.getIngress() (whenever we get a an event associated with our service), but this is always empty ;^(
would be most grateful for any tips or guidance.... -chris
The Fabric8 client has the following API call:
client.endpoints().get();
This would give you the list of all end points. Now there are ways in which you can limit the list that you receive to a particular namespace/labels using:
client.endpoints().inNamespace("5683616f16426028459a535c").withLabel("name", "spark-master").list();