本文整理汇总了Java中io.fabric8.kubernetes.api.model.Service类的典型用法代码示例。如果您正苦于以下问题:Java Service类的具体用法?Java Service怎么用?Java Service使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Service类属于io.fabric8.kubernetes.api.model包,在下文中一共展示了Service类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onRequest
import io.fabric8.kubernetes.api.model.Service; //导入依赖的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: createService
import io.fabric8.kubernetes.api.model.Service; //导入依赖的package包/类
protected Service createService(final String namespace,
final String serviceName,
Map<String, String> labels) {
labels = normalizeLabels(labels);
final Service service = new Service();
final ObjectMeta metadata = new ObjectMeta();
metadata.setNamespace(normalizeNamespace(namespace));
metadata.setName(normalizeServiceName(serviceName));
metadata.setLabels(labels);
service.setMetadata(metadata);
service.setSpec(this.createServiceSpec(labels));
return service;
}
开发者ID:microbean,项目名称:microbean-helm,代码行数:18,代码来源:TillerInstaller.java
示例3: printServices
import io.fabric8.kubernetes.api.model.Service; //导入依赖的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
示例4: initializeUI
import io.fabric8.kubernetes.api.model.Service; //导入依赖的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
示例5: buildAppStatus
import io.fabric8.kubernetes.api.model.Service; //导入依赖的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
示例6: testExists
import io.fabric8.kubernetes.api.model.Service; //导入依赖的package包/类
public void testExists() throws ResourceException {
// Check that the service doesn't exist already
Service service = KubernetesClientUtil.retrieveService(kubernetesClient, serviceResourceV1);
assertNull(service);
// Test exists method
assertFalse(serviceResourceV1.exists());
// Create service
serviceResourceV1.create();
// Check that the service exists
service = KubernetesClientUtil.retrieveService(kubernetesClient, serviceResourceV1);
assertNotNull(service);
// Test exists method
assertTrue(serviceResourceV1.exists());
}
开发者ID:qaware,项目名称:gradle-cloud-deployer,代码行数:20,代码来源:ServiceResourceIntegrationTest.java
示例7: testCreate
import io.fabric8.kubernetes.api.model.Service; //导入依赖的package包/类
public void testCreate() throws ResourceException {
// Check that the service doesn't exist already
Service service = KubernetesClientUtil.retrieveService(kubernetesClient, serviceResourceV1);
assertNull(service);
// Create service
serviceResourceV1.create();
// Check that the service exists
service = KubernetesClientUtil.retrieveService(kubernetesClient, serviceResourceV1);
assertNotNull(service);
// Compare services
assertEquals(service.getMetadata().getName(), serviceResourceV1.getId());
assertEquals(service.getApiVersion(), serviceResourceV1.getResourceConfig().getResourceVersion());
assertEquals(service.getKind(), serviceResourceV1.getResourceConfig().getResourceType());
}
开发者ID:qaware,项目名称:gradle-cloud-deployer,代码行数:19,代码来源:ServiceResourceIntegrationTest.java
示例8: testDelete
import io.fabric8.kubernetes.api.model.Service; //导入依赖的package包/类
public void testDelete() throws ResourceException {
// Create service
serviceResourceV1.create();
// Check that the service exists
Service service = KubernetesClientUtil.retrieveService(kubernetesClient, serviceResourceV1);
assertNotNull(service);
// Delete service
serviceResourceV1.delete();
// Check that service doesn't exist anymore
service = KubernetesClientUtil.retrieveService(kubernetesClient, serviceResourceV1);
assertNull(service);
}
开发者ID:qaware,项目名称:gradle-cloud-deployer,代码行数:17,代码来源:ServiceResourceIntegrationTest.java
示例9: serviceToEndpoint
import io.fabric8.kubernetes.api.model.Service; //导入依赖的package包/类
private Endpoint serviceToEndpoint(Service service) {
String secretName = service.getMetadata().getAnnotations().get(AnnotationKeys.CERT_SECRET_NAME);
String serviceName = service.getMetadata().getAnnotations().get(AnnotationKeys.SERVICE_NAME);
Endpoint.Builder builder = new Endpoint.Builder()
.setName(service.getMetadata().getName())
.setService(serviceName);
if (secretName != null) {
builder.setCertProvider(new SecretCertProvider(secretName));
}
if (service.getSpec().getPorts().size() > 0) {
Integer nodePort = service.getSpec().getPorts().get(0).getNodePort();
Integer port = service.getSpec().getPorts().get(0).getPort();
if (nodePort != null) {
builder.setPort(nodePort);
} else if (port != null) {
builder.setPort(port);
}
}
return builder.build();
}
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:25,代码来源:Controller.java
示例10: doGetService
import io.fabric8.kubernetes.api.model.Service; //导入依赖的package包/类
protected void doGetService(Exchange exchange, String operation)
throws Exception {
Service service = null;
String serviceName = exchange.getIn().getHeader(
KubernetesConstants.KUBERNETES_SERVICE_NAME, String.class);
String namespaceName = exchange.getIn().getHeader(
KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
if (ObjectHelper.isEmpty(serviceName)) {
LOG.error("Get a specific service require specify a service name");
throw new IllegalArgumentException(
"Get a specific service require specify a service name");
}
if (ObjectHelper.isEmpty(namespaceName)) {
LOG.error("Get a specific service require specify a namespace name");
throw new IllegalArgumentException(
"Get a specific service require specify a namespace name");
}
service = getEndpoint().getKubernetesClient().services()
.inNamespace(namespaceName).withName(serviceName).get();
exchange.getOut().setBody(service);
}
开发者ID:HydAu,项目名称:Camel,代码行数:22,代码来源:KubernetesServicesProducer.java
示例11: listTest
import io.fabric8.kubernetes.api.model.Service; //导入依赖的package包/类
@Test
public void listTest() throws Exception {
if (ObjectHelper.isEmpty(authToken)) {
return;
}
List<Service> result = template.requestBody("direct:list", "",
List.class);
boolean fabric8Exists = false;
Iterator<Service> it = result.iterator();
while (it.hasNext()) {
Service service = it.next();
if ("fabric8".equalsIgnoreCase(service.getMetadata().getName())) {
fabric8Exists = true;
}
}
assertTrue(fabric8Exists);
}
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:KubernetesServicesProducerTest.java
示例12: getServiceTest
import io.fabric8.kubernetes.api.model.Service; //导入依赖的package包/类
@Test
public void getServiceTest() throws Exception {
if (ObjectHelper.isEmpty(authToken)) {
return;
}
Exchange ex = template.request("direct:getServices", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(
KubernetesConstants.KUBERNETES_NAMESPACE_NAME,
"default");
exchange.getIn().setHeader(
KubernetesConstants.KUBERNETES_SERVICE_NAME,
"elasticsearch");
}
});
Service result = ex.getOut().getBody(Service.class);
assertNull(result);
}
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:KubernetesServicesProducerTest.java
示例13: resolveServiceByLabelOnly
import io.fabric8.kubernetes.api.model.Service; //导入依赖的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
示例14: initService
import io.fabric8.kubernetes.api.model.Service; //导入依赖的package包/类
public void initService() {
final ObjectMeta buildmyTestService = new ObjectMetaBuilder().addToLabels("test", "test").withName("myTestService").build();
final ServicePort portmyTestService = new ServicePortBuilder().withPort(8080).withProtocol("http").build();
final ServiceSpec specmyTestService = new ServiceSpecBuilder().addNewPort().and()
.withClusterIP("192.168.1.1").withPorts(portmyTestService).build();
final ObjectMeta buildmyTestService2 = new ObjectMetaBuilder().addToLabels("test", "test2").withName("myTestService2").build();
final ServicePort portmyTestService2 = new ServicePortBuilder().withPort(9080).withProtocol("http").build();
final ServiceSpec specmyTestService2 = new ServiceSpecBuilder().addNewPort().and()
.withClusterIP("192.168.1.2").withPorts(portmyTestService2).build();
final Service servicemyTestService = new ServiceBuilder().withMetadata(buildmyTestService).withSpec(specmyTestService).build();
final Service servicemyTestService2 = new ServiceBuilder().withMetadata(buildmyTestService2).withSpec(specmyTestService2).build();
server.expect().withPath("/api/v1/namespaces/default/services").andReturn(200, new ServiceListBuilder().addToItems(servicemyTestService,servicemyTestService2).build()).times(2);
}
开发者ID:amoAHCP,项目名称:vxms,代码行数:17,代码来源:ResolveServicesByNameTest.java
示例15: initService
import io.fabric8.kubernetes.api.model.Service; //导入依赖的package包/类
public void initService() {
final ObjectMeta buildmyTestService = new ObjectMetaBuilder().addToLabels("name", "myTestService").addToLabels("version", "v1").withName("myTestService").build();
final ServicePort portmyTestService = new ServicePortBuilder().withPort(8080).withProtocol("http").build();
final ServiceSpec specmyTestService = new ServiceSpecBuilder().addNewPort().and()
.withClusterIP("192.168.1.1").withPorts(portmyTestService).build();
final ObjectMeta buildmyTestService2 = new ObjectMetaBuilder().addToLabels("name", "myTestService").addToLabels("version", "v2").withName("myTestService2").build();
final ServicePort portmyTestService2 = new ServicePortBuilder().withPort(9080).withProtocol("http").build();
final ServiceSpec specmyTestService2 = new ServiceSpecBuilder().addNewPort().and()
.withClusterIP("192.168.1.2").withPorts(portmyTestService2).build();
final Service servicemyTestService = new ServiceBuilder().withMetadata(buildmyTestService).withSpec(specmyTestService).build();
final Service servicemyTestService2 = new ServiceBuilder().withMetadata(buildmyTestService2).withSpec(specmyTestService2).build();
server.expect().withPath("/api/v1/namespaces/default/services?labelSelector=name%3DmyTestService,version%3Dv1").andReturn(200, new ServiceListBuilder().addToItems(servicemyTestService).build()).times(1);
server.expect().withPath("/api/v1/namespaces/default/services?labelSelector=name%3DmyTestService,version%3Dv2").andReturn(200, new ServiceListBuilder().addToItems(servicemyTestService2).build()).times(1);
}
开发者ID:amoAHCP,项目名称:vxms,代码行数:18,代码来源:ResolveServicesByLabelsConfigAndPortOKOfflineTest.java
示例16: initService
import io.fabric8.kubernetes.api.model.Service; //导入依赖的package包/类
public void initService() {
final ObjectMeta buildmyTestService = new ObjectMetaBuilder().addToLabels("test", "test").withName("myTestService").build();
final ServicePort portmyTestService_1 = new ServicePortBuilder().withName("mainhttp").withPort(8080).withProtocol("http").build();
final ServicePort portmyTestService_2 = new ServicePortBuilder().withName("mytcp").withPort(9090).withProtocol("tcp").build();
final ServiceSpec specmyTestService = new ServiceSpecBuilder().addNewPort().and()
.withClusterIP("192.168.1.1").withPorts(portmyTestService_1,portmyTestService_2).build();
final ObjectMeta buildmyTestService2 = new ObjectMetaBuilder().addToLabels("test", "test2").withName("myTestService2").build();
final ServicePort portmyTestService2_1 = new ServicePortBuilder().withPort(9080).withProtocol("http").build();
final ServicePort portmyTestService2_2 = new ServicePortBuilder().withName("test").withPort(9090).withProtocol("http").build();
final ServiceSpec specmyTestService2 = new ServiceSpecBuilder().addNewPort().and()
.withClusterIP("192.168.1.2").withPorts(portmyTestService2_1,portmyTestService2_2).build();
final Service servicemyTestService = new ServiceBuilder().withMetadata(buildmyTestService).withSpec(specmyTestService).build();
final Service servicemyTestService2 = new ServiceBuilder().withMetadata(buildmyTestService2).withSpec(specmyTestService2).build();
server.expect().withPath("/api/v1/namespaces/default/services").andReturn(200, new ServiceListBuilder().addToItems(servicemyTestService,servicemyTestService2).build()).times(2);
}
开发者ID:amoAHCP,项目名称:vxms,代码行数:19,代码来源:ResolveServicesByLAbelsWithPortNameTest.java
示例17: initService
import io.fabric8.kubernetes.api.model.Service; //导入依赖的package包/类
public void initService() {
final ObjectMeta buildmyTestService = new ObjectMetaBuilder().addToLabels("name", "myTestService").addToLabels("version", "v1").withName("myTestService").build();
final ServicePort portmyTestService = new ServicePortBuilder().withPort(8080).withProtocol("http").build();
final ServiceSpec specmyTestService = new ServiceSpecBuilder().addNewPort().and()
.withClusterIP("192.168.1.1").withPorts(portmyTestService).build();
final ObjectMeta buildmyTestService2 = new ObjectMetaBuilder().addToLabels("name", "myTestService").addToLabels("version", "v2").withName("myTestService2").build();
final ServicePort portmyTestService2 = new ServicePortBuilder().withPort(9080).withProtocol("http").build();
final ServiceSpec specmyTestService2 = new ServiceSpecBuilder().addNewPort().and()
.withClusterIP("192.168.1.2").withPorts(portmyTestService2).build();
final Service servicemyTestService = new ServiceBuilder().withMetadata(buildmyTestService).withSpec(specmyTestService).build();
final Service servicemyTestService2 = new ServiceBuilder().withMetadata(buildmyTestService2).withSpec(specmyTestService2).build();
server.expect().withPath("/api/v1/namespaces/default/services?labelSelector=name%3DmyTestService").andReturn(200, new ServiceListBuilder().addToItems(servicemyTestService,servicemyTestService2).build()).times(2);
}
开发者ID:amoAHCP,项目名称:vxms,代码行数:17,代码来源:ResolveServicesByLabelsTooManyNOKTest.java
示例18: initService
import io.fabric8.kubernetes.api.model.Service; //导入依赖的package包/类
public void initService() {
final ObjectMeta buildmyTestService = new ObjectMetaBuilder().addToLabels("name", "myTestService").addToLabels("version", "v1").withName("myTestService").build();
final ServicePort portmyTestService = new ServicePortBuilder().withPort(8080).withProtocol("http").build();
final ServiceSpec specmyTestService = new ServiceSpecBuilder().addNewPort().and()
.withClusterIP("192.168.1.1").withPorts(portmyTestService).build();
final ObjectMeta buildmyTestService2 = new ObjectMetaBuilder().addToLabels("name", "myTestService").addToLabels("version", "v2").withName("myTestService2").build();
final ServicePort portmyTestService2 = new ServicePortBuilder().withPort(9080).withProtocol("http").build();
final ServiceSpec specmyTestService2 = new ServiceSpecBuilder().addNewPort().and()
.withClusterIP("192.168.1.2").withPorts(portmyTestService2).build();
final Service servicemyTestService = new ServiceBuilder().withMetadata(buildmyTestService).withSpec(specmyTestService).build();
final Service servicemyTestService2 = new ServiceBuilder().withMetadata(buildmyTestService2).withSpec(specmyTestService2).build();
server.expect().withPath("/api/v1/namespaces/default/services?labelSelector=version%3Dv1").andReturn(200, new ServiceListBuilder().addToItems(servicemyTestService).build()).times(1);
server.expect().withPath("/api/v1/namespaces/default/services?labelSelector=version%3Dv2").andReturn(200, new ServiceListBuilder().addToItems(servicemyTestService2).build()).times(1);
}
开发者ID:amoAHCP,项目名称:vxms,代码行数:18,代码来源:ResolveServicesByLabelOKTest.java
示例19: initService
import io.fabric8.kubernetes.api.model.Service; //导入依赖的package包/类
public void initService() {
final ObjectMeta buildmyTestService = new ObjectMetaBuilder().addToLabels("name", "myTestService").addToLabels("version", "v1").withName("myTestService").build();
final ServicePort portmyTestService = new ServicePortBuilder().withPort(8080).withProtocol("http").build();
final ServiceSpec specmyTestService = new ServiceSpecBuilder().addNewPort().and()
.withClusterIP("192.168.1.1").withPorts(portmyTestService).build();
final ObjectMeta buildmyTestService2 = new ObjectMetaBuilder().addToLabels("name", "myTestService").addToLabels("version", "v2").withName("myTestService2").build();
final ServicePort portmyTestService2 = new ServicePortBuilder().withPort(9080).withProtocol("http").build();
final ServiceSpec specmyTestService2 = new ServiceSpecBuilder().addNewPort().and()
.withClusterIP("192.168.1.2").withPorts(portmyTestService2).build();
final Service servicemyTestService = new ServiceBuilder().withMetadata(buildmyTestService).withSpec(specmyTestService).build();
final Service servicemyTestService2 = new ServiceBuilder().withMetadata(buildmyTestService2).withSpec(specmyTestService2).build();
server.expect().withPath("/api/v1/namespaces/default/services?labelSelector=service1x.name%3Dservice1x.value").andReturn(200, new ServiceListBuilder().build()).times(1);
server.expect().withPath("/api/v1/namespaces/default/services?labelSelector=service2x.name%3Dservice2x.value").andReturn(200, new ServiceListBuilder().build()).times(1);
}
开发者ID:amoAHCP,项目名称:vxms,代码行数:18,代码来源:ResolveServicesByLabelWithConfigNOKTest.java
示例20: createPods
import io.fabric8.kubernetes.api.model.Service; //导入依赖的package包/类
/**
* Creates OpenShift pods and resolves machine servers based on routes and services.
*
* @param services created OpenShift services
* @param routes created OpenShift routes
* @throws InfrastructureException when any error occurs while creating OpenShift pods
*/
@VisibleForTesting
void createPods(List<Service> services, List<Route> routes) throws InfrastructureException {
final ServerResolver serverResolver = ServerResolver.of(services, routes);
final OpenShiftEnvironment environment = getContext().getEnvironment();
final Map<String, InternalMachineConfig> machineConfigs = environment.getMachines();
for (Pod toCreate : environment.getPods().values()) {
final Pod createdPod = project.pods().create(toCreate);
final ObjectMeta podMetadata = createdPod.getMetadata();
for (Container container : createdPod.getSpec().getContainers()) {
String machineName = Names.machineName(toCreate, container);
OpenShiftMachine machine =
new OpenShiftMachine(
machineName,
podMetadata.getName(),
container.getName(),
serverResolver.resolve(machineName),
project,
MachineStatus.STARTING,
machineConfigs.get(machineName).getAttributes());
machines.put(machine.getName(), machine);
sendStartingEvent(machine.getName());
}
}
}
开发者ID:eclipse,项目名称:che,代码行数:32,代码来源:OpenShiftInternalRuntime.java
注:本文中的io.fabric8.kubernetes.api.model.Service类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论