use of io.fabric8.kubernetes.api.model.IntOrStringBuilder in project devspaces-images by redhat-developer.
the class AsyncStorageProvisioner method createStorageServiceIfNotExist.
/**
* Create service for serving rsync connection
*/
private void createStorageServiceIfNotExist(KubernetesClient k8sClient, String namespace, String userId) {
ServiceResource<Service> serviceResource = k8sClient.services().inNamespace(namespace).withName(ASYNC_STORAGE);
if (serviceResource.get() != null) {
// service already exist
return;
}
ObjectMeta meta = new ObjectMeta();
meta.setName(ASYNC_STORAGE);
meta.setNamespace(namespace);
meta.setLabels(of(CHE_USER_ID_LABEL, userId));
IntOrString targetPort = new IntOrStringBuilder().withIntVal(SERVICE_PORT).withStrVal(valueOf(SERVICE_PORT)).build();
ServicePort port = new ServicePortBuilder().withName("rsync-port").withProtocol("TCP").withPort(SERVICE_PORT).withTargetPort(targetPort).build();
ServiceSpec spec = new ServiceSpec();
spec.setPorts(singletonList(port));
spec.setSelector(of(CHE_DEPLOYMENT_NAME_LABEL, ASYNC_STORAGE));
ServerServiceBuilder serviceBuilder = new ServerServiceBuilder();
Service service = serviceBuilder.withPorts(singletonList(port)).withSelectorEntry(CHE_DEPLOYMENT_NAME_LABEL, ASYNC_STORAGE).withName(ASYNC_STORAGE).build();
k8sClient.services().inNamespace(namespace).create(service);
}
use of io.fabric8.kubernetes.api.model.IntOrStringBuilder in project che-server by eclipse-che.
the class AsyncStorageProvisioner method createStorageServiceIfNotExist.
/**
* Create service for serving rsync connection
*/
private void createStorageServiceIfNotExist(KubernetesClient k8sClient, String namespace, String userId) {
ServiceResource<Service> serviceResource = k8sClient.services().inNamespace(namespace).withName(ASYNC_STORAGE);
if (serviceResource.get() != null) {
// service already exist
return;
}
ObjectMeta meta = new ObjectMeta();
meta.setName(ASYNC_STORAGE);
meta.setNamespace(namespace);
meta.setLabels(of(CHE_USER_ID_LABEL, userId));
IntOrString targetPort = new IntOrStringBuilder().withIntVal(SERVICE_PORT).withStrVal(valueOf(SERVICE_PORT)).build();
ServicePort port = new ServicePortBuilder().withName("rsync-port").withProtocol("TCP").withPort(SERVICE_PORT).withTargetPort(targetPort).build();
ServiceSpec spec = new ServiceSpec();
spec.setPorts(singletonList(port));
spec.setSelector(of(CHE_DEPLOYMENT_NAME_LABEL, ASYNC_STORAGE));
ServerServiceBuilder serviceBuilder = new ServerServiceBuilder();
Service service = serviceBuilder.withPorts(singletonList(port)).withSelectorEntry(CHE_DEPLOYMENT_NAME_LABEL, ASYNC_STORAGE).withName(ASYNC_STORAGE).build();
k8sClient.services().inNamespace(namespace).create(service);
}
Aggregations