当前位置: 首页>>代码示例>>Java>>正文


Java ServicePortBuilder类代码示例

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


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

示例1: initService

import io.fabric8.kubernetes.api.model.ServicePortBuilder; //导入依赖的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.ServicePortBuilder; //导入依赖的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.ServicePortBuilder; //导入依赖的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.ServicePortBuilder; //导入依赖的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.ServicePortBuilder; //导入依赖的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.ServicePortBuilder; //导入依赖的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.ServicePortBuilder; //导入依赖的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.ServicePortBuilder; //导入依赖的package包/类
@Override
public Service build() {
	ServiceSpecBuilder spec = new ServiceSpecBuilder();

	if (servicePorts.isEmpty()) {
		//keep this for backward compatibility with single port usage in testsuite
		if (containerPort == 0) {
			throw new IllegalStateException("containerPort must be set for service");
		}
		spec.withPorts(new ServicePortBuilder()
			.withProtocol(protocol.uppercase())
			.withPort(port)
			.withNewTargetPort(containerPort).build());
	} else {
		spec.withPorts(servicePorts);
	}

	spec.withSessionAffinity(sessionAffinity.toString());

	spec.withSelector(selectors);

	if (clusterIP != null) {
		spec.withClusterIP(clusterIP);
	}

	if (this.isNodePort) {
		spec.withType("NodePort");
	}

	return new io.fabric8.kubernetes.api.model.ServiceBuilder()
			.withMetadata(metadataBuilder().build())
			.withSpec(spec.build())
			.build();
}
 
开发者ID:xtf-cz,项目名称:xtf,代码行数:35,代码来源:ServiceBuilder.java

示例9: build

import io.fabric8.kubernetes.api.model.ServicePortBuilder; //导入依赖的package包/类
@Override
public ServicePort build() {
	if (targetPort == 0) {
		throw new IllegalStateException("targetPort must be set for service");
	}
	ServicePortBuilder servicePort = new ServicePortBuilder();
	if (StringUtils.isNotBlank(getName())) { servicePort.withName(getName()); }
	servicePort.withProtocol(protocol.uppercase())
			.withPort(port)
			.withNewTargetPort(targetPort);
	return servicePort.build();
}
 
开发者ID:xtf-cz,项目名称:xtf,代码行数:13,代码来源:PortBuilder.java

示例10: configureDatastore

import io.fabric8.kubernetes.api.model.ServicePortBuilder; //导入依赖的package包/类
static DeploymentConfigBuilder configureDatastore(final ApplicationBuilder appBuilder) {
	final DeploymentConfigBuilder cassandra = appBuilder.deploymentConfig("middleware-manager-datastore", "middleware-manager-datastore", false);

	cassandra
			.onConfigurationChange()
			.podTemplate()
			.container()
			.fromImage(ImageRegistry.get().midlewareManagerStorage())
			.envVar("CASSANDRA_START_RPC", "true")
			.port(9042, "cql-port")
			.port(9160, "thift-port")
			.port(7000, "tcp-port")
			.port(7001, "ssl-port")
			.port(7199, "jmx-port")
			.addVolumeMount("cassandra-data", "/opt/apache-cassandra/data", false)
			.pod()
			.addEmptyDirVolume("cassandra-data").container()
			.addReadinessProbe().createTcpProbe("7000");

	appBuilder.service("middleware-manager-datastore")
			.addContainerSelector("name", "middleware-manager-datastore")
			.ports(new ServicePortBuilder().withName("cql-port").withPort(9042).withTargetPort(new IntOrString("cql-port")).build(),
					new ServicePortBuilder().withName("thift-port").withPort(9160).withTargetPort(new IntOrString("thift-port")).build(),
					new ServicePortBuilder().withName("tcp-port").withPort(7000).withTargetPort(new IntOrString("tcp-port")).build(),
					new ServicePortBuilder().withName("ssl-port").withPort(7001).withTargetPort(new IntOrString("ssl-port")).build(),
					new ServicePortBuilder().withName("jmx-port").withPort(7199).withTargetPort(new IntOrString("jmx-port")).build()
			);

	return cassandra;
}
 
