本文整理汇总了Java中io.fabric8.kubernetes.api.model.ServiceList类的典型用法代码示例。如果您正苦于以下问题:Java ServiceList类的具体用法?Java ServiceList怎么用?Java ServiceList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServiceList类属于io.fabric8.kubernetes.api.model包,在下文中一共展示了ServiceList类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onRequest
import io.fabric8.kubernetes.api.model.ServiceList; //导入依赖的package包/类
@Override
public SpeechletResponse onRequest(IntentRequest request, Session session) throws SpeechletException {
IntentContext<BaseOperation<Service, ServiceList, ?, ?>> ctx = createContext(request.getIntent(), session);
String namespace = ctx.getVariable(Variable.Namespace, getKubernetesClient().getNamespace());
LOGGER.info("Listing all services for namespace:" + namespace);
try {
List<String> services = list(ctx)
.getItems()
.stream()
.map(d -> d.getMetadata().getName()).collect(Collectors.toList());
if (services.isEmpty()) {
return newResponse("No services found in namespace " + namespace);
} else {
return newResponse("The available services in namespace " + namespace + " are: " + join(services, ","));
}
} catch (KubernetesClientException e) {
return newFailureNotice(e.getStatus().getMessage());
}
}
开发者ID:fabric8io,项目名称:kubernetes-alexa,代码行数:22,代码来源:GetServices.java
示例2: printServices
import io.fabric8.kubernetes.api.model.ServiceList; //导入依赖的package包/类
private void printServices(ServiceList services, PrintStream out) {
TablePrinter table = new TablePrinter();
table.columns("id", "labels", "selector", "port");
List<Service> items = services.getItems();
if (items == null) {
items = Collections.EMPTY_LIST;
}
Filter<Service> filter = KubernetesHelper.createServiceFilter(filterText.getValue());
for (Service service : items) {
if (filter.matches(service)) {
String labels = KubernetesHelper.toLabelsString(service.getMetadata().getLabels());
String selector = KubernetesHelper.toLabelsString(getSelector(service));
Set<Integer> ports = getPorts(service);
List<Integer> portList = new ArrayList<>(ports);
String portText;
if (portList.size() == 1) {
portText = portList.get(0).toString();
} else {
portText = Strings.join(portList, ", ");
}
table.row(KubernetesHelper.getName(service), labels, selector, portText);
}
}
table.print();
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:27,代码来源:ServicesList.java
示例3: initializeUI
import io.fabric8.kubernetes.api.model.ServiceList; //导入依赖的package包/类
@Override
public void initializeUI(UIBuilder builder) throws Exception {
super.initializeUI(builder);
// populate autocompletion options
serviceId.setCompleter(new UICompleter<String>() {
@Override
public Iterable<String> getCompletionProposals(UIContext context, InputComponent<?, String> input, String value) {
List<String> list = new ArrayList<String>();
ServiceList services = getKubernetes().services().inNamespace(getNamespace()).list();
if (services != null) {
List<Service> items = services.getItems();
if (items != null) {
for (Service item : items) {
String id = KubernetesHelper.getName(item);
list.add(id);
}
}
}
Collections.sort(list);
return list;
}
});
builder.add(serviceId);
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:27,代码来源:ServiceDelete.java
示例4: buildAppStatus
import io.fabric8.kubernetes.api.model.ServiceList; //导入依赖的package包/类
protected AppStatus buildAppStatus(String id, PodList podList, ServiceList services) {
AppStatus.Builder statusBuilder = AppStatus.of(id);
Service service = null;
if (podList != null && podList.getItems() != null) {
for (Pod pod : podList.getItems()) {
for (Service svc : services.getItems()) {
if (svc.getMetadata().getName()
.equals(pod.getMetadata().getLabels().get(SPRING_DEPLOYMENT_KEY))) {
service = svc;
break;
}
}
statusBuilder.with(new KubernetesAppInstanceStatus(pod, service, properties));
}
}
return statusBuilder.build();
}
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-kubernetes,代码行数:18,代码来源:AbstractKubernetesDeployer.java
示例5: resolveServiceByLabelOnly
import io.fabric8.kubernetes.api.model.ServiceList; //导入依赖的package包/类
private static void resolveServiceByLabelOnly(
Object bean,
JsonObject env,
KubernetesClient client,
Field serviceNameField,
boolean withLabel,
boolean withLabels)
throws KubernetesClientException {
final Map<String, String> labels =
getLabelsFromAnnotation(env, serviceNameField, withLabel, withLabels);
final ServiceList serviceListResult = getServicesByLabel(labels, client);
Optional.ofNullable(serviceListResult)
.ifPresent(
list -> {
if (!list.getItems().isEmpty() && list.getItems().size() == 1) {
final Service serviceEntry = list.getItems().get(0);
resolveHostAndSetValue(bean, env, serviceNameField, serviceEntry);
} else if (!list.getItems().isEmpty() && list.getItems().size() > 1) {
handleNonUniqueLabelsError(labels);
}
});
}
开发者ID:amoAHCP,项目名称:vxms,代码行数:23,代码来源:KubeDiscovery.java
示例6: getEndpoints
import io.fabric8.kubernetes.api.model.ServiceList; //导入依赖的package包/类
@Override
public EndpointsList getEndpoints(@QueryParam("namespace") String namespace) {
EndpointsList answer = new EndpointsList();
List<Endpoints> list = new ArrayList<>();
answer.setItems(list);
ServiceList services = getServices(namespace);
if (services != null) {
List<Pod> pods = getPods(namespace).getItems();
List<Service> items = notNullList(services.getItems());
for (Service service : items) {
Endpoints endpoints = createEndpointsForService(service, pods);
if (endpoints != null) {
list.add(endpoints);
}
}
}
return answer;
}
开发者ID:fabric8io,项目名称:jube,代码行数:20,代码来源:ApiMasterService.java
示例7: doList
import io.fabric8.kubernetes.api.model.ServiceList; //导入依赖的package包/类
protected void doList(Exchange exchange, String operation) throws Exception {
ServiceList servicesList = null;
String namespaceName = exchange.getIn().getHeader(
KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
if (!ObjectHelper.isEmpty(namespaceName)) {
servicesList = getEndpoint().getKubernetesClient().services()
.inNamespace(namespaceName).list();
} else {
servicesList = getEndpoint().getKubernetesClient().services()
.list();
}
exchange.getOut().setBody(servicesList.getItems());
}
开发者ID:HydAu,项目名称:Camel,代码行数:14,代码来源:KubernetesServicesProducer.java
示例8: getServicesByLabel
import io.fabric8.kubernetes.api.model.ServiceList; //导入依赖的package包/类
private static ServiceList getServicesByLabel(Map<String, String> labels, KubernetesClient client)
throws KubernetesClientException {
Objects.requireNonNull(client, "no client available");
final MixedOperation<Service, ServiceList, DoneableService, Resource<Service, DoneableService>>
services = client.services();
final FilterWatchListDeletable<Service, ServiceList, Boolean, Watch, Watcher<Service>>
listable = createLabelFilterQuery(labels, services);
return listable.list();
}
开发者ID:amoAHCP,项目名称:vxms,代码行数:10,代码来源:KubeDiscovery.java
示例9: createLabelFilterQuery
import io.fabric8.kubernetes.api.model.ServiceList; //导入依赖的package包/类
private static FilterWatchListDeletable<Service, ServiceList, Boolean, Watch, Watcher<Service>>
createLabelFilterQuery(
Map<String, String> labels,
MixedOperation<Service, ServiceList, DoneableService, Resource<Service, DoneableService>>
services) {
FilterWatchListDeletable<Service, ServiceList, Boolean, Watch, Watcher<Service>> listable =
null;
for (Entry<String, String> entry : labels.entrySet()) {
listable =
listable == null
? services.withLabel(entry.getKey(), entry.getValue())
: listable.withLabel(entry.getKey(), entry.getValue());
}
return listable;
}
开发者ID:amoAHCP,项目名称:vxms,代码行数:16,代码来源:KubeDiscovery.java
示例10: findServiceEntry
import io.fabric8.kubernetes.api.model.ServiceList; //导入依赖的package包/类
private static Optional<Service> findServiceEntry(
JsonObject env, KubernetesClient client, String serviceName) {
Objects.requireNonNull(client, "no client available");
final String resolvedServiceName = resolveProperty(env, serviceName);
return Optional.ofNullable(client.services().inNamespace(client.getNamespace()).list())
.orElse(new ServiceList())
.getItems()
.stream()
.filter(item -> item.getMetadata().getName().equalsIgnoreCase(resolvedServiceName))
.findFirst();
}
开发者ID:amoAHCP,项目名称:vxms,代码行数:12,代码来源:KubeDiscovery.java
示例11: findServices
import io.fabric8.kubernetes.api.model.ServiceList; //导入依赖的package包/类
@Test
public void findServices() {
final ObjectMeta build = new ObjectMetaBuilder().addToLabels("test", "test").build();
final ServiceSpec spec = new ServiceSpecBuilder().addNewPort().and()
.withClusterIP("192.168.1.1").build();
final Service service = new ServiceBuilder().withMetadata(build).withSpec(spec).build();
server.expect().withPath("/api/v1/namespaces/default/services").andReturn(200, new ServiceListBuilder().addToItems().addToItems(service).build()).once();
KubernetesClient client = this.client;
final ServiceList list = client.services().inNamespace("default").list();
assertNotNull(list);
assertEquals("test", list.getItems().get(0).getMetadata().getLabels().get("test"));
System.out.println(list.getItems().get(0).getSpec().getClusterIP());
}
开发者ID:amoAHCP,项目名称:vxms,代码行数:14,代码来源:KubernetesMockTest.java
示例12: newOperation
import io.fabric8.kubernetes.api.model.ServiceList; //导入依赖的package包/类
@Override
public BaseOperation<Service, ServiceList, ?, ?> newOperation() {
return (BaseOperation<Service, ServiceList, ?, ?>) getKubernetesClient().services();
}
开发者ID:fabric8io,项目名称:kubernetes-alexa,代码行数:5,代码来源:GetServices.java
示例13: execute
import io.fabric8.kubernetes.api.model.ServiceList; //导入依赖的package包/类
@Override
public Result execute(UIExecutionContext uiExecutionContext) throws Exception {
ServiceList services = getKubernetes().services().list();
printServices(services, System.out);
return null;
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:7,代码来源:ServicesList.java
示例14: getServices
import io.fabric8.kubernetes.api.model.ServiceList; //导入依赖的package包/类
@Override
public ServiceList getServices() {
return getServices(namespace);
}
开发者ID:fabric8io,项目名称:jube,代码行数:5,代码来源:LocalKubernetesModel.java
示例15: getServices
import io.fabric8.kubernetes.api.model.ServiceList; //导入依赖的package包/类
@Override
public ServiceList getServices(String namespace) {
return model.getServices(namespace);
}
开发者ID:fabric8io,项目名称:jube,代码行数:5,代码来源:ApiMasterService.java
示例16: getServices
import io.fabric8.kubernetes.api.model.ServiceList; //导入依赖的package包/类
@Override
public ServiceList getServices() {
return memoryModel.getServices();
}
开发者ID:fabric8io,项目名称:jube,代码行数:5,代码来源:ApiMasterKubernetesModel.java
示例17: getServices
import io.fabric8.kubernetes.api.model.ServiceList; //导入依赖的package包/类
ServiceList getServices();
开发者ID:fabric8io,项目名称:jube,代码行数:2,代码来源:KubernetesModel.java
注:本文中的io.fabric8.kubernetes.api.model.ServiceList类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论