io.fabric8.kubernetes.api.model.DoneableService Java Examples
The following examples show how to use
io.fabric8.kubernetes.api.model.DoneableService.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PatchService.java From jkube with Eclipse Public License 2.0 | 6 votes |
private static EntityPatcher<Service> servicePatcher() { return (KubernetesClient client, String namespace, Service newObj, Service oldObj) -> { if (UserConfigurationCompare.configEqual(newObj, oldObj)) { return oldObj; } DoneableService entity = client.services() .inNamespace(namespace) .withName(newObj.getMetadata().getName()) .edit(); if (!UserConfigurationCompare.configEqual(newObj.getMetadata(), oldObj.getMetadata())) { entity.withMetadata(newObj.getMetadata()); } if(!UserConfigurationCompare.configEqual(newObj.getSpec(), oldObj.getSpec())) { entity.withSpec(newObj.getSpec()); } return entity.done(); }; }
Example #2
Source File: ServiceOperator.java From strimzi-kafka-operator with Apache License 2.0 | 6 votes |
/** * Checks if the Service already has assigned node ports. * * @param namespace The namespace. * @param name The route name. * @return Whether the Service already has assigned node ports. */ public boolean isNodePortReady(String namespace, String name) { ServiceResource<Service, DoneableService> resourceOp = operation().inNamespace(namespace).withName(name); Service resource = resourceOp.get(); if (resource != null && resource.getSpec() != null && resource.getSpec().getPorts() != null) { boolean ready = true; for (ServicePort port : resource.getSpec().getPorts()) { if (port.getNodePort() == null) { ready = false; } } return ready; } return false; }
Example #3
Source File: SpringBootWatcher.java From jkube with Eclipse Public License 2.0 | 5 votes |
private String getServiceExposeUrl(KubernetesClient kubernetes, Set<HasMetadata> resources) throws InterruptedException { long serviceUrlWaitTimeSeconds = Configs.asInt(getConfig(Config.serviceUrlWaitTimeSeconds)); for (HasMetadata entity : resources) { if (entity instanceof Service) { Service service = (Service) entity; String name = KubernetesHelper.getName(service); Resource<Service, DoneableService> serviceResource = kubernetes.services() .inNamespace(getContext().getJKubeServiceHub().getClusterAccess().getNamespace()) .withName(name); String url = null; // lets wait a little while until there is a service URL in case the exposecontroller is running slow for (int i = 0; i < serviceUrlWaitTimeSeconds; i++) { if (i > 0) { Thread.sleep(1000); } Service s = serviceResource.get(); if (s != null) { url = KubernetesHelper.getOrCreateAnnotations(s).get(JKubeAnnotations.SERVICE_EXPOSE_URL.value()); if (StringUtils.isNotBlank(url)) { break; } } if (!isExposeService(service)) { break; } } // lets not wait for other services serviceUrlWaitTimeSeconds = 1; if (StringUtils.isNotBlank(url) && url.startsWith("http")) { return url; } } } log.info("No exposed service found for connecting the dev tools"); return null; }
Example #4
Source File: KubeDiscovery.java From vxms with Apache License 2.0 | 5 votes |
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; }
Example #5
Source File: KubeDiscovery.java From vxms with Apache License 2.0 | 5 votes |
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(); }
Example #6
Source File: KubernetesResource.java From strimzi-kafka-operator with Apache License 2.0 | 5 votes |
public static DoneableService createServiceResource(String appName, int port, String clientNamespace, String transportProtocol) { Service service = getSystemtestsServiceResource(appName, port, clientNamespace, transportProtocol).build(); LOGGER.info("Creating Service {} in namespace {}", service.getMetadata().getName(), clientNamespace); ResourceManager.kubeClient().createService(service); deleteLater(service); return new DoneableService(service); }
Example #7
Source File: ServiceMockBuilder.java From strimzi-kafka-operator with Apache License 2.0 | 5 votes |
/** Override Service creation to also create Endpoints */ @Override protected void mockCreate(String resourceName, ServiceResource<Service, DoneableService> resource) { when(resource.create(any())).thenAnswer(i -> { Service argument = i.getArgument(0); db.put(resourceName, copyResource(argument)); LOGGER.debug("create {} (and endpoint) {} ", resourceType, resourceName); endpointsDb.put(resourceName, new Endpoints()); return argument; }); }
Example #8
Source File: ServiceOperator.java From strimzi-kafka-operator with Apache License 2.0 | 5 votes |
/** * Checks if the Service already has assigned ingress address. * * @param namespace The namespace. * @param name The route name. * @return Whether the Service already has assigned ingress address. */ public boolean isIngressAddressReady(String namespace, String name) { ServiceResource<Service, DoneableService> resourceOp = operation().inNamespace(namespace).withName(name); Service resource = resourceOp.get(); if (resource != null && resource.getStatus() != null && resource.getStatus().getLoadBalancer() != null && resource.getStatus().getLoadBalancer().getIngress() != null && resource.getStatus().getLoadBalancer().getIngress().size() > 0) { if (resource.getStatus().getLoadBalancer().getIngress().get(0).getHostname() != null || resource.getStatus().getLoadBalancer().getIngress().get(0).getIp() != null) { return true; } } return false; }
Example #9
Source File: ServiceMockBuilder.java From strimzi-kafka-operator with Apache License 2.0 | 4 votes |
public ServiceMockBuilder(Map<String, Service> svcDb, Map<String, Endpoints> endpointsDb) { super(Service.class, ServiceList.class, DoneableService.class, castClass(ServiceResource.class), svcDb); this.endpointsDb = endpointsDb; }
Example #10
Source File: ServiceOperator.java From strimzi-kafka-operator with Apache License 2.0 | 4 votes |
@Override protected MixedOperation<Service, ServiceList, DoneableService, ServiceResource<Service, DoneableService>> operation() { return client.services(); }
Example #11
Source File: KubernetesResource.java From strimzi-kafka-operator with Apache License 2.0 | 4 votes |
public static DoneableService createServiceResource(Service service, String clientNamespace) { LOGGER.info("Creating Service {} in namespace {}", service.getMetadata().getName(), clientNamespace); ResourceManager.kubeClient().createService(service); deleteLater(service); return new DoneableService(service); }
Example #12
Source File: TeiidOpenShiftClient.java From syndesis with Apache License 2.0 | 4 votes |
private Service createService(OpenShiftClient client, String namespace, String openShiftName) { String serviceName = openShiftName; debug(openShiftName, "Creating the Service for VDB "+openShiftName); Service service = client.services().inNamespace(namespace).withName(serviceName).get(); if (service == null) { //TODO: this does not check if odata is enabled TreeMap<String, String> labels = new TreeMap<String, String>(); labels.put("application", openShiftName); TreeMap<String, String> annotations = new TreeMap<String, String>(); annotations.put(DESCRIPTION_ANNOTATION_LABEL, SERVICE_DESCRIPTION); if (this.config.isExposeVia3scale()) { labels.put("discovery.3scale.net", "true"); annotations.put("discovery.3scale.net/scheme", "http"); annotations.put("discovery.3scale.net/port", Integer.toString(ProtocolType.ODATA.getTargetPort())); annotations.put("discovery.3scale.net/description-path", "/openapi.json"); } SpecNested<DoneableService> donable = client.services().inNamespace(namespace).createNew() .withNewMetadata() .withName(serviceName) .addToLabels(labels) .addToAnnotations(annotations) .endMetadata() .withNewSpec() .withSessionAffinity("ClientIP") .addToSelector("application", openShiftName); for (ProtocolType type : ProtocolType.values()) { donable.addNewPort() .withName(type.id()) .withPort(type.getTargetPort()) .withNewTargetPort() .withStrVal(type.id()) .endTargetPort() .endPort(); } service = donable.endSpec().done(); } return service; }
Example #13
Source File: ServicesController.java From rabbitmq-operator with Apache License 2.0 | 4 votes |
@Override protected MixedOperation<Service, ServiceList, DoneableService, ServiceResource<Service, DoneableService>> operation() { return getClient().services(); }
Example #14
Source File: ServiceOperationsImpl.java From kubernetes-client with Apache License 2.0 | 4 votes |
public ServiceOperationsImpl(OperationContext context) { super(context.withPlural("services")); this.type = Service.class; this.listType = ServiceList.class; this.doneableType = DoneableService.class; }
Example #15
Source File: AutoAdaptableKubernetesClient.java From kubernetes-client with Apache License 2.0 | 4 votes |
@Override public MixedOperation<Service, ServiceList, DoneableService, ServiceResource<Service, DoneableService>> services() { return delegate.services(); }
Example #16
Source File: DefaultKubernetesClient.java From kubernetes-client with Apache License 2.0 | 4 votes |
@Override public MixedOperation<Service, ServiceList, DoneableService, ServiceResource<Service, DoneableService>> services() { return new ServiceOperationsImpl(httpClient, getConfiguration()); }
Example #17
Source File: ManagedKubernetesClient.java From kubernetes-client with Apache License 2.0 | 4 votes |
public MixedOperation<io.fabric8.kubernetes.api.model.Service, ServiceList, DoneableService, ServiceResource<io.fabric8.kubernetes.api.model.Service, DoneableService>> services() { return delegate.services(); }
Example #18
Source File: DefaultOpenShiftClient.java From kubernetes-client with Apache License 2.0 | 4 votes |
@Override public MixedOperation<Service, ServiceList, DoneableService, ServiceResource<Service, DoneableService>> services() { return delegate.services(); }
Example #19
Source File: KubernetesClient.java From kubernetes-client with Apache License 2.0 | 2 votes |
/** * API entrypoint for Service related operations. Service (core/v1) * * @return MixedOperation object for Service related operations. */ MixedOperation<Service, ServiceList, DoneableService, ServiceResource<Service, DoneableService>> services();