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

Java PodSpec类代码示例

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

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



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

示例1: mountsSecretVolumeWhenLoadedFromYaml

import io.fabric8.kubernetes.api.model.PodSpec; //导入依赖的package包/类
@Test
public void mountsSecretVolumeWhenLoadedFromYaml() throws Exception {
  RunEnvironment env = fromYaml("/minimal-pod.yaml")
      .withSecret(SECRET);
  Pod pod = createPod(env);

  final PodSpec spec = pod.getSpec();
  assertThat(spec.getVolumes(), hasItems(new VolumeBuilder()
      .withName(SECRET.name())
      .withNewSecret()
          .withSecretName(SECRET.name())
      .endSecret()
      .build()));

  Container container = findHypeRunContainer(pod);
  assertThat(container.getVolumeMounts(), hasItems(new VolumeMountBuilder()
      .withName(SECRET.name())
      .withMountPath(SECRET.mountPath())
      .withReadOnly(true)
      .build()));
}
 
开发者ID:spotify,项目名称:hype,代码行数:22,代码来源:KubernetesDockerRunnerTest.java


示例2: newPod

import io.fabric8.kubernetes.api.model.PodSpec; //导入依赖的package包/类
private Pod newPod(String uid, String namespace, String name, String node) {
    Pod pod = new Pod();

    ObjectMeta objMeta = new ObjectMeta();
    objMeta.setName(name);
    objMeta.setNamespace(namespace);
    objMeta.setUid(uid);

    PodSpec spec = new PodSpec();
    spec.setNodeName(node);

    pod.setMetadata(objMeta);
    pod.setSpec(spec);

    return pod;
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:17,代码来源:KubernetesPodApiTest.java


示例3: deployWithEnvironmentWithCommaDelimitedValue

import io.fabric8.kubernetes.api.model.PodSpec; //导入依赖的package包/类
@Test
public void deployWithEnvironmentWithCommaDelimitedValue() throws Exception {
	AppDefinition definition = new AppDefinition("app-test", null);
	Map<String, String> props = new HashMap<>();
	props.put("spring.cloud.deployer.kubernetes.environmentVariables",
		"foo='bar,baz',car=caz,boo='zoo,gnu',doo=dar");

	AppDeploymentRequest appDeploymentRequest = new AppDeploymentRequest(definition, getResource(), props);

	deployer = new KubernetesAppDeployer(bindDeployerProperties(), null);
	PodSpec podSpec = deployer.createPodSpec("1", appDeploymentRequest, 8080, false);

	assertThat(podSpec.getContainers().get(0).getEnv())
		.contains(
			new EnvVar("foo", "bar,baz", null),
			new EnvVar("car", "caz", null),
			new EnvVar("boo", "zoo,gnu", null),
			new EnvVar("doo", "dar", null));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-kubernetes,代码行数:20,代码来源:KubernetesAppDeployerTests.java


示例4: provision

import io.fabric8.kubernetes.api.model.PodSpec; //导入依赖的package包/类
@Override
public void provision(OpenShiftEnvironment osEnv, RuntimeIdentity identity)
    throws InfrastructureException {
  final String workspaceId = identity.getWorkspaceId();
  final Set<String> subPaths = new HashSet<>();
  final PersistentVolumeClaim pvc = newPVC(pvcName, pvcAccessMode, pvcQuantity);
  osEnv.getPersistentVolumeClaims().put(pvcName, pvc);
  for (Pod pod : osEnv.getPods().values()) {
    PodSpec podSpec = pod.getSpec();
    for (Container container : podSpec.getContainers()) {
      String machineName = Names.machineName(pod, container);
      InternalMachineConfig machineConfig = osEnv.getMachines().get(machineName);
      addMachineVolumes(workspaceId, subPaths, podSpec, container, machineConfig);
    }
  }
  if (preCreateDirs && !subPaths.isEmpty()) {
    pvc.setAdditionalProperty(
        format(SUBPATHS_PROPERTY_FMT, workspaceId),
        subPaths.toArray(new String[subPaths.size()]));
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:CommonPVCStrategy.java


示例5: addMachineVolumes

import io.fabric8.kubernetes.api.model.PodSpec; //导入依赖的package包/类
private void addMachineVolumes(
    String workspaceId,
    Set<String> subPaths,
    PodSpec podSpec,
    Container container,
    InternalMachineConfig machineConfig) {
  if (machineConfig.getVolumes().isEmpty()) {
    return;
  }
  for (Entry<String, Volume> volumeEntry : machineConfig.getVolumes().entrySet()) {
    String volumePath = volumeEntry.getValue().getPath();
    String subPath = getVolumeSubPath(workspaceId, volumeEntry.getKey());
    subPaths.add(subPath);

    container.getVolumeMounts().add(newVolumeMount(pvcName, volumePath, subPath));
    addVolumeIfNeeded(podSpec);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:CommonPVCStrategy.java


示例6: addMachineVolumes

import io.fabric8.kubernetes.api.model.PodSpec; //导入依赖的package包/类
private void addMachineVolumes(
    String workspaceId,
    Map<String, PersistentVolumeClaim> claims,
    PodSpec podSpec,
    Container container,
    InternalMachineConfig machineConfig) {
  if (machineConfig.getVolumes().isEmpty()) {
    return;
  }
  for (Entry<String, Volume> volumeEntry : machineConfig.getVolumes().entrySet()) {
    String volumeName = volumeEntry.getKey();
    String volumePath = volumeEntry.getValue().getPath();
    String subPath = workspaceId + '/' + volumeName;
    String pvcUniqueName = pvcNamePrefix + '-' + workspaceId + '-' + volumeName;

    PersistentVolumeClaim newPVC = newPVC(pvcUniqueName, pvcAccessMode, pvcQuantity);
    putLabel(newPVC, CHE_WORKSPACE_ID_LABEL, workspaceId);
    claims.put(pvcUniqueName, newPVC);

    container.getVolumeMounts().add(newVolumeMount(pvcUniqueName, volumePath, subPath));

    addVolumeIfAbsent(podSpec, pvcUniqueName);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:UniqueWorkspacePVCStrategy.java


示例7: provision

import io.fabric8.kubernetes.api.model.PodSpec; //导入依赖的package包/类
@Override
public void provision(OpenShiftEnvironment osEnv, RuntimeIdentity identity)
    throws InfrastructureException {

  for (Pod podConfig : osEnv.getPods().values()) {
    final PodSpec podSpec = podConfig.getSpec();
    for (Container containerConfig : podSpec.getContainers()) {
      String machineName = Names.machineName(podConfig, containerConfig);
      InternalMachineConfig machineConfig = osEnv.getMachines().get(machineName);
      if (!machineConfig.getServers().isEmpty()) {
        ServerExposer serverExposer =
            new ServerExposer(machineName, podConfig, containerConfig, osEnv);
        serverExposer.expose(machineConfig.getServers());
      }
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:ServersConverter.java


示例8: mockPod

import io.fabric8.kubernetes.api.model.PodSpec; //导入依赖的package包/类
private static Pod mockPod(String machineName, long ramLimit) {
  final String containerName = "container_" + machineName;
  final Container containerMock = mock(Container.class);
  final ResourceRequirements resourcesMock = mock(ResourceRequirements.class);
  final Quantity quantityMock = mock(Quantity.class);
  final Pod podMock = mock(Pod.class);
  final PodSpec specMock = mock(PodSpec.class);
  final ObjectMeta metadataMock = mock(ObjectMeta.class);
  when(podMock.getSpec()).thenReturn(specMock);
  when(podMock.getMetadata()).thenReturn(metadataMock);
  when(quantityMock.getAmount()).thenReturn(String.valueOf(ramLimit));
  when(resourcesMock.getLimits()).thenReturn(ImmutableMap.of("memory", quantityMock));
  when(containerMock.getName()).thenReturn(containerName);
  when(containerMock.getResources()).thenReturn(resourcesMock);
  when(metadataMock.getAnnotations())
      .thenReturn(
          ImmutableMap.of(format(MACHINE_NAME_ANNOTATION_FMT, containerName), machineName));
  when(specMock.getContainers()).thenReturn(ImmutableList.of(containerMock));
  return podMock;
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:OpenShiftEnvironmentFactoryTest.java


示例9: updatePod

import io.fabric8.kubernetes.api.model.PodSpec; //导入依赖的package包/类
public String updatePod(final @NotNull String podId, final Pod pod) throws Exception {
    // TODO needs implementing remotely!

    return NodeHelper.excludeFromProcessMonitor(processMonitor, pod, new Callable<String>() {
        @Override
        public String call() throws Exception {
            System.out.println("Updating pod " + pod);
            PodSpec desiredState = pod.getSpec();
            Objects.notNull(desiredState, "desiredState");

            PodStatus currentState = NodeHelper.getOrCreatetStatus(pod);
            List<Container> containers = KubernetesHelper.getContainers(pod);
            model.updatePod(podId, pod);

            return NodeHelper.createMissingContainers(processManager, model, pod, currentState, containers);
        }
    });
}
 
开发者ID:fabric8io,项目名称:jube,代码行数:19,代码来源:ApiMasterService.java


示例10: createPodSpec

import io.fabric8.kubernetes.api.model.PodSpec; //导入依赖的package包/类
private PodSpec createPodSpec() throws IOException {
    PodSpec podSpec = new PodSpec();
    podSpec.setHostname("localhost");

    Container container = new Container();
    container.setImage("docker.io/wildflyext/wildfly-camel:latest");
    container.setName("wildfly-camel-test");

    ContainerPort port = new ContainerPort();
    port.setHostIP("0.0.0.0");
    port.setContainerPort(8080);

    List<ContainerPort> ports = new ArrayList<>();
    ports.add(port);
    container.setPorts(ports);

    List<Container> containers = new ArrayList<>();
    containers.add(container);

    podSpec.setContainers(containers);

    return podSpec;
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:24,代码来源:KubernetesIntegrationTest.java


示例11: mountsSecretVolume

import io.fabric8.kubernetes.api.model.PodSpec; //导入依赖的package包/类
@Test
public void mountsSecretVolume() throws Exception {
  RunEnvironment env = environment()
      .withSecret(SECRET);
  Pod pod = createPod(env);

  final PodSpec spec = pod.getSpec();
  assertThat(spec.getVolumes(), hasItems(new VolumeBuilder()
      .withName(SECRET.name())
      .withNewSecret()
          .withSecretName(SECRET.name())
      .endSecret()
      .build()));

  Container container = findHypeRunContainer(pod);
  assertThat(container.getVolumeMounts(), hasItems(new VolumeMountBuilder()
      .withName(SECRET.name())
      .withMountPath(SECRET.mountPath())
      .withReadOnly(true)
      .build()));
}
 
开发者ID:spotify,项目名称:hype,代码行数:22,代码来源:KubernetesDockerRunnerTest.java


示例12: createDeploymentSpec

import io.fabric8.kubernetes.api.model.PodSpec; //导入依赖的package包/类
protected DeploymentSpec createDeploymentSpec(final Map<String, String> labels,
                                              final String serviceAccountName,
                                              final String imageName,
                                              final ImagePullPolicy imagePullPolicy,
                                              final String namespace,
                                              final boolean hostNetwork,
                                              final boolean tls,
                                              final boolean verifyTls) {    
  final DeploymentSpec deploymentSpec = new DeploymentSpec();
  final PodTemplateSpec podTemplateSpec = new PodTemplateSpec();
  final ObjectMeta metadata = new ObjectMeta();
  metadata.setLabels(normalizeLabels(labels));
  podTemplateSpec.setMetadata(metadata);
  final PodSpec podSpec = new PodSpec();
  podSpec.setServiceAccountName(normalizeServiceAccountName(serviceAccountName));
  podSpec.setContainers(Arrays.asList(this.createContainer(imageName, imagePullPolicy, namespace, tls, verifyTls)));
  podSpec.setHostNetwork(Boolean.valueOf(hostNetwork));
  final Map<String, String> nodeSelector = new HashMap<>();
  nodeSelector.put("beta.kubernetes.io/os", "linux");
  podSpec.setNodeSelector(nodeSelector);    
  if (tls) {
    final Volume volume = new Volume();
    volume.setName(DEFAULT_NAME + "-certs");
    final SecretVolumeSource secretVolumeSource = new SecretVolumeSource();
    secretVolumeSource.setSecretName(SECRET_NAME);
    volume.setSecret(secretVolumeSource);
    podSpec.setVolumes(Arrays.asList(volume));
  }
  podTemplateSpec.setSpec(podSpec);
  deploymentSpec.setTemplate(podTemplateSpec);    
  return deploymentSpec;
}
 
开发者ID:microbean,项目名称:microbean-helm,代码行数:33,代码来源:TillerInstaller.java


示例13: newDeployment

import io.fabric8.kubernetes.api.model.PodSpec; //导入依赖的package包/类
private Deployment newDeployment(String uid, String namespace, String name, int desiredReplicaCount, String containerImageName) {
    Deployment deployment = new Deployment();

    ObjectMeta objMeta = new ObjectMeta();
    objMeta.setName(name);
    objMeta.setNamespace(namespace);
    objMeta.setUid(uid);

    DeploymentSpec spec = new DeploymentSpec();
    spec.setReplicas(desiredReplicaCount);

    Container container = new Container();
    container.setImage(containerImageName);

    PodSpec podSpec = new PodSpec();
    podSpec.setContainers(Arrays.asList(container));

    PodTemplateSpec podTemplateSpec = new PodTemplateSpec();
    podTemplateSpec.setSpec(podSpec);
    spec.setTemplate(podTemplateSpec);

    deployment.setMetadata(objMeta);
    deployment.setSpec(spec);

    DeploymentStatus deploymentStatus = new DeploymentStatus();
    deploymentStatus.setAvailableReplicas(3);
    deployment.setStatus(deploymentStatus);

    return deployment;
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:31,代码来源:KubernetesDeploymentApiTest.java


示例14: testGetStartedTime

import io.fabric8.kubernetes.api.model.PodSpec; //导入依赖的package包/类
@Test
public void testGetStartedTime() throws Exception {
    KubeCloudImage image = m.mock(KubeCloudImage.class);
    ObjectMeta metadata = new ObjectMeta();
    metadata.setName("foo");
    Pod pod = new Pod("1.0", "kind", metadata, new PodSpec(), new PodStatusBuilder().withStartTime("2017-06-12T22:59Z").build());
    m.checking(new Expectations(){{
        allowing(myApi).getPodStatus(with("foo")); will(returnValue(pod.getStatus()));
    }});
    KubeCloudInstanceImpl instance = new KubeCloudInstanceImpl(image, pod, myApi);
    Date startedTime = instance.getStartedTime();
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'");
    dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
    assertEquals("2017-06-12T22:59Z", dateFormat.format(startedTime));
}
 
开发者ID:JetBrains,项目名称:teamcity-kubernetes-plugin,代码行数:16,代码来源:KubeCloudInstanceImplTest.java


示例15: podsAsTable

import io.fabric8.kubernetes.api.model.PodSpec; //导入依赖的package包/类
protected TablePrinter podsAsTable(PodList pods) {
    TablePrinter table = new TablePrinter();
    table.columns("id", "image(s)", "host", "labels", "status");
    List<Pod> items = pods.getItems();
    if (items == null) {
        items = Collections.EMPTY_LIST;
    }
    Filter<Pod> filter = KubernetesHelper.createPodFilter(filterText.getValue());
    for (Pod item : items) {
        if (filter.matches(item)) {
            String id = KubernetesHelper.getName(item);
            PodStatus podStatus = item.getStatus();
            String status = "";
            String host = "";
            if (podStatus != null) {
                status = KubernetesHelper.getStatusText(podStatus);
                host = podStatus.getHostIP();
            }
            Map<String, String> labelMap = item.getMetadata().getLabels();
            String labels = KubernetesHelper.toLabelsString(labelMap);
            PodSpec spec = item.getSpec();
            if (spec != null) {
                List<Container> containerList = spec.getContainers();
                for (Container container : containerList) {
                    String image = container.getImage();
                    table.row(id, image, host, labels, status);

                    id = "";
                    host = "";
                    status = "";
                    labels = "";
                }
            }
        }
    }
    return table;
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:38,代码来源:PodsList.java


示例16: createPod

import io.fabric8.kubernetes.api.model.PodSpec; //导入依赖的package包/类
private void createPod(String appId, AppDeploymentRequest request, Map<String, String> idMap) {
	Map<String, String> podLabelMap = new HashMap<>();
	podLabelMap.put("task-name", request.getDefinition().getName());
	podLabelMap.put(SPRING_MARKER_KEY, SPRING_MARKER_VALUE);
	PodSpec spec = createPodSpec(appId, request, null, true);
	client.pods()
			.inNamespace(client.getNamespace()).createNew()
			.withNewMetadata()
			.withName(appId)
			.withLabels(podLabelMap)
			.addToLabels(idMap)
			.endMetadata()
			.withSpec(spec)
			.done();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-kubernetes,代码行数:16,代码来源:KubernetesTaskLauncher.java


示例17: deployWithVolumesOnly

import io.fabric8.kubernetes.api.model.PodSpec; //导入依赖的package包/类
@Test
public void deployWithVolumesOnly() throws Exception {
	AppDefinition definition = new AppDefinition("app-test", null);
	AppDeploymentRequest appDeploymentRequest = new AppDeploymentRequest(definition, getResource(),
		new HashMap<>());

	deployer = new KubernetesAppDeployer(bindDeployerProperties(), null);
	PodSpec podSpec = deployer.createPodSpec("1", appDeploymentRequest, 8080, false);

	assertThat(podSpec.getVolumes()).isEmpty();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-kubernetes,代码行数:12,代码来源:KubernetesAppDeployerTests.java


示例18: deployWithNodeSelector

import io.fabric8.kubernetes.api.model.PodSpec; //导入依赖的package包/类
@Test
public void deployWithNodeSelector() throws Exception {
	AppDefinition definition = new AppDefinition("app-test", null);
	Map<String, String> props = new HashMap<>();
	props.put("spring.cloud.deployer.kubernetes.deployment.nodeSelector", "disktype:ssd, os: linux");
	AppDeploymentRequest appDeploymentRequest = new AppDeploymentRequest(definition, getResource(), props);

	deployer = new KubernetesAppDeployer(bindDeployerProperties(), null);
	PodSpec podSpec = deployer.createPodSpec("1", appDeploymentRequest, 8080, false);

	assertThat(podSpec.getNodeSelector()).containsOnly(entry("disktype", "ssd"), entry("os", "linux"));

}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-kubernetes,代码行数:14,代码来源:KubernetesAppDeployerTests.java


示例19: doCreatePod

import io.fabric8.kubernetes.api.model.PodSpec; //导入依赖的package包/类
protected void doCreatePod(Exchange exchange, String operation)
        throws Exception {
    Pod pod = null;
    String podName = exchange.getIn().getHeader(
            KubernetesConstants.KUBERNETES_POD_NAME, String.class);
    String namespaceName = exchange.getIn().getHeader(
            KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
    PodSpec podSpec = exchange.getIn().getHeader(
            KubernetesConstants.KUBERNETES_POD_SPEC, PodSpec.class);
    if (ObjectHelper.isEmpty(podName)) {
        LOG.error("Create a specific pod require specify a pod name");
        throw new IllegalArgumentException(
                "Create a specific pod require specify a pod name");
    }
    if (ObjectHelper.isEmpty(namespaceName)) {
        LOG.error("Create a specific pod require specify a namespace name");
        throw new IllegalArgumentException(
                "Create a specific pod require specify a namespace name");
    }
    if (ObjectHelper.isEmpty(podSpec)) {
        LOG.error("Create a specific pod require specify a pod spec bean");
        throw new IllegalArgumentException(
                "Create a specific pod require specify a pod spec bean");
    }
    Map<String, String> labels = exchange.getIn().getHeader(
            KubernetesConstants.KUBERNETES_PODS_LABELS, Map.class);
    EditablePod podCreating = new PodBuilder().withNewMetadata()
            .withName(podName).withLabels(labels).endMetadata()
            .withSpec(podSpec).build();
    pod = getEndpoint().getKubernetesClient().pods()
            .inNamespace(namespaceName).create(podCreating);
    exchange.getOut().setBody(pod);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:34,代码来源:KubernetesPodsProducer.java


示例20: provision

import io.fabric8.kubernetes.api.model.PodSpec; //导入依赖的package包/类
@Override
public void provision(OpenShiftEnvironment osEnv, RuntimeIdentity identity)
    throws InfrastructureException {
  final Map<String, PersistentVolumeClaim> claims = osEnv.getPersistentVolumeClaims();
  for (Pod pod : osEnv.getPods().values()) {
    final PodSpec podSpec = pod.getSpec();
    for (Container container : podSpec.getContainers()) {
      final String machineName = Names.machineName(pod, container);
      InternalMachineConfig machineConfig = osEnv.getMachines().get(machineName);
      addMachineVolumes(identity.getWorkspaceId(), claims, podSpec, container, machineConfig);
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:14,代码来源:UniqueWorkspacePVCStrategy.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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