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


Java PodSpec类代码示例

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


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


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