开发者ID:xtf-cz,项目名称:xtf,代码行数:31,代码来源:MiddlewareManagerUtil.java

示例11: exposePort

import io.fabric8.kubernetes.api.model.ServicePortBuilder; //导入依赖的package包/类
private Map<String, ServicePort> exposePort(Collection<? extends ServerConfig> serverConfig) {
  Map<String, ServicePort> exposedPorts = new HashMap<>();
  Set<String> portsToExpose =
      serverConfig.stream().map(ServerConfig::getPort).collect(Collectors.toSet());

  for (String portToExpose : portsToExpose) {
    String[] portProtocol = portToExpose.split("/");
    int port = parseInt(portProtocol[0]);
    String protocol = portProtocol.length > 1 ? portProtocol[1].toUpperCase() : "TCP";
    Optional<ContainerPort> exposedOpt =
        container
            .getPorts()
            .stream()
            .filter(p -> p.getContainerPort().equals(port) && protocol.equals(p.getProtocol()))
            .findAny();
    ContainerPort containerPort;

    if (exposedOpt.isPresent()) {
      containerPort = exposedOpt.get();
    } else {
      containerPort =
          new ContainerPortBuilder().withContainerPort(port).withProtocol(protocol).build();
      container.getPorts().add(containerPort);
    }

    exposedPorts.put(
        portToExpose,
        new ServicePortBuilder()
            .withName("server-" + containerPort.getContainerPort())
            .withPort(containerPort.getContainerPort())
            .withProtocol(protocol)
            .withNewTargetPort(containerPort.getContainerPort())
            .build());
  }
  return exposedPorts;
}
 
开发者ID:eclipse,项目名称:che,代码行数:37,代码来源:ServerExposer.java

示例12: mockService

import io.fabric8.kubernetes.api.model.ServicePortBuilder; //导入依赖的package包/类
private static Service mockService() {
  final Service service = mock(Service.class);
  final ServiceSpec spec = mock(ServiceSpec.class);
  mockName(SERVICE_NAME, service);
  when(service.getSpec()).thenReturn(spec);
  when(spec.getSelector()).thenReturn(ImmutableMap.of(POD_SELECTOR, POD_NAME));
  final ServicePort sp1 =
      new ServicePortBuilder().withTargetPort(intOrString(EXPOSED_PORT_1)).build();
  final ServicePort sp2 =
      new ServicePortBuilder().withTargetPort(intOrString(EXPOSED_PORT_2)).build();
  when(spec.getPorts()).thenReturn(ImmutableList.of(sp1, sp2));
  return service;
}
 
开发者ID:eclipse,项目名称:che,代码行数:14,代码来源:OpenShiftInternalRuntimeTest.java

示例13: toServicePort

import io.fabric8.kubernetes.api.model.ServicePortBuilder; //导入依赖的package包/类
public ServicePort toServicePort() {
    return new ServicePortBuilder().withPort(port).withName(getName()).build();
}
 
开发者ID:StuPro-TOSCAna,项目名称:TOSCAna,代码行数:4,代码来源:Port.java

示例14: getOpenServicePorts

import io.fabric8.kubernetes.api.model.ServicePortBuilder; //导入依赖的package包/类
public List<ServicePort> getOpenServicePorts() {
    List<ServicePort> ports = new ArrayList<>();
    openPorts.forEach(e -> ports.add(new ServicePortBuilder().withPort(e).build()));
    return Collections.unmodifiableList(ports);
}
 
开发者ID:StuPro-TOSCAna,项目名称:TOSCAna,代码行数:6,代码来源:NodeStack.java

示例15: newServicePort

import io.fabric8.kubernetes.api.model.ServicePortBuilder; //导入依赖的package包/类
private ServicePort newServicePort(final int port) {
    return new ServicePortBuilder().withPort(port).withNewTargetPort(port).build();
}
 
开发者ID:fabzo,项目名称:kraken,代码行数:4,代码来源:KubernetesLifecycleHandler.java


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