• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ServiceBuilder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中io.fabric8.kubernetes.api.model.ServiceBuilder的典型用法代码示例。如果您正苦于以下问题:Java ServiceBuilder类的具体用法?Java ServiceBuilder怎么用?Java ServiceBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ServiceBuilder类属于io.fabric8.kubernetes.api.model包,在下文中一共展示了ServiceBuilder类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: initService

import io.fabric8.kubernetes.api.model.ServiceBuilder; //导入依赖的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


示例2: initService

import io.fabric8.kubernetes.api.model.ServiceBuilder; //导入依赖的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


示例3: initService

import io.fabric8.kubernetes.api.model.ServiceBuilder; //导入依赖的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


示例4: initService

import io.fabric8.kubernetes.api.model.ServiceBuilder; //导入依赖的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


示例5: initService

import io.fabric8.kubernetes.api.model.ServiceBuilder; //导入依赖的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


示例6: initService

import io.fabric8.kubernetes.api.model.ServiceBuilder; //导入依赖的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


示例7: createService

import io.fabric8.kubernetes.api.model.ServiceBuilder; //导入依赖的package包/类
private Service createService(
    String name, String machineName, Integer port, Map<String, ServerConfigImpl> servers) {
  Serializer serializer = Annotations.newSerializer();
  serializer.machineName(machineName);
  if (servers != null) {
    serializer.servers(servers);
  }

  return new ServiceBuilder()
      .withNewMetadata()
      .withName(name)
      .withAnnotations(serializer.annotations())
      .endMetadata()
      .withNewSpec()
      .withPorts(
          new ServicePortBuilder()
              .withPort(port)
              .withNewTargetPort()
              .withIntVal(port)
              .endTargetPort()
              .build())
      .endSpec()
      .build();
}
 
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:ServerResolverTest.java


示例8: build

import io.fabric8.kubernetes.api.model.ServiceBuilder; //导入依赖的package包/类
public ResourceService build() {
    service = new ServiceBuilder()
        .withNewMetadata()
        .withName(name + "-service")
        .addToLabels("app", name + "-service")
        .endMetadata()
        .withNewSpec()
        .addAllToPorts(pod.getPorts().stream().map(Port::toServicePort).collect(Collectors.toList()))
        .addToSelector("app", name)
        .withType("NodePort")
        .endSpec()
        .build();
    return this;
}
 
开发者ID:StuPro-TOSCAna,项目名称:TOSCAna,代码行数:15,代码来源:ResourceService.java


示例9: buildDockerService

import io.fabric8.kubernetes.api.model.ServiceBuilder; //导入依赖的package包/类
private Service buildDockerService(final DockerComponent component, final EnvironmentContext ctx) {
    //@formatter:off
    val servicePart = new ServiceBuilder()
        .withNewMetadata()
            .withName(saltedName(ctx.salt(), component.name()))
            .addToLabels("salt", ctx.salt())
            .addToLabels("app", component.name())
            .addToLabels("scope", "integration-tests")
            .endMetadata()
        .withNewSpec()
            .addAllToPorts(createServicePorts(component, ctx))
            .addToSelector("salt", ctx.salt())
            .addToSelector("app", component.name())
            .addToSelector("scope", "integration-tests");
    //@formatter:on

    final Service service;
    switch (config.defaultServiceType()) {
        case NODE_PORT:
            service = servicePart.withType("NodePort").endSpec().build();
            break;
        case LOAD_BALANCER:
            service = servicePart.withType("LoadBalancer").endSpec().build();
            break;
        case DEFAULT:
        default:
            service = servicePart.endSpec().build();
            break;
    }

    return service;
}
 
开发者ID:fabzo,项目名称:kraken,代码行数:33,代码来源:KubernetesLifecycleHandler.java


示例10: doCreateService

import io.fabric8.kubernetes.api.model.ServiceBuilder; //导入依赖的package包/类
protected void doCreateService(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);
    ServiceSpec serviceSpec = exchange.getIn().getHeader(
            KubernetesConstants.KUBERNETES_SERVICE_SPEC, ServiceSpec.class);
    if (ObjectHelper.isEmpty(serviceName)) {
        LOG.error("Create a specific service require specify a service name");
        throw new IllegalArgumentException(
                "Create a specific service require specify a service name");
    }
    if (ObjectHelper.isEmpty(namespaceName)) {
        LOG.error("Create a specific service require specify a namespace name");
        throw new IllegalArgumentException(
                "Create a specific service require specify a namespace name");
    }
    if (ObjectHelper.isEmpty(serviceSpec)) {
        LOG.error("Create a specific service require specify a service spec bean");
        throw new IllegalArgumentException(
                "Create a specific service require specify a service spec bean");
    }
    Map<String, String> labels = exchange.getIn().getHeader(
            KubernetesConstants.KUBERNETES_SERVICE_LABELS, Map.class);
    EditableService serviceCreating = new ServiceBuilder()
            .withNewMetadata().withName(serviceName).withLabels(labels)
            .endMetadata().withSpec(serviceSpec).build();
    service = getEndpoint().getKubernetesClient().services()
            .inNamespace(namespaceName).create(serviceCreating);
    exchange.getOut().setBody(service);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:34,代码来源:KubernetesServicesProducer.java


示例11: findServices

import io.fabric8.kubernetes.api.model.ServiceBuilder; //导入依赖的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



注:本文中的io.fabric8.kubernetes.api.model.ServiceBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EventListener类代码示例发布时间:2022-05-23
下一篇:
Java AttributePattern类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap