Try this exercise. Fill in the missing part by typing it in.
To use service discovery with Spring Cloud Kubernetes, you can start by creating a new instance of the KubernetesClient
and retrieving the list of __ available in the cluster. Here's an example code snippet:
TEXT/X-JAVA
1KubernetesClient client = new DefaultKubernetesClient();
2ServiceList services = client.services().list();
3
4for (Service service : services.getItems()) {
5 System.out.println(service.getMetadata().getName());
6}
In this example, we create a new instance of the KubernetesClient
using the DefaultKubernetesClient
class. We then use the client to retrieve the list of services using the services().list()
method. Finally, we iterate over the services and print their names.
Write the missing line below